aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-10-16 14:46:44 -0700
committerZac Medico <zmedico@gentoo.org>2012-10-16 14:46:44 -0700
commitd40c242a4c9a9b666fd8730734b149bce2dd7cd9 (patch)
tree363e5c610cc3f2ecaca0da1eb28df02426c5a90a
parentTest PopenProcess. (diff)
downloadportage-d40c242a4c9a9b666fd8730734b149bce2dd7cd9.tar.gz
portage-d40c242a4c9a9b666fd8730734b149bce2dd7cd9.tar.bz2
portage-d40c242a4c9a9b666fd8730734b149bce2dd7cd9.zip
repoman: validate PORTAGE_GPG_KEY
-rwxr-xr-xbin/repoman9
1 files changed, 9 insertions, 0 deletions
diff --git a/bin/repoman b/bin/repoman
index d1f0b861a..c59791c76 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -88,6 +88,7 @@ util.initialize_logger()
max_desc_len = 100
allowed_filename_chars="a-zA-Z0-9._-+:"
pv_toolong_re = re.compile(r'[0-9]{19,}')
+GPG_KEY_ID_REGEX = r'(0x)?([0-9a-fA-F]{8}|[0-9a-fA-F]{16}|[0-9a-fA-F]{24}|[0-9a-fA-F]{32})!?'
bad = create_color_func("BAD")
# A sane umask is needed for files that portage creates.
@@ -605,6 +606,14 @@ if repo_config.sign_commit:
sign_manifests = "sign" in repoman_settings.features and \
repo_config.sign_manifest
+if sign_manifests and options.mode in ("commit",) and \
+ repoman_settings.get("PORTAGE_GPG_KEY") and \
+ re.match(r'^%s$' % GPG_KEY_ID_REGEX,
+ repoman_settings["PORTAGE_GPG_KEY"]) is None:
+ logging.error("PORTAGE_GPG_KEY value is invalid: %s" %
+ repoman_settings["PORTAGE_GPG_KEY"])
+ sys.exit(1)
+
manifest_hashes = repo_config.manifest_hashes
if manifest_hashes is None:
manifest_hashes = portage.const.MANIFEST2_HASH_DEFAULTS