pinentry patches
Peter O'Gorman
gnupg-devel at mlists.thewrittenword.com
Fri May 25 17:24:15 CEST 2007
[sent before, but message was too long, resending with shorter patch]
Hi,
We built pinentry-0.7.2, it required getopt (which required gettext
and iconv), so we added gnulib getopt.
The IRIX compiler, for some reason, did not like this:
{ "version", no_argument, &opt_version, 1 }
so, we changed it.
Most compilers don't understand '\e', so replaced with its hex
equivalent.
Now for the big problem though.
In the normal situation when running pinentry it does not have a
terminal, so it does fopen(tty_name,"r") etc to get a terminal to ask
for the passphrase on. On hpux and tru64 ncurses is unable to properly
initialize this device, it remains in line buffered mode and echoes
the passphrase as it is typed, changing it to *** after the user
presses return. It also does not change the keymappings, so I had to
case '\r':
case '\n':
so the user could get out of the dialog. We "fixed" the echo to the
screen issue using tcsetattr, but I hope that there is some more
knowledgeable person here who knows a proper fix. With this "fix" the
device stays in line buffered mode, but does not echo the chars as
they are typed. It does still change them to '***' after the user
presses <ENTER>.
Anyway, patches, bad as they are, attached.
Peter
[patch does not include added files
getopt.m4, pinentry/getopt.c, pinentry/getopt1.c,
pinentry/getopt_.h, pinentry/getopt_int.h, pinentry/gettext.h which
can be found in gnulib]
-------------- next part --------------
Index: configure.ac
===================================================================
--- configure.ac.orig 2005-01-27 08:04:19.000000000 +0000
+++ configure.ac 2007-05-14 21:06:06.665999000 +0000
@@ -108,14 +98,10 @@
AC_CHECK_FUNCS(seteuid stpcpy mmap)
GNUPG_CHECK_MLOCK
-dnl Checks for libassuan.
-dnl -> None required becuase we use a stripped down version of libassuan.
-
-
dnl Checks for libsecmem.
GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
-
+gl_GETOPT
AC_PATH_PROG(SETCAP, setcap, :, "$PATH:/sbin:/usr/sbin")
AC_CHECK_LIB(cap, cap_set_proc, [
AC_DEFINE(USE_CAPABILITIES,1,[The capabilities support library is installed])
@@ -274,6 +260,9 @@
AM_CONDITIONAL(BUILD_PINENTRY_GTK_2, test "$pinentry_gtk_2" = "yes")
+AM_GNU_GETTEXT_VERSION([0.15.0])
+AM_GNU_GETTEXT([external])
+AM_ICONV
dnl
dnl Check for Qt pinentry program.
dnl
Index: secmem/util.c
===================================================================
--- secmem/util.c.orig 2004-12-22 11:38:10.000000000 +0000
+++ secmem/util.c 2007-05-14 19:47:07.015863000 +0000
@@ -32,15 +32,6 @@
#include "util.h"
-#ifndef TEMP_FAILURE_RETRY
-#define TEMP_FAILURE_RETRY(expression) \
- (__extension__ \
- ({ long int __result; \
- do __result = (long int) (expression); \
- while (__result == -1L && errno == EINTR); \
- __result; }))
-#endif
-
#ifndef HAVE_DOSISH_SYSTEM
static int uid_set = 0;
static uid_t real_uid, file_uid;
@@ -54,8 +45,13 @@
ssize_t written = 0;
for (ptr = (char *)data, todo = bytes; todo; ptr += written, todo -= written)
- if ((written = TEMP_FAILURE_RETRY(write(fd, ptr, todo))) < 0)
- break;
+ {
+ long int __result;
+ do {
+ __result = write(fd, ptr, todo); }
+ while (__result == -1L && errno == EINTR);
+ if ((written = __result) < 0)
+ break; }
return written;
}
Index: pinentry/Makefile.am
===================================================================
--- pinentry/Makefile.am.orig 2003-12-23 08:41:40.000000000 +0000
+++ pinentry/Makefile.am 2007-05-14 20:03:43.702584000 +0000
@@ -31,5 +31,18 @@
AM_CPPFLAGS = -I$(top_srcdir)/assuan -I$(top_srcdir)/secmem
-libpinentry_a_SOURCES = pinentry.h pinentry.c
+libpinentry_a_SOURCES = pinentry.h pinentry.c
+libpinentry_a_LIBADD = $(LIBOBJS)
+
libpinentry_curses_a_SOURCES = pinentry-curses.h pinentry-curses.c
+
+BUILT_SOURCES = $(GETOPT_H)
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+getopt.h: getopt_.h
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/getopt_.h; \
+ } > $@-t
+ mv -f $@-t $@
+MOSTLYCLEANFILES = getopt.h getopt.h-t
Index: pinentry/pinentry.c
===================================================================
--- pinentry/pinentry.c.orig 2004-12-22 11:37:50.000000000 +0000
+++ pinentry/pinentry.c 2007-05-14 21:26:31.039167000 +0000
@@ -281,7 +281,7 @@
" --parent-wid Parent window ID (for positioning)\n"
" -d, --debug Turn on debugging output\n"
" -h, --help Display this help and exit\n"
-" --version Output version information and exit\n", this_pgmname);
+" -V, --version Output version information and exit\n", this_pgmname);
}
@@ -305,7 +305,7 @@
{ "no-global-grab", no_argument, 0, 'g' },
{ "parent-wid", required_argument, 0, 'W' },
{ "help", no_argument, 0, 'h' },
- { "version", no_argument, &opt_version, 1 },
+ { "version", no_argument, 0, 'V' },
{ NULL, 0, NULL, 0 }};
while ((opt = getopt_long (argc, argv, "degh", opts, NULL)) != -1)
@@ -327,7 +327,9 @@
case 'h':
opt_help = 1;
break;
-
+ case 'V':
+ opt_version =1;
+ break;
case 'D':
/* Note, this is currently not used because the GUI engine
has already been initialized when parsing these options. */
Index: pinentry/pinentry-curses.c
===================================================================
--- pinentry/pinentry-curses.c.orig 2007-05-21 20:43:17.466427000 +0000
+++ pinentry/pinentry-curses.c 2007-05-22 01:49:57.845437000 +0000
@@ -34,6 +34,9 @@
#include <string.h>
#include <errno.h>
+#if defined(__hpux) || defined (__osf__)
+#include <termios.h>
+#endif
#include <memory.h>
#include "pinentry.h"
@@ -561,6 +564,18 @@
errno = err;
return -1;
}
+#if defined(__hpux) || defined (__osf__)
+{
+/* HP-UX and Tru64 echo the passphrase on input */
+/* lets set noecho. I don't know why ncurses is unable to properly
+ * initialize the terminal device. */
+ struct termios tios;
+ tcgetattr(fileno(ttyfi),&tios);
+ tios.c_lflag = (ICANON|ISIG);
+ tios.c_iflag = (INLCR|ICRNL|BRKINT);
+ tcsetattr(fileno(ttyfi),0,&tios);
+}
+#endif
screen = newterm (tty_type, ttyfo, ttyfi);
set_term (screen);
}
@@ -653,11 +666,12 @@
}
break;
- case '\e':
+ case 0x1b:
done = -2;
break;
case '\r':
+ case '\n':
switch (diag.pos)
{
case DIALOG_POS_PIN:
More information about the Gnupg-devel
mailing list