208 if cfg_dget('misc.dovecot_version') >= 0x1010cf00: |
208 if cfg_dget('misc.dovecot_version') >= 0x1010cf00: |
209 md5.update('%s:%s:' % (user.localpart, user.domainname)) |
209 md5.update('%s:%s:' % (user.localpart, user.domainname)) |
210 else: |
210 else: |
211 md5.update('%s::' % user) |
211 md5.update('%s::' % user) |
212 md5.update(password) |
212 md5.update(password) |
213 if (scheme in ('PLAIN-MD5', 'DIGEST-MD5') and encoding in DEFAULT_HEX) \ |
213 if (scheme in ('PLAIN-MD5', 'DIGEST-MD5') and encoding in DEFAULT_HEX) or \ |
214 or (scheme == 'LDAP-MD5' and encoding == 'HEX'): |
214 (scheme == 'LDAP-MD5' and encoding == 'HEX'): |
215 digest = md5.hexdigest() |
215 digest = md5.hexdigest() |
216 else: |
216 else: |
217 digest = md5.digest().encode('base64').rstrip() |
217 digest = md5.digest().encode('base64').rstrip() |
218 return _format_digest(digest, scheme, encoding) |
218 return _format_digest(digest, scheme, encoding) |
219 |
219 |
365 scheme = scheme_encoding[0] |
365 scheme = scheme_encoding[0] |
366 if not scheme in _scheme_info: |
366 if not scheme in _scheme_info: |
367 raise VMMError(_(u"Unsupported password scheme: '%s'") % scheme, |
367 raise VMMError(_(u"Unsupported password scheme: '%s'") % scheme, |
368 VMM_ERROR) |
368 VMM_ERROR) |
369 if cfg_dget('misc.dovecot_version') < _scheme_info[scheme][1]: |
369 if cfg_dget('misc.dovecot_version') < _scheme_info[scheme][1]: |
370 raise VMMError(_(u"The password scheme '%(scheme)s' requires Dovecot \ |
370 raise VMMError(_(u"The password scheme '%(scheme)s' requires Dovecot " |
371 >= v%(version)s") % |
371 u">= v%(version)s") % {'scheme': scheme, |
372 {'scheme': scheme, |
372 'version': version_str(_scheme_info[scheme][1])}, |
373 'version': version_str(_scheme_info[scheme][1])}, |
|
374 VMM_ERROR) |
373 VMM_ERROR) |
375 if len(scheme_encoding) > 1: |
374 if len(scheme_encoding) > 1: |
376 if cfg_dget('misc.dovecot_version') < 0x10100a01: |
375 if cfg_dget('misc.dovecot_version') < 0x10100a01: |
377 raise VMMError(_(u'Encoding suffixes for password schemes require \ |
376 raise VMMError(_(u'Encoding suffixes for password schemes require ' |
378 Dovecot >= v1.1.alpha1'), |
377 u'Dovecot >= v1.1.alpha1'), VMM_ERROR) |
379 VMM_ERROR) |
|
380 if scheme_encoding[1] not in ('B64', 'BASE64', 'HEX'): |
378 if scheme_encoding[1] not in ('B64', 'BASE64', 'HEX'): |
381 raise VMMError(_(u"Unsupported password encoding: '%s'") % |
379 raise VMMError(_(u"Unsupported password encoding: '%s'") % |
382 scheme_encoding[1], VMM_ERROR) |
380 scheme_encoding[1], VMM_ERROR) |
383 encoding = scheme_encoding[1] |
381 encoding = scheme_encoding[1] |
384 else: |
382 else: |