From: parmentelat Date: Fri, 14 Dec 2018 12:08:22 +0000 (+0100) Subject: more tweaks for python3 X-Git-Tag: plcapi-7.0-0~14 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=f9b4cbd4cee0c41047fb6a140bb50e8cc1f79b55 more tweaks for python3 --- diff --git a/PLC/Auth.py b/PLC/Auth.py index afde8c1..33f60c2 100644 --- a/PLC/Auth.py +++ b/PLC/Auth.py @@ -324,7 +324,7 @@ class PasswordAuth(Auth): "PasswordAuth: Maintenance account password verification failed") else: # Compare encrypted plaintext against encrypted password stored in the DB - plaintext = auth['AuthString'].encode(method.api.encoding) + plaintext = auth['AuthString'] password = person['password'] # Protect against blank passwords in the DB diff --git a/PLC/Persons.py b/PLC/Persons.py index d24597a..bc4b4c1 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -5,10 +5,7 @@ # Copyright (C) 2006 The Trustees of Princeton University # -try: - from hashlib import md5 -except ImportError: - from md5 import md5 +from hashlib import md5 import time from random import Random import re @@ -113,8 +110,8 @@ class Person(Row): else: # Generate a somewhat unique 8 character salt string salt = str(time.time()) + str(Random().random()) - salt = md5(salt).hexdigest()[:8] - return crypt.crypt(password.encode(self.api.encoding), magic + salt + "$") + salt = md5(salt.encode()).hexdigest()[:8] + return crypt.crypt(password, magic + salt + "$") validate_date_created = Row.validate_timestamp validate_last_updated = Row.validate_timestamp diff --git a/PLC/Sites.py b/PLC/Sites.py index 9d565c4..f9f16bc 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -68,7 +68,7 @@ class Site(Row): if not len(login_base): raise PLCInvalidArgument("Login base must be specified") - if not set(login_base).issubset(string.lowercase + string.digits + '.'): + if not set(login_base).issubset(string.ascii_lowercase + string.digits + '.'): raise PLCInvalidArgument("Login base must consist only of lowercase ASCII letters or numbers or dots") conflicts = Sites(self.api, [login_base])