VirtualMailManager/password.py
branchv0.6.x
changeset 274 45ec5c3cfef4
parent 272 446483386914
child 284 ec1966828246
equal deleted inserted replaced
273:77fc7138ef6a 274:45ec5c3cfef4
    50         cmd_args.insert(1, 'pw')
    50         cmd_args.insert(1, 'pw')
    51     process = Popen(cmd_args, stdout=PIPE, stderr=PIPE)
    51     process = Popen(cmd_args, stdout=PIPE, stderr=PIPE)
    52     stdout, stderr = process.communicate()
    52     stdout, stderr = process.communicate()
    53     if process.returncode:
    53     if process.returncode:
    54         raise VMMError(stderr.strip(), VMM_ERROR)
    54         raise VMMError(stderr.strip(), VMM_ERROR)
    55     return stdout.strip()
    55     hashed = stdout.strip()
       
    56     if not hashed.startswith('{%s}' % scheme):
       
    57         raise VMMError('Unexpected result from %s: %s' %
       
    58                        (cfg_dget('bin.dovecotpw'), hashed), VMM_ERROR)
       
    59     return hashed
    56 
    60 
    57 
    61 
    58 def _md4_new():
    62 def _md4_new():
    59     """Returns an new MD4-hash object if supported by the hashlib or
    63     """Returns an new MD4-hash object if supported by the hashlib or
    60     provided by PyCrypto - other `None`.
    64     provided by PyCrypto - other `None`.