4 import re, time, ldap, getopt, sys, pwd, os;
5 from userdir_gpg import *;
6 Output = "extrakeys.gpg";
9 AdminUser = pwd.getpwuid(os.getuid())[0];
10 (options, arguments) = getopt.getopt(sys.argv[1:], "o:")
11 for (switch, val) in options:
15 if len(arguments) == 0:
16 print "Give some keyrings to probe";
19 # Popen GPG with the correct magic special options
20 Args = [GPGPath] + GPGBasicOptions;
22 Args.append("--keyring");
27 Args.append("--fast-list-mode");
28 Args.append("--list-sigs");
29 Args = Args + GPGSearchOptions + [" 2> /dev/null"]
30 Keys = os.popen(" ".join(Args),"r");
32 # Loop over the GPG key file
35 print "Reading keys+sigs from keyring";
37 Line = Keys.readline();
41 Split = Line.split(":");
42 if len(Split) >= 8 and Split[0] == "pub":
43 HaveKeys[Split[4]] = "";
46 if len(Split) >= 5 and Split[0] == "sig":
47 NeedKeys[Split[4]] = "";
51 # Popen GPG with the correct magic special options
52 Args = [GPGPath] + GPGBasicOptions;
54 Args.append("--keyring");
60 Args = Args + GPGSearchOptions + [" 2> /dev/null"]
61 Keys = os.popen(" ".join(Args),"r");
63 print "Reading keys from output ring";
65 Line = Keys.readline();
69 Split = Line.split(":");
70 if len(Split) >= 8 and Split[0] == "pub":
71 HaveKeys[Split[4]] = "";
76 for x in NeedKeys.keys():
77 if not HaveKeys.has_key(x):
78 KeysToFetch.append("0x"+x);
80 print "Have %u keys and %u sigs, need %u keys"%(len(HaveKeys),len(NeedKeys),len(KeysToFetch));
83 Args.append("--keyserver 18.43.0.48");
84 Args.append("--recv-keys");
90 print " ".join(Args+KeysToFetch[I:OldI])
91 Fetcher = os.popen(" ".join(Args+KeysToFetch[I:OldI]),"r");
93 Line = Fetcher.readline();