launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30387
[Merge] ~ines-almeida/launchpad:fix-gpg-generateKey into launchpad:master
Ines Almeida has proposed merging ~ines-almeida/launchpad:fix-gpg-generateKey into launchpad:master.
Commit message:
Fix signing key generation used in non-prod environments
In production, we use a diferent key generation handler enabled by a feature flag ("archivepublisher.gpg.signing_service.enabled").
For non-prod environments, this handler is still used and seems to currently fail with a generic gpgme.GpgmeError. This patch fixes this error.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/448909
This was tested locally - the error was raised when trying to generate keys both xenial and focal, and was fixed with this patch
We don't seem to have unit tests that would catch this failure specifically (we use a mock for the actual bit that fails), but also this doesn't run on production since 2020
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:fix-gpg-generateKey into launchpad:master.
diff --git a/lib/lp/services/gpg/handler.py b/lib/lp/services/gpg/handler.py
index bfd0393..912474f 100644
--- a/lib/lp/services/gpg/handler.py
+++ b/lib/lp/services/gpg/handler.py
@@ -332,6 +332,11 @@ class GPGHandler:
if "GPG_AGENT_INFO" in os.environ:
del os.environ["GPG_AGENT_INFO"]
+ def passphrase_cb(uid_hint, passphrase_info, prev_was_bad, fd):
+ os.write(fd, b"\n")
+
+ context.passphrase_cb = passphrase_cb
+
# Only 'utf-8' encoding is supported by gpgme.
# See more information at:
# http://pyme.sourceforge.net/doc/gpgme/Generating-Keys.html