X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-mailgate;h=81d3757b510252a84afed5bfcbd4f085bbd302bd;hb=5f0890953c9bf981431b461530ff7c196d7d3861;hp=4f8fee35d03dd70a9eef4e055f74e566b338b444;hpb=76d1b148de5785a608e6cb7968bea0d108166b0c;p=mirror%2Fuserdir-ldap.git diff --git a/ud-mailgate b/ud-mailgate index 4f8fee3..81d3757 100755 --- a/ud-mailgate +++ b/ud-mailgate @@ -8,10 +8,7 @@ import userdir_gpg, userdir_ldap, sys, traceback, time, ldap, os, commands import pwd, tempfile import hmac -try: - import hashlib -except ImportError: - import sha as sha1_module +import sha as sha1_module from userdir_gpg import * from userdir_ldap import * @@ -99,11 +96,11 @@ DelItems = {"c": None, }; def make_hmac(str): - F = open(PassDir+"/key-hmac","r"); + F = open(PassDir+"/key-hmac-"+pwd.getpwuid(os.getuid())[0],"r"); key = F.readline().strip() F.close(); - return hmac.new(key, str, sha1_module).hexdigest + return hmac.new(key, str, sha1_module).hexdigest() @@ -485,15 +482,14 @@ def FinishConfirmSudopassword(l, uid, Attrs): res = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid="+uid, ['sudoPassword']); if len(res) != 1: raise Error, "Not exactly one hit when searching for user" - Attrs = res[0][1] - if Attrs.has_key('sudoPassword'): - inldap = Attrs['sudoPassword'] + if res[0][1].has_key('sudoPassword'): + inldap = res[0][1]['sudoPassword'] else: inldap = [] newldap = [] for entry in inldap: - Match = re.compile('^('+UUID_FORMAT+') (confirmed|unconfirmed) ([a-z0-9,*]+) ([^ ]+)$'),match(entry.lower()) + Match = re.compile('^('+UUID_FORMAT+') (confirmed|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$').match(entry.lower()) if Match == None: raise Error, "Could not parse existing sudopasswd entry" uuid = Match.group(1) @@ -517,9 +513,9 @@ def FinishConfirmSudopassword(l, uid, Attrs): newentry = " ".join([uuid, status, hosts, cryptedpass]) if len(newldap) == 0: - newldap.append((ldap.MOD_ADD,"sudoPassword",newentry)) - else: newldap.append((ldap.MOD_REPLACE,"sudoPassword",newentry)) + else: + newldap.append((ldap.MOD_ADD,"sudoPassword",newentry)) for entry in SudoPasswd: result = result + "Entry %s that you confirm is not listed in ldap."%(entry)