From f9b4cbd4cee0c41047fb6a140bb50e8cc1f79b55 Mon Sep 17 00:00:00 2001 From: parmentelat Date: Fri, 14 Dec 2018 13:08:22 +0100 Subject: [PATCH] more tweaks for python3 --- PLC/Auth.py | 2 +- PLC/Persons.py | 9 +++------ PLC/Sites.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) 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]) -- 2.43.0