diff options
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r-- | ipaserver/install/installutils.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 345bf06bb..6ae117cb4 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -313,7 +313,11 @@ def get_password(prompt): else: return sys.stdin.readline().rstrip() -def read_password(user, confirm=True, validate=True, retry=True): +def _read_password_default_validator(password): + if len(password) < 8: + raise ValueError("Password must be at least 8 characters long") + +def read_password(user, confirm=True, validate=True, retry=True, validator=_read_password_default_validator): correct = False pwd = "" while not correct: @@ -322,10 +326,13 @@ def read_password(user, confirm=True, validate=True, retry=True): pwd = get_password(user + " password: ") if not pwd: continue - if validate and len(pwd) < 8: - print "Password must be at least 8 characters long" - pwd = "" - continue + if validate: + try: + validator(pwd) + except ValueError, e: + print str(e) + pwd = "" + continue if not confirm: correct = True continue |