Fix work lib without py-smbpasswd.

Without py-smbpasswd calculate-lib does not support crypt algoritm
lm and nt.
develop
Mike Hiretsky 14 years ago
parent ea54e05efe
commit 0849c0bd2b

@ -23,7 +23,10 @@ import time
from random import choice
from base64 import encodestring as _b64enc
b64encode = lambda x: _b64enc(x).rstrip()
import smbpasswd
try:
from smbpasswd import lmhash,nthash
except ImportError:
lmhash,nthash = None,None
from cl_print import color_print
# для создания сертификата
import pwd
@ -101,14 +104,17 @@ class encrypt(color_print):
h.update(salt)
hashPwd = "{SSHA}" + b64encode(h.digest() + salt)
elif SecHashAlg == "lm":
hashPwd = smbpasswd.lmhash(password)
elif SecHashAlg == "nt":
hashPwd = smbpasswd.nthash(password)
elif SecHashAlg == "lm" and lmhash:
hashPwd = lmhash(password)
elif SecHashAlg == "nt" and nthash:
hashPwd = nthash(password)
else:
self.printERROR(_("ERROR") + " getHashPasswd: " +\
if SecHashAlg in ("lm","nt"):
self.printERROR(_("ERROR") + " getHashPasswd: " +\
(_("Can not support '%s' crypto algorithm")\
%SecHashAlg) + " " + _("without py-smbpasswd"))
else:
self.printERROR(_("ERROR") + " getHashPasswd: " +\
_("Can not support '%s' crypto algorithm")\
%SecHashAlg)
return False

Loading…
Cancel
Save