X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-gpgimport;h=866563c7131db9a6983549467bf241afc70ff17d;hb=fb74d49d4f338f293cea186f4d60a066c9b6f354;hp=797aa5d0d2c8cdd2ec078ae4a5a500524dcca429;hpb=a6fb69805c3999a85c064a96c93417bb1c284c5c;p=mirror%2Fuserdir-ldap.git diff --git a/ud-gpgimport b/ud-gpgimport index 797aa5d..866563c 100755 --- a/ud-gpgimport +++ b/ud-gpgimport @@ -3,6 +3,7 @@ # Copyright (c) 1999-2000 Jason Gunthorpe # Copyright (c) 2004 Joey Schulze +# Copyright (c) 2008, 2009, 2010 Peter Palfrader # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -62,17 +63,15 @@ for (switch, val) in options: LoadOverride(val); elif (switch == '-a'): NoAct = 0; -if len(arguments) == 0: - print "Give some keyrings to probe"; - sys.exit(0); + # Main program starts here # Connect to the ldap server if NoAct == 0: - l = passwdAccessLDAP(LDAPServer, BaseDn, AdminUser) + l = passwdAccessLDAP(BaseDn, AdminUser) else: - l = ldap.open(LDAPServer); + l = connectLDAP() l.simple_bind_s("",""); # Download the existing key list and put it into a map @@ -105,14 +104,16 @@ Attrs = None; print; # Popen GPG with the correct magic special options -Args = [GPGPath] + GPGBasicOptions; +ClearKeyrings() +if len(arguments) == 0: + print "Using default keyrings: %s"%ConfModule.add_keyrings; + SetKeyrings(ConfModule.add_keyrings.split(":")) for x in arguments: - Args.append("--keyring"); if x.find("/") == -1: - Args.append("./"+x); - else: - Args.append(x); -Args = Args + GPGSearchOptions + [" 2> /dev/null"] + x= "./"+x + SetKeyrings( [x] ) + +Args = [GPGPath] + GPGBasicOptions + GPGKeyRings + GPGSearchOptions + [" 2> /dev/null"] Keys = os.popen(" ".join(Args),"r"); # Loop over the GPG key file @@ -140,7 +141,7 @@ while(1): break; if SeenKeys.has_key(Split2[9]): - print "Dup key 0x",Split2[9],"belonging to",KeyMap[Split2[9]][0]; + print "Dup key ",Split2[9],"belonging to",KeyMap[Split2[9]][0]; continue; SeenKeys[Split2[9]] = None; @@ -155,13 +156,13 @@ while(1): print "None for",SplitEmail(Split[9]),"'%s'"%(Split[9]); if UID[1] != None: for x in UID[1]: print x; - print "MISSING 0x" + Split2[9]; + print "MISSING " + Split2[9]; continue; UID = UID[0] Rec = [(ldap.MOD_ADD,"keyFingerPrint",Split2[9])]; Dn = "uid=" + UID + "," + BaseDn; - print "Adding key 0x"+Split2[9],"to",UID; + print "Adding key "+Split2[9],"to",UID; if KeyCount.has_key(UID): KeyCount[UID] = KeyCount[UID] + 1; else: @@ -187,7 +188,7 @@ print Ignored,"keys already in the directory (ignored)"; # Look for unmatched keys for x in KeyMap.keys(): if KeyMap[x][1] == 0: - print "key 0x%s belonging to %s removed"%(x,KeyMap[x][0]); + print "key %s belonging to %s removed"%(x,KeyMap[x][0]); if KeyCount.has_key(KeyMap[x][0]) : KeyCount[KeyMap[x][0]] = KeyCount[KeyMap[x][0]] - 1 if KeyCount[KeyMap[x][0]] <= 0: