equal
deleted
inserted
replaced
10 functions: |
10 functions: |
11 |
11 |
12 hashed_password = pwhash(password[, scheme][, user]) |
12 hashed_password = pwhash(password[, scheme][, user]) |
13 random_password = randompw() |
13 random_password = randompw() |
14 scheme, encoding = verify_scheme(scheme) |
14 scheme, encoding = verify_scheme(scheme) |
|
15 schemes, encodings = list_schemes() |
15 """ |
16 """ |
16 |
17 |
17 from crypt import crypt |
18 from crypt import crypt |
18 from random import SystemRandom |
19 from random import SystemRandom |
19 from subprocess import Popen, PIPE |
20 from subprocess import Popen, PIPE |
346 'SSHA256': (_ssha256_hash, 0x10200a04), |
347 'SSHA256': (_ssha256_hash, 0x10200a04), |
347 'SSHA512': (_ssha512_hash, 0x20000b03), |
348 'SSHA512': (_ssha512_hash, 0x20000b03), |
348 } |
349 } |
349 |
350 |
350 |
351 |
|
352 def list_schemes(): |
|
353 """Returns the tuple (schemes, encodings). |
|
354 |
|
355 `schemes` is an iterator for all supported password schemes (depends on |
|
356 the used Dovecot version and features of the libc). |
|
357 `encodings` is a tuple with all usable encoding suffixes. The tuple may |
|
358 be empty. |
|
359 """ |
|
360 dcv = cfg_dget('misc.dovecot_version') |
|
361 schemes = (k for (k, v) in _scheme_info.iteritems() if v[1] <= dcv) |
|
362 if dcv >= 0x10100a01: |
|
363 encodings = DEFAULT_B64[1:] + DEFAULT_HEX[1:] |
|
364 else: |
|
365 encodings = () |
|
366 return schemes, encodings |
|
367 |
|
368 |
351 def verify_scheme(scheme): |
369 def verify_scheme(scheme): |
352 """Checks if the password scheme *scheme* is known and supported by the |
370 """Checks if the password scheme *scheme* is known and supported by the |
353 configured `misc.dovecot_version`. |
371 configured `misc.dovecot_version`. |
354 |
372 |
355 The *scheme* maybe a password scheme's name (e.g.: 'PLAIN') or a scheme |
373 The *scheme* maybe a password scheme's name (e.g.: 'PLAIN') or a scheme |