PBR

pbr 1.10.0 test fails with gpg: agent_genkey failed: No such file or directory

Bug #1627102 reported by Corey Bryant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Confirmed
Medium
Unassigned
gnupg2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

I could use a hand here for some pointers. We are working on uploading python-pbr to yakkety because that's the min version needed by ceilometer. Tests are failing on yakkety with:

======================================================================
FAIL: pbr.tests.test_packaging.TestVersions.test_capitalized_headers(postversioned)
pbr.tests.test_packaging.TestVersions.test_capitalized_headers(postversioned)
----------------------------------------------------------------------
_StringException: Empty attachments:
  pythonlogging:''
  pythonlogging:'pbr'
  stderr

stdout: {{{
Initialized empty Git repository in /tmp/tmpkVtsjz/tmpeiFwqT/testpackage/.git/

gpg (GnuPG) 2.1.15
libgcrypt 1.7.2-beta
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /tmp/tmpydCYQ6/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

gpg: directory '/tmp/tmpydCYQ6/.gnupg' created
gpg: new configuration file '/tmp/tmpydCYQ6/.gnupg/dirmngr.conf' created
gpg: new configuration file '/tmp/tmpydCYQ6/.gnupg/gpg.conf' created
gpg: keybox '/tmp/tmpydCYQ6/.gnupg/pubring.kbx' created
gpg: invalid item '(setpref)' in preference string
gpg: agent_genkey failed: No such file or directory
gpg: key generation failed: No such file or directory

[master (root-commit) c51d352] test commit

Revision history for this message
Corey Bryant (corey.bryant) wrote :

This seems to be similar to: https://bugs.launchpad.net/pbr/+bug/1296200

Revision history for this message
Corey Bryant (corey.bryant) wrote :

I was able to successfully run the 1.10.0 tests on xenial. I wonder if this is due to yakkety having gnupg 2.1.15?

xenial has gnupg 1.4.20
yakkety has gnupg 2.1.15

Revision history for this message
Corey Bryant (corey.bryant) wrote :

After digging some more I think the error is specific to this line:
gpg: agent_genkey failed: No such file or directory

I'm not sure why gpg-agent would be running, but if I add the following patch, the tests run fine on yakkety with gnupg 2.1.15:

--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -81,6 +81,7 @@
         base._run_cmd(['git', 'init', '.'], self._basedir)
         base._config_git()
         base._run_cmd(['git', 'add', '.'], self._basedir)
+ base._run_cmd(['killall', 'gpg-agent'], self._basedir)

     def commit(self, message_content='test commit'):
         files = len(os.listdir(self._basedir))

Revision history for this message
Corey Bryant (corey.bryant) wrote :

gpg-agent is started automatically by gpg so it shouldn't be a problem that it is running. All the same steps seem to work fine interactively on a new yakkety instance:

$ cat /tmp/tmp/key-config
%no-protection
%transient-key
%no-ask-passphrase
Key-Type: RSA
Name-Real: Example Key
Name-Comment: N/A
Name-Email: <email address hidden>
Expire-Date: 2d
Preferences: (setpref)
%commit

$ gpg -vvv --gen-key --batch --debug-quick-random /tmp/tmp/key-config
gpg: using character set 'utf-8'
gpg: invalid item '(setpref)' in preference string
gpg: writing self signature
gpg: RSA/SHA256 signature from: "7933319B12B759E8 [?]"
gpg: writing public key to '/home/ubuntu/.gnupg/pubring.kbx'
gpg: using pgp trust model
gpg: key 1C67DDDBC2E31773: accepted as trusted key
gpg: key 337D344BB55B6C75: accepted as trusted key
gpg: key 215364B9961AB763: accepted as trusted key
gpg: key 8DF81BE76250CE68: accepted as trusted key
gpg: key 7933319B12B759E8: accepted as trusted key
gpg: key 7933319B12B759E8 marked as ultimately trusted
gpg: writing to '/home/ubuntu/.gnupg/openpgp-revocs.d/58B3E470840749DC0D34983B7933319B12B759E8.rev'
gpg: RSA/SHA256 signature from: "7933319B12B759E8 Example Key (N/A) <email address hidden>"
gpg: revocation certificate stored as '/home/ubuntu/.gnupg/openpgp-revocs.d/58B3E470840749DC0D34983B7933319B12B759E8.rev'

summary: - 1.10.0 test fails with gpg: invalid item '(setpref)' in preference
- string
+ 1.10.0 test fails with gpg: agent_genkey failed: No such file or
+ directory
Revision history for this message
Corey Bryant (corey.bryant) wrote : Re: 1.10.0 test fails with gpg: agent_genkey failed: No such file or directory

Here's an strace of the gpg call from within the pbr tests: http://paste.ubuntu.com/23233747/

I think line 406 is where the ENOENT comes from but it's hard to tell what is going on. fd=4 is an AF_LOCAL socket connected to "/run/user/1000/gnupg/S.gpg-agent":

406 read(4, "ERR 67141713 No such file or dir"..., 1002) = 50

Revision history for this message
Corey Bryant (corey.bryant) wrote :

I'm adding a patch to the python-pbr package in ubuntu to stop gpg-agent before creating the initial gpg keypair. To recreate on Ubuntu the patch would need to be dropped before running autopkgtests.

summary: - 1.10.0 test fails with gpg: agent_genkey failed: No such file or
+ pbr 1.10.0 test fails with gpg: agent_genkey failed: No such file or
directory
Revision history for this message
Ben Nemec (bnemec) wrote :

1.10.0 is pretty old now. Is this still a problem on a newer version of pbr? Thanks.

Changed in pbr:
status: New → Incomplete
Revision history for this message
Corey Bryant (corey.bryant) wrote :

This appears to no longer be an issue for us in queens.

Revision history for this message
Sorin Sbarnea (ssbarnea) wrote :

I can reproduce the same bug while trying to run the test suite on Fedora 33, so is not really fixed.

Revision history for this message
Sorin Sbarnea (ssbarnea) wrote :

Running gpg --gen-key --batch --debug-quick-random /tmp/tmpgmkfjy7d/tmptqv2nhlf/key-config
STDOUT:

STDERR:
gpg: directory '/tmp/tmpc13owdnd/.gnupg' created
gpg: keybox '/tmp/tmpc13owdnd/.gnupg/pubring.kbx' created
gpg: invalid item '(setpref)' in preference string
gpg: agent_genkey failed: No such file or directory
gpg: key generation failed: No such file or directory
Running git add /tmp/tmpgmkfjy7d/tmpvj5jmu2m/testpackage/14
STDOUT:

Changed in pbr:
status: Incomplete → Confirmed
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.