summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico2012-10-17 02:01:35 (GMT)
committerZac Medico2012-10-17 02:01:35 (GMT)
commit8a28c000ce225b79076e36f212162f58e01188b7 (patch)
treec567b2ce4105cea5e9c1d3be6f13819c93a25f20
parentf1e4d32191ad46460043f1fa83ca447c657678e2 (diff)
ManifestTask: improve gpg key parsing
This fixes it to correctly parse longer key IDs, which do not fit on the first line of gpg output. Without this fix, failure to parse the key results in manifest being re-signed even though they already have a signature with the correct key.
-rw-r--r--pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py
index bfa7bd7..d51400a 100644
--- a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py
+++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py
@@ -23,6 +23,8 @@ class ManifestTask(CompositeTask):
_PGP_HEADER = b"BEGIN PGP SIGNED MESSAGE"
_manifest_line_re = re.compile(r'^(%s) ' % "|".join(MANIFEST2_IDENTIFIERS))
+ _gpg_key_id_re = re.compile(r'^[0-9A-F]*$')
+ _gpg_key_id_lengths = (8, 16, 24, 32, 40)
def _start(self):
self._manifest_path = os.path.join(self.repo_config.location,
@@ -70,14 +72,15 @@ class ManifestTask(CompositeTask):
@staticmethod
def _parse_gpg_key(output):
"""
- Returns the last token of the first line, or None if there
- is no such token.
+ Returns the first token which appears to represent a gpg key
+ id, or None if there is no such token.
"""
- output = output.splitlines()
- if output:
- output = output[0].split()
- if output:
- return output[-1]
+ regex = ManifestTask._gpg_key_id_re
+ lengths = ManifestTask._gpg_key_id_lengths
+ for token in output.split():
+ m = regex.match(token)
+ if m is not None and len(m.group(0)) in lengths:
+ return m.group(0)
return None
def _check_sig_key_exit(self, proc):