X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-gpgimport;h=103f472b008d0019b7223868a4862c5909535398;hb=refs%2Fheads%2Fsalsa;hp=b8c998752f111162e0a48aee7b5fcd87b8ac898e;hpb=ff3b878da940bd8871ff8312722e40f3d7fa8543;p=mirror%2Fuserdir-ldap.git diff --git a/ud-gpgimport b/ud-gpgimport index b8c9987..103f472 100755 --- a/ud-gpgimport +++ b/ud-gpgimport @@ -4,6 +4,7 @@ # Copyright (c) 1999-2000 Jason Gunthorpe # Copyright (c) 2004 Joey Schulze # Copyright (c) 2008, 2009, 2010 Peter Palfrader +# Copyright (c) 2010 Martin Zobel-Helas # # 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 @@ -94,8 +95,8 @@ def load_keys_from_gpg(keyrings): continue keys[fingerprint] = pgp_uid - if Keys.close() != None: - raise "Error","GPG failed" + if Keys.close() is not None: + raise Exception("GPG failed") return keys @@ -106,12 +107,20 @@ def load_keys_from_gpg(keyrings): # Process options AdminUser = pwd.getpwuid(os.getuid())[0]; -(options, arguments) = getopt.getopt(sys.argv[1:], "au:m:n") +(options, arguments) = getopt.getopt(sys.argv[1:], "ahu:m:") for (switch, val) in options: if (switch == '-u'): AdminUser = val elif (switch == '-m'): LoadOverride(val); + elif (switch == '-h'): + print "Usage: ud-gpgimport " + print "Available options:" + print " -h Show this help" + print " -u= Admin user (defaults to current username)" + print " -m= Override file to use" + print " -a actually do changes, not dry-run" + sys.exit(0) elif (switch == '-a'): NoAct = 0; @@ -168,9 +177,9 @@ for fpr in pgpkeys: continue; UID = GetUID(l,SplitEmail(pgp_uid),UnknownMap); - if UID[0] == None: + if UID[0] is None: print "Unassigned key in keyrings: %s, belonging to %s"%(fpr, pgp_uid) - if UID[1] != None: + if UID[1] is not None: for x in UID[1]: print x; print "MISSING " + fpr; continue; @@ -200,7 +209,7 @@ print Ignored,"keys already in the directory (ignored)"; # Look for unmatched keys for x in KeyMap.keys(): - if KeyMap[x][1] == 0 and not x in pgpkeys_extra: + if KeyMap[x][1] == 0 and x not in pgpkeys_extra: 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