Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added key import debug logging to reposync #7427

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion python/spacewalk/satellite_tools/repo_plugins/yum_src.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ def __synchronize_gpg_keys(self):
line_l = line.decode().split(":")
if line_l[0] == "sig" and "selfsig" in line_l[10]:
spacewalk_gpg_keys.setdefault(line_l[4][8:].lower(), []).append(format(int(line_l[5]), 'x'))
log(3, "spacewalk keyIds: {}".format([k for k in sorted(spacewalk_gpg_keys)]))

# Collect GPG keys from reposync Zypper RPM database
process = subprocess.Popen(['rpm', '-q', 'gpg-pubkey', '--dbpath', REPOSYNC_ZYPPER_RPMDB_PATH], stdout=subprocess.PIPE)
for line in process.stdout.readlines():
match = RPM_PUBKEY_VERSION_RELEASE_RE.match(line.decode())
if match:
zypper_gpg_keys[match.groups()[0]] = match.groups()[1]
log(3, "zypper keyIds: {}".format([k for k in sorted(zypper_gpg_keys)]))

# Compare GPG keys and remove keys from reposync that are going to be imported with a newer release.
for key in zypper_gpg_keys:
Expand All @@ -151,12 +153,25 @@ def __synchronize_gpg_keys(self):
# This GPG key has a newer release on the Spacewalk GPG keyring that on the reposync Zypper RPM database.
# We delete this key from the RPM database to allow importing the newer version.
os.system("rpm --dbpath {} -e gpg-pubkey-{}-{}".format(REPOSYNC_ZYPPER_RPMDB_PATH, key, zypper_gpg_keys[key]))
log(3, "new version available for gpg-pubkey-{}-{}".format(key, zypper_gpg_keys[key]))

# Finally, once we deleted the existing old key releases from the Zypper RPM database
# we proceed to import all keys from the Spacewalk GPG keyring. This will allow new GPG
# keys release are upgraded in the Zypper keyring since rpmkeys does not handle the upgrade
# properly
os.system("rpmkeys --dbpath {} --import {}".format(REPOSYNC_ZYPPER_RPMDB_PATH, f.name))
log(3, "rpmkeys -vv --dbpath {} --import {}".format(REPOSYNC_ZYPPER_RPMDB_PATH, f.name))
process = subprocess.Popen(["rpmkeys", "-vv", "--dbpath", REPOSYNC_ZYPPER_RPMDB_PATH, "--import", f.name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
try:
outs, errs = process.communicate(timeout=15)
if process.returncode is None or process.returncode > 0:
log(0, "Failed to import keys into rpm database ({}): {}".format(process.returncode, outs.decode('utf-8')))
else:
log(3, "CMD out: {}".format(outs.decode('utf-8')))
except TimeoutExpired:
process.kill()
log(0, "Timeout exceeded while importing keys to rpm database")
keycont = f.read()
rhnLog.log_clean(5, keycont.decode('utf-8'))


class ZypperRepo:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added key import debug logging to reposync (bsc#1213675)