gpg --list-config should be able to run when $HOME is not writeable (or does not exist)

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 1 00:19:18 CEST 2016


Hi GnuPG folks--

some gnupg commands (like --list-config) seem to want to do a lot more
than they need to with the filesystem.  They report errors when the
gnupg homedir is not writeable, and they fail outright when $HOME is not
writeable (or does not exist).  but "gpg --version" works fine in those
situations:


0 dkg at alice:~$ HOME=/does-not-exist gpg --version
gpg (GnuPG) 2.1.15
libgcrypt 1.7.3-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: /does-not-exist/.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
0 dkg at alice:~$ GNUPGHOME=/does-not-exist gpg --with-colons --list-config version 
gpg: keyblock resource '/does-not-exist/pubring.kbx': No such file or directory
cfg:version:2.1.15
2 dkg at alice:~$ HOME=/does-not-exist gpg --with-colons --list-config version
gpg: Fatal: can't create directory '/does-not-exist/.gnupg': No such file or directory
2 dkg at alice:~$ 


Note that when $GNUPGHOME does not exist, the return code is non-zero but
the answer is emitted.  But when $HOME does not exist, the answer isn't
even produced!

We recently had a problem where GnuPG failed to build on the debian
autobuilders because the test suite tried (and failed) to create
$HOME/.gnupg during a test because of this.

The attached patch fixes the test suite when $HOME does not exist, but
it seems to me like the right fix is for gpg to not try to access
these directories at all when it doesn't need to do so.

      --dkg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-avoid-test-suite-failures-when-HOME-is-non-existent.patch
Type: text/x-diff
Size: 1219 bytes
Desc: not available
URL: </pipermail/attachments/20160831/34ceb8aa/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 930 bytes
Desc: not available
URL: </pipermail/attachments/20160831/34ceb8aa/attachment.sig>


More information about the Gnupg-devel mailing list