X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=ud-echelon;h=36329807b5f882da88be8843cc50d0b0bd3ef3a4;hp=0487d9432c7019559776f3c4236b91ed3539929d;hb=a6fb69805c3999a85c064a96c93417bb1c284c5c;hpb=37b0b5875ff83d8e9a9e8ca918d42fc32b720f06 diff --git a/ud-echelon b/ud-echelon index 0487d94..3632980 100755 --- a/ud-echelon +++ b/ud-echelon @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- mode: python -*- -import userdir_gpg, userdir_ldap, sys, traceback, time, ldap, posix, getopt; -import string, pwd +import userdir_gpg, userdir_ldap, sys, traceback, time, ldap, os, getopt; +import pwd from userdir_gpg import *; from userdir_ldap import *; @@ -12,10 +12,19 @@ Debug = None; # Try to extract a key fingerprint from a PGP siged message def TryGPG(Email): # Try to get a pgp text - Msg = GetClearSig(Email); - if string.find(Msg[0],"-----BEGIN PGP SIGNED MESSAGE-----") == -1: + try: + Msg = GetClearSig(Email); + except: + # Log an exception.. but continue. This is to deal with 'sort of' + # PGP-MIME things + S = "%s: %s -> %s\n" %(Now,MsgID,ErrMsg); + S = S + " %s: %s\n" %(sys.exc_type,sys.exc_value); + ErrLog.write(S); return None; - + + if Msg[0].find("-----BEGIN PGP SIGNED MESSAGE-----") == -1: + return None; + Res = GPGCheckSig(Msg[0]); # Failed to find a matching sig @@ -25,7 +34,7 @@ def TryGPG(Email): return None; # Search for the matching key fingerprint - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"keyfingerprint=" + Res[2][1]); + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"keyFingerPrint=" + Res[2][1]); if len(Attrs) == 0: return None; if len(Attrs) != 1: @@ -87,8 +96,8 @@ try: global l; l = ldap.open(LDAPServer); if Debug == None: - F = open(PassDir+"/pass-"+pwd.getpwuid(posix.getuid())[0],"r"); - AccessPass = string.split(string.strip(F.readline())," "); + F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r"); + AccessPass = F.readline().strip().split(" ") l.simple_bind_s("uid="+AccessPass[0]+","+BaseDn,AccessPass[1]); F.close(); else: