2 ''' Sample externpasscheck script for use with voicemail.conf
4 Copyright (C) 2010, Digium, Inc.
5 Russell Bryant <russell@digium.com>
7 The externpasscheck option in voicemail.conf allows an external script to
8 validate passwords when a user is changing it. The script can enforce password
9 strength rules. This script is an example of doing so and implements a check
10 on password length, a password with too many identical consecutive numbers, or
11 a password made up of sequential digits.
24 (
"(?P<digit>\d)(?P=digit){%d}" % (REQUIRED_LENGTH - 1),
25 "%d consecutive numbers that are the same" % REQUIRED_LENGTH)
45 mailbox, context, old_pw, new_pw = sys.argv[1:5]
48 if len(new_pw) < REQUIRED_LENGTH:
49 print(
"INVALID: Password is too short (%d) - must be at least %d" % \
50 (len(new_pw), REQUIRED_LENGTH))
53 for regex, error
in REGEX_BLACKLIST:
54 if re.search(regex, new_pw):
55 print(
"INVALID: %s" % error)
58 for pw
in PW_BLACKLIST:
59 if new_pw.find(pw) != -1:
60 print(
"INVALID: %s is forbidden in a password" % pw)