Support for LDAP password modification (user level only for now). I need a working environment to check if postfix/dovecot accept the way I encrypt passwords.

see #192
This commit is contained in:
Antoine Nguyen
2011-12-28 13:30:01 +01:00
parent 880880a374
commit 96dfb877ae
5 changed files with 82 additions and 39 deletions
+3 -2
View File
@@ -34,11 +34,12 @@ def _check_password(password, crypted):
return hashlib.md5(password).hexdigest() == crypted
return password
def crypt_password(password):
def crypt_password(password, hexdigest=True):
scheme = parameters.get_admin("PASSWORD_SCHEME", app="admin")
if scheme == "crypt":
salt = ''.join(Random().sample(string.letters + string.digits, 2))
return crypt.crypt(password, salt)
if scheme == "md5":
return hashlib.md5(password).hexdigest()
obj = hashlib.md5(password)
return obj.hexdigest() if hexdigest else obj.digest()
return password