[Collab-qa-commits] r1308 - upload-history

filippo at alioth.debian.org filippo at alioth.debian.org
Sun Sep 28 15:07:31 UTC 2008


Author: filippo
Date: 2008-09-28 15:07:29 +0000 (Sun, 28 Sep 2008)
New Revision: 1308

Modified:
   upload-history/munge_ddc.py
Log:
parse expired/revoked keys

Modified: upload-history/munge_ddc.py
===================================================================
--- upload-history/munge_ddc.py	2008-09-28 12:37:36 UTC (rev 1307)
+++ upload-history/munge_ddc.py	2008-09-28 15:07:29 UTC (rev 1308)
@@ -23,7 +23,7 @@
 nmu_changelog_RE = re.compile("\s+\*\s+.*(NMU|non[- ]maintainer)", re.IGNORECASE + re.MULTILINE)
 
 #keyid_RE = re.compile("Signature made (.+) using \S+ key ID (\S+)")
-keyid_RE = re.compile("\[GNUPG:\] (GOOD|BAD|ERR)SIG (\S+) (.+)")
+keyid_RE = re.compile("\[GNUPG:\] ([A-Z]+)SIG (\S+) (.+)")
 
 bugnumber_list_RE = re.compile("^([0-9]{3,} ?)+")
 
@@ -36,8 +36,11 @@
     
     Return a tuple (key, key-id) or ("N/A", "N/A") if key not available"""
 
-    cmd = ["/usr/bin/gpgv", "--status-fd", "1"]
+    cmd = ["/usr/bin/gpgv", "--status-fd", "1"] 
 
+    if os.environ.has_key("KEYRING"):
+        keyring = os.environ["KEYRING"].split(":")
+
     opt_keyrings = []
     if isinstance(keyring, str):
         if os.path.exists(keyring):
@@ -50,8 +53,7 @@
     if opt_keyrings:
         cmd.extend(opt_keyrings)
     else:
-        # XXX raise exception?
-        return ("N/A", "N/A")
+        raise ValueError, "no keyring found"
 
     p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
             stdout=subprocess.PIPE, env={"LC_ALL": "C"} )
@@ -60,13 +62,16 @@
    
     m = keyid_RE.search(out)
     if m:
-        #sys.stderr.write(m.group(2))
-        if m.group(1) == "GOOD":
+        # see /usr/share/doc/gnupg/DETAILS.gz
+        # fields with <longuid> <username> format 
+        if m.group(1) in ("GOOD", "EXP", "EXPKEY", "REVKEY", "BAD"):
             return (m.group(2), m.group(3))
-        else:
+        # ERRSIG  <long keyid>  <pubkey_algo> <hash_algo> <sig_class> <timestamp> <rc>
+        elif m.group(1) == "ERR":
             return (m.group(2), "N/A")
     else:
-        return ("N/A", "N/A")
+        raise ValueError, out
+        #return ("N/A", "N/A")
 
 get_key_info = get_key_info_gpgv
 




More information about the Collab-qa-commits mailing list