public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_parallel_manifest/
Date: Wed, 17 Oct 2012 02:01:49 +0000 (UTC)	[thread overview]
Message-ID: <1350439295.8a28c000ce225b79076e36f212162f58e01188b7.zmedico@gentoo> (raw)

commit:     8a28c000ce225b79076e36f212162f58e01188b7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 17 02:01:35 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 17 02:01:35 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8a28c000

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.

---
 .../ebuild/_parallel_manifest/ManifestTask.py      |   17 ++++++++++-------
 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):


             reply	other threads:[~2012-10-17  2:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17  2:01 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-01-08  1:48 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_parallel_manifest/ Zac Medico
2013-01-06 11:06 Zac Medico
2012-10-18  6:37 Zac Medico
2012-10-18  1:43 Zac Medico
2012-10-18  1:24 Zac Medico
2012-10-16 22:45 Zac Medico
2012-10-06 17:26 Zac Medico
2012-10-03 23:32 Zac Medico
2012-10-03 20:21 Zac Medico
2012-10-03 20:16 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350439295.8a28c000ce225b79076e36f212162f58e01188b7.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox