summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-11-28 19:49:17 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-11-28 19:49:17 -0500
commit0877f0389f187cf2cbf026c73b27071857d3e6f7 (patch)
tree6408feac822cff49dfb92bcdf227ee80ebb87212 /devel/management/commands
parent5b1ccb92255d3e2504c9814d66769de35dd0415d (diff)
parent5d22a3b891be36b74871b88cb1b125723996415e (diff)
Merge tag 'release_2013-10-27' into archweb-generic
Dependency updates and fix for key revokes
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/pgp_import.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/devel/management/commands/pgp_import.py b/devel/management/commands/pgp_import.py
index b1f29d77..faa9ff5e 100644
--- a/devel/management/commands/pgp_import.py
+++ b/devel/management/commands/pgp_import.py
@@ -176,8 +176,13 @@ def import_keys(keyring):
logger.info("created %d, updated %d keys", created_ct, updated_ct)
-SignatureData = namedtuple('SignatureData',
- ('signer', 'signee', 'created', 'expires', 'valid'))
+class SignatureData(object):
+ def __init__(self, signer, signee, created):
+ self.signer = signer
+ self.signee = signee
+ self.created = created
+ self.expires = None
+ self.revoked = None
def parse_sigdata(data):
@@ -192,21 +197,26 @@ def parse_sigdata(data):
if parts[0] == 'pub':
current_pubkey = parts[4]
nodes[current_pubkey] = None
- if parts[0] == 'uid':
+ elif parts[0] == 'uid':
uid = parts[9]
# only set uid if this is the first one encountered
if nodes[current_pubkey] is None:
nodes[current_pubkey] = uid
- if parts[0] == 'sig':
+ elif parts[0] == 'sig':
signer = parts[4]
created = get_date(parts[5])
- expires = None
+ edge = SignatureData(signer, current_pubkey, created)
if parts[6]:
- expires = get_date(parts[6])
- valid = parts[1] != '-'
- edge = SignatureData(signer, current_pubkey,
- created, expires, valid)
+ edge.expires = get_date(parts[6])
edges.append(edge)
+ elif parts[0] == 'rev':
+ signer = parts[4]
+ revoked = get_date(parts[5])
+ # revoke any prior edges that match
+ matches = [e for e in edges if e.signer == signer
+ and e.signee == current_pubkey]
+ for edge in matches:
+ edge.revoked = revoked
return nodes, edges
@@ -220,18 +230,18 @@ def import_signatures(keyring):
pruned_edges = {edge for edge in edges
if edge.signer in nodes and edge.signer != edge.signee}
- logger.info("creating or finding %d signatures", len(pruned_edges))
+ logger.info("creating or finding up to %d signatures", len(pruned_edges))
created_ct = updated_ct = 0
with transaction.commit_on_success():
for edge in pruned_edges:
sig, created = PGPSignature.objects.get_or_create(
signer=edge.signer, signee=edge.signee,
created=edge.created, expires=edge.expires,
- defaults={ 'valid': edge.valid })
- if sig.valid != edge.valid:
- sig.valid = edge.valid
+ defaults={ 'revoked': edge.revoked })
+ if sig.revoked != edge.revoked:
+ sig.revoked = edge.revoked
sig.save()
- updated_ct = 1
+ updated_ct += 1
if created:
created_ct += 1