X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=userdir_ldap.py;h=9e998994aab0e57d469d692cd86aa8943010eec7;hb=04409346418395c9f00c5f4a8244ce1d3512b446;hp=109c7cec17c40d787d508cbec58b9d730f3b6300;hpb=2dbb95ed55973f4cfbffe44871b9b344179b6fff;p=mirror%2Fuserdir-ldap.git diff --git a/userdir_ldap.py b/userdir_ldap.py index 109c7ce..9e99899 100644 --- a/userdir_ldap.py +++ b/userdir_ldap.py @@ -22,7 +22,7 @@ import termios, re, imp, ldap, sys, crypt, rfc822, pwd, os, getpass import userdir_gpg import hmac -import sha as sha1_module +import hashlib try: File = open("/etc/userdir-ldap/userdir-ldap.conf"); @@ -432,10 +432,13 @@ def Group2GID(l, name): return -1 def make_hmac(str): - File = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r"); - HmacKey = File.readline().strip() - File.close(); - return hmac.new(HmacKey, str, sha1_module).hexdigest() + if 'UD_HMAC_KEY' in os.environ: + HmacKey = os.environ['UD_HMAC_KEY'] + else: + File = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r"); + HmacKey = File.readline().strip() + File.close(); + return hmac.new(HmacKey, str, hashlib.sha1).hexdigest() def make_passwd_hmac(status, purpose, uid, uuid, hosts, cryptedpass): return make_hmac(':'.join([status, purpose, uid, uuid, hosts, cryptedpass]))