Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 519760

Summary: app-crypt/gnupg-2.0.25 - Fatal error/non-zero exit code returned when --trust-model=always used
Product: Gentoo Linux Reporter: James Hogan <james>
Component: Current packagesAssignee: Crypto team [DISABLED] <crypto+disabled>
Status: RESOLVED FIXED    
Severity: normal CC: james
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
See Also: http://bugs.debian.org/735363
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Fix patch from debian bug report

Description James Hogan 2014-08-12 22:06:11 UTC
Attempting to use caff (from app-crypt/signing-party-1.1.4) to sign a GPG key I came accross a problem. It would always indefinitely print this after signing:

Could not import <the_key> into temporary gnupg.

Enabling debug and tracing in caff shows the following message:

[trace2] stderr is now gpg: keyring `/tmp/caff-<the_key>-N3eRx/secring.gpg' created
gpg: keyring `/tmp/caff-<the_key>-N3eRx/pubring.gpg' created
gpg: Fatal: can't open `/tmp/caff-<the_key>-N3eRx/trustdb.gpg': No such file or directory

Googling for that I found the debian bug I linked to and can confirm that the same gnupg command fails in the same way, and looking at an strace of caff it's doing something similar (using the all important --trust-model=always to make it happen):

[pid  9714] execve("/usr/bin/gpg", ["gpg", "--batch", "--no-tty", "--homedir", "/tmp/caff-<the_key>-ejET7", "--status-fd", "5", "--no-auto-check-trustdb", "--trust-model=always", "--import"], [/* 64 vars */]) = 0

Reproducible: Always

Steps to Reproduce:
Using caff, having configured it:
1. caff <some key>
2. follow instructions to sign key
3. observe infinite loop of messages and accumulation of /tmp/ directories

Or using gpg directly:
1. gpg --export <some_key> > some_key.gpg
2. mkdir /tmp/caff-test-ejET7
3. gpg --homedir /tmp/caff-test-ejET7 --trust-model=always --import < some_key.pgp
4. observe error message about inability to open trustdb.gpg and non-zero exit code

It only happens once. rm -fr /tmp/caff-test-ejET7 to reproduce again.

If you don't have a key to import, it also happens with --gen-key as pointed out on the debian bug report, but that takes longer as it has to gather enough entropy to generate the key.
Actual Results:  
gpg: Fatal: can't open `/tmp/caff-<the_key>-N3eRx/trustdb.gpg': No such file or directory

non-zero exit code

Expected Results:  
gnupg should just create the missing trustdb.gpg and continue. That's what the debian report seems to imply anyway.

$ emerge --info
!!! Repository 'gbin' is missing masters attribute in '/var/lib/layman/gbin/metadata/layout.conf'
!!! Set 'masters = gentoo' in this file for future compatibility
Portage 2.2.8-r1 (default/linux/amd64/13.0/desktop/kde/systemd, gcc-4.7.3, glibc-2.19-r1, 3.15.6+ x86_64)
=================================================================
System uname: Linux-3.15.6+-x86_64-Intel-R-_Core-TM-_i7-3537U_CPU_@_2.00GHz-with-gentoo-2.2
KiB Mem:     7717936 total,    640064 free
KiB Swap:   15728636 total,  14889300 free
Timestamp of tree: Tue, 12 Aug 2014 20:00:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
ccache version 3.1.9 [disabled]
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.7, 3.3.5-r1
dev-util/ccache:          3.1.9-r3
dev-util/cmake:           2.8.12.2-r1
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.19-r1
Repositories: gentoo steam-overlay dotnet gbin
Installed sets: @steam
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://mirror.bytemark.co.uk/gentoo/ http://mirror.bytemark.co.uk/gentoo/ http://mirror.qubenet.net/mirror/gentoo/ http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/"
LANG="en_GB.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/steam /var/lib/layman/dotnet /var/lib/layman/gbin"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 berkdb bindist bluetooth branding bzip2 cairo cdda cdr cli cracklib crypt cups cxx dbus declarative dia dri dts dvd dvdr emboss encode exif fam firefox flac fluidsynth fortran gdbm gif gpm gtk iconv imap ipv6 jpeg kde kipi lcms ldap libnotify mad mmx mng modules mp3 mp4 mpeg multilib multitarget ncurses networkmanager nls nptl ogg openconnect opengl openmp pam pango pcre pdf phonon plasma png policykit ppds qt3support qt4 readline sdl semantic-desktop session spell sse sse2 ssl startup-notification subversion svg systemd tcpd theora tiff truetype udev udisks unicode upnp upower usb v4l vaapi vim-syntax vorbis wxwidgets x264 xcb xcomposite xinerama xml xscreensaver xv xvid zeroconf zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_GB" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 James Hogan 2014-08-12 22:44:55 UTC
Created attachment 382788 [details, diff]
Fix patch from debian bug report

Adding this patch to /etc/portage/pages/app-crypt/gnupg/ and re-emerging gnupg made it work for me.

It is from the debian bug report.
Comment 2 Kristian Fiskerstrand (RETIRED) gentoo-dev 2014-08-13 14:26:19 UTC
Thanks. I recall this issue, indeed, and it has been fixed already in 1.4. Try 2.0.26 in ~arch that includes similar patch taken from the upstream git repo. 

+  13 Aug 2014; Kristian Fiskerstrand <k_f@gentoo.org>
+  +files/gnupg-2.0.26-Need-to-init-the-trustdb-for-import.patch,
+  +gnupg-2.0.26.ebuild:
+  Version bump to 2.0.26. Add patch to fix an import issue for trust-
+  model=always (bug #519760)

This patch is also submitted to gnupg-devel ( http://lists.gnupg.org/pipermail/gnupg-devel/2014-August/028659.html )