Page MenuHome GnuPG

gpg does not honor $TMPDIR nor use /tmp when checking trustdb
Closed, ResolvedPublic

Description

Environment

i386, Linux 2.6.12.3, Debian unstable, self-compiled gnupg 1.4.1, ...

Description

command "gpg --check-trustdb" fails to check the trustdb if user has no write permission on the directory the keyring lives in:

$ TMPDIR=/tmp gpg --check-trustdb

[...]

gpg: can't create `/usr/share/keyrings/debian-keyring.gpg.tmp': Permission denied
gpg: failed to rebuild keyring cache: file open error
gpg: can't create `/usr/share/keyrings/debian-keyring.pgp.tmp': Permission denied
gpg: failed to rebuild keyring cache: file open error

[...]

How To Repeat

place keyring in directory without user write permissions:

gpg --check-trustdb

Fix

honor $TMPDIR if set, otherwise use /tmp

Event Timeline

werner added a subscriber: werner.

This is not a bug. We can't use the tmpdir for reasons of atomicity. The
temporary file is renamed to the old file and this won't work if /tmp or
whatever is on another file system.