[PINENTRY PATCH] tty: Declare dummy curses_cmd_handler.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Nov 6 04:26:35 CET 2016


* tty/pinentry-tty.c: Declare a dummy handler for the
curses_cmd_handler for fallback.

--

This is needed for building pinentry-tty, which links to a copy of the
pinentry object which doesn't have curses (it makes no sense to
fallback from tty to curses).  But the new cmd_info in
pinentry/pinentry.c needs some sort of value to test against when
reporting the flavor.

You can replicate this linker error from git with:

     ./autogen.sh
     ./configure --enable-maintainer-mode \
       --enable-{fallback-curses,pinentry-tty} \
       --disable-{inside-emacs,libsecret} && make

Which produces:

    gcc  -g -O2 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wformat -Wno-format-y2k -Wformat-security -W -Wno-sign-compare -Wno-missing-field-initializers -Wdeclaration-after-statement -Wno-pointer-sign -Wpointer-arith   -o pinentry-tty pinentry-tty.o ../pinentry/libpinentry.a ../secmem/libsecmem.a -lassuan -L/usr/lib/x86_64-linux-gnu -lgpg-error -L/usr/lib/x86_64-linux-gnu -lgpg-error  -lcap
    ../pinentry/libpinentry.a(pinentry.o): In function `cmd_getinfo':
    «BUILDDIR»/pinentry/pinentry.c:1457: undefined reference to `curses_cmd_handler'
    collect2: error: ld returned 1 exit status
    Makefile:410: recipe for target 'pinentry-tty' failed
    make[2]: *** [pinentry-tty] Error 1
    make[2]: Leaving directory '«BUILDDIR»/tty'

One could argue that developers who --enable-tty then must also
--disable-fallback-curses, but that would just mean that it's
impossible to't build one of the graphical pinentries at the same time
(with curses fallback) as you are actually building pinentry-tty.
Arguably, though, the ./configure script should figure out the right
thing to do in this case and the build each variant sensibly.

This patch is a hack to ensure that pinentry-tty continues to link
properly even when other pinentries are being built concurrently with
a curses fallback.

Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
 tty/pinentry-tty.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tty/pinentry-tty.c b/tty/pinentry-tty.c
index bd82fad..3d6cd5a 100644
--- a/tty/pinentry-tty.c
+++ b/tty/pinentry-tty.c
@@ -556,6 +556,10 @@ tty_cmd_handler(pinentry_t pinentry)
 
 pinentry_cmd_handler_t pinentry_cmd_handler = tty_cmd_handler;
 
+/* needed to link cleanly; should never be used except for comparison
+ * in pinentry/pinentry.c's cmd_getinfo(): */
+pinentry_cmd_handler_t curses_cmd_handler = NULL;
+
 
 int
 main (int argc, char *argv[])
-- 
2.10.1




More information about the Gnupg-devel mailing list