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 random import choice
from base64 import encodestring as _b64enc from base64 import encodestring as _b64enc
b64encode = lambda x: _b64enc(x).rstrip() 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 from cl_print import color_print
# для создания сертификата # для создания сертификата
import pwd import pwd
@ -101,14 +104,17 @@ class encrypt(color_print):
h.update(salt) h.update(salt)
hashPwd = "{SSHA}" + b64encode(h.digest() + salt) hashPwd = "{SSHA}" + b64encode(h.digest() + salt)
elif SecHashAlg == "lm": elif SecHashAlg == "lm" and lmhash:
hashPwd = smbpasswd.lmhash(password) hashPwd = lmhash(password)
elif SecHashAlg == "nt" and nthash:
elif SecHashAlg == "nt": hashPwd = nthash(password)
hashPwd = smbpasswd.nthash(password)
else: 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")\ _("Can not support '%s' crypto algorithm")\
%SecHashAlg) %SecHashAlg)
return False return False

Loading…
Cancel
Save