diff -r e57dd007d69a -r cabdf94ec580 VirtualMailManager/password.py --- a/VirtualMailManager/password.py Sun Nov 06 04:47:43 2011 +0000 +++ b/VirtualMailManager/password.py Sun Nov 06 21:26:34 2011 +0000 @@ -12,6 +12,7 @@ hashed_password = pwhash(password[, scheme][, user]) random_password = randompw() scheme, encoding = verify_scheme(scheme) + schemes, encodings = list_schemes() """ from crypt import crypt @@ -348,6 +349,23 @@ } +def list_schemes(): + """Returns the tuple (schemes, encodings). + + `schemes` is an iterator for all supported password schemes (depends on + the used Dovecot version and features of the libc). + `encodings` is a tuple with all usable encoding suffixes. The tuple may + be empty. + """ + dcv = cfg_dget('misc.dovecot_version') + schemes = (k for (k, v) in _scheme_info.iteritems() if v[1] <= dcv) + if dcv >= 0x10100a01: + encodings = DEFAULT_B64[1:] + DEFAULT_HEX[1:] + else: + encodings = () + return schemes, encodings + + def verify_scheme(scheme): """Checks if the password scheme *scheme* is known and supported by the configured `misc.dovecot_version`.