Commit d4c27e43 authored by Matthew Wilkes's avatar Matthew Wilkes

Make the SHA usage in mkzopeinstance a conditional import. Re-adds Python2.4 compatibility

parent 0a2faf57
...@@ -167,9 +167,12 @@ def get_inituser(): ...@@ -167,9 +167,12 @@ def get_inituser():
def write_inituser(fn, user, password): def write_inituser(fn, user, password):
import binascii import binascii
import hashlib try:
from hashlib import sha256 as sha
except:
from sha import new as sha
fp = open(fn, "w") fp = open(fn, "w")
pw = binascii.b2a_base64(hashlib.sha256(password).digest())[:-1] pw = binascii.b2a_base64(sha(password).digest())[:-1]
fp.write('%s:{SHA256}%s\n' % (user, pw)) fp.write('%s:{SHA256}%s\n' % (user, pw))
fp.close() fp.close()
os.chmod(fn, 0644) os.chmod(fn, 0644)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment