X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-mailgate;h=32985d1c2c5f6a78714798e80a58395cd7b2f0c6;hb=f60516f70fc0e00488de904c44b86428706f39f4;hp=5ec68d28906fd6f56588917d6e01193592abecfa;hpb=ab793ab26e05839fe37ea186f058d4fd7c290293;p=mirror%2Fuserdir-ldap.git diff --git a/ud-mailgate b/ud-mailgate index 5ec68d2..32985d1 100755 --- a/ud-mailgate +++ b/ud-mailgate @@ -189,10 +189,11 @@ def DoArbChange(Str, Attrs): if i.lower() == attrName: attrName = i break - if attrName in ArbChanges: + if attrName not in ArbChanges: return None - if re.match(ArbChanges[attrName], G[1]) is None: + value = G[1] + if re.match(ArbChanges[attrName], value) is None: raise UDFormatError("Item does not match the required format" + ArbChanges[attrName]) Attrs.append((ldap.MOD_REPLACE, attrName, value)) @@ -484,7 +485,7 @@ def DoConfirmSudopassword(Str, SudoPasswd): return "got confirm for sudo password %s on host(s) %s, auth code %s" % (uuid, hosts, hmac) -def FinishConfirmSudopassword(l, uid, Attrs, SudoPasswd): +def FinishConfirmSudopassword(lc, uid, Attrs, SudoPasswd): result = "\n" if len(SudoPasswd) == 0: @@ -493,7 +494,7 @@ def FinishConfirmSudopassword(l, uid, Attrs, SudoPasswd): res = lc.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "uid=" + uid, ['sudoPassword']) if len(res) != 1: raise UDFormatError("Not exactly one hit when searching for user") - if sudoPassword in res[0][1]: + if 'sudoPassword' in res[0][1]: inldap = res[0][1]['sudoPassword'] else: inldap = [] @@ -599,7 +600,7 @@ def HandleChange(Reply, DnRecord, Key): if CommitChanges == 1 and len(SudoPasswd) > 0: # only if we are still good to go try: - Res = FinishConfirmSudopassword(l, GetAttr(DnRecord, "uid"), Attrs, SudoPasswd) + Res = FinishConfirmSudopassword(lc, GetAttr(DnRecord, "uid"), Attrs, SudoPasswd) if Res is not None: Result += Res + "\n" except Error, e: