[elbe-devel] [PATCH] db/pwhash: use encrypt function as fallback
Manuel Traut
manut at linutronix.de
Wed Jun 28 06:56:06 CEST 2017
because the hash function is not available in jessie
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/db.py | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/elbepack/db.py b/elbepack/db.py
index 26d44056..baf4c091 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -849,11 +849,18 @@ class ElbeDB(object):
### User management ###
def add_user (self, name, fullname, password, email, admin):
+ # encrypt is deprecated but hash is not available in jessie
+ try:
+ hash = pbkdf2_sha512.hash( password )
+ except AttributeError:
+ hash = pbkdf2_sha512.encrypt( password )
+
u = User( name = name,
- fullname = fullname,
- pwhash = pbkdf2_sha512.hash( password ),
- email = email,
- admin = admin )
+ fullname = fullname,
+ pwhash = hash,
+ email = email,
+ admin = admin )
+
with session_scope(self.session) as s:
if s.query(User).filter(User.name == name).count() > 0:
raise ElbeDBError( "user %s already exists in the database" %
@@ -881,7 +888,11 @@ class ElbeDB(object):
# Update password only if given
if not password is None:
- u.pwhash = pbkdf2_sha512.hash( password )
+ # encrypt is deprecated but hash is not available in jessie
+ try:
+ u.pwhash = pbkdf2_sha512.hash( password )
+ except AttributeError:
+ u.pwhash = pbkdf2_sha512.encrypt( password )
def del_user (self, userid):
with session_scope(self.session) as s:
--
2.13.2
More information about the elbe-devel
mailing list