X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=ud-emailmatcher;h=4d42d7782de1bb8b0e6ca4e163a35d58519f8910;hp=daf76cd88143e5d06c9659a0bbccd0043a442a8c;hb=HEAD;hpb=c50d88536a4feb3087d1aa802e110250cb2861fc diff --git a/ud-emailmatcher b/ud-emailmatcher index daf76cd..4d42d77 100755 --- a/ud-emailmatcher +++ b/ud-emailmatcher @@ -3,7 +3,7 @@ # This script tries to match a list of email addresses to the ldap database # uids. It makes use of the PGP key ring to determine matches -import string, re, time, ldap, getopt, sys; +import re, time, ldap, getopt, sys; from userdir_ldap import *; from userdir_gpg import *; @@ -13,14 +13,14 @@ AddressSplit = re.compile("(.*).*<([^@]*)@([^>]*)>"); def ImportForward(File,EmailMap): F = open(File,"r"); while(1): - Line = string.strip(F.readline()); + Line = F.readline().strip() if Line == "": break; - Split = string.split(Line,":"); + Split = Line.split(":") if len(Split) != 2: continue; - Addr = string.strip(Split[1]); + Addr = Split[1].strip() if EmailMap.has_key(Addr) and EmailMap[Addr] != Split[0]: print "Dup Over Emap",Line,Split else: @@ -34,12 +34,12 @@ def ImportOverride(File,OverMap): Line = F.readline(); if Line == "": break; - Line = string.strip(Line); + Line = Line.strip() - Split = string.split(Line,":"); + Split = Line.split(":") if len(Split) != 2: continue; - OverMap[Split[0]] = string.strip(Split[1]); + OverMap[Split[0]] = Split[1].strip() F.close(); (options, arguments) = getopt.getopt(sys.argv[1:], "o:f:") @@ -50,10 +50,9 @@ for x in arguments: Args.append("--keyring"); Args.append(x); Args = Args + GPGSearchOptions + [" 2> /dev/null"] -Keys = os.popen(string.join(Args," "),"r"); +Keys = os.popen(" ".join(Args),"r") -l = ldap.open(LDAPServer); -l.simple_bind_s("",""); +l = connectLDAP() # Fetch the key list and map to email address PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"keyfingerprint=*",\ @@ -80,7 +79,7 @@ while(1): if Line == "": break; - Split = string.split(Line,":"); + Split = Line.split(":") if len(Split) >= 8 and Split[0] == "pub": if FingerPrint != None and UID != None: for x in Emails: @@ -124,9 +123,9 @@ while(1): Line = sys.stdin.readline(); if Line == "": break; - Line = string.strip(Line); + Line = Line.strip() - Split = string.split(Line,"@"); + Split = Line.split("@") if len(Split) != 2: continue; @@ -134,7 +133,7 @@ while(1): if Split[1] == EmailAppend: if FinalMap.has_key(Line): print "Dup",Line - Split2 = string.split(Split[0],"-"); + Split2 = Split[0].split("-") FinalMap[Line] = Split2[0]; continue; @@ -146,7 +145,7 @@ while(1): continue; # Try again splitting off common address appendage modes - Split2 = string.split(Split[0],"-"); + Split2 = Split[0].split("-") Addr = Split2[0]+'@'+Split[1]; if EmailMap.has_key(Addr): if FinalMap.has_key(Addr):