Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2012 06:15:22 GMT
From:      Ben Cottrell <tamino@wolfhut.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/170269: Fix /dev/tty brokenness in ports/security/gnupg [PATCH]
Message-ID:  <201207300615.q6U6FMBC007636@red.freebsd.org>
Resent-Message-ID: <201207300620.q6U6K4kQ045764@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         170269
>Category:       ports
>Synopsis:       Fix /dev/tty brokenness in ports/security/gnupg [PATCH]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 30 06:20:04 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Ben Cottrell
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD pendor.wolfhut.org 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Note: This patch is NOT to be applied to the FreeBSD source tree or the ports
tree with patch(1). It is a patch *file*, to be added as-is to the ports tree, with
a suggested filename of "ports/security/gnupg/files/patch-dev-tty".

If you give gpg some input on standard input, and it needs to prompt you to
enter your passphrase, it doesn't realize that it has to reopen /dev/tty. There
are three places in the source where they try to figure out what the tty is, and
*one* of them was correct. This patch just makes the other two correct, as well.

I also submitted this to the gnupg folks
(https://bugs.g10code.com/gnupg/issue1434). But all else being equal, I'd
rather see this show up in portsnap sooner rather than later! This bug basically
prevents me from using gpg2, and I have to use gpg1 instead.
>How-To-Repeat:
# Force it to use the ncurses pinentry method
unsetenv DISPLAY

# Of course it'll work if you have $GPG_TTY set. This patch makes it work
# even if you do *not* have $GPG_TTY set. To reproduce, you must unset it.
unsetenv GPG_TTY

# Try to sign something, passing the data in as standard input.
touch a_file
gpg -a --clearsign < a_file > out_file

>Fix:


Patch attached with submission follows:

diff -ur common/session-env.c.orig common/session-env.c
--- common/session-env.c.orig	2012-03-27 01:00:37.000000000 -0700
+++ common/session-env.c	2012-07-29 18:35:08.000000000 -0700
@@ -328,8 +328,12 @@
   
   /* Get the default value with and additional fallback for GPG_TTY.  */
   defvalue = getenv (name);
-  if ((!defvalue || !*defvalue) && !strcmp (name, "GPG_TTY") && ttyname (0))
-    defvalue = ttyname (0);
+  if ((!defvalue || !*defvalue) && !strcmp (name, "GPG_TTY"))
+    {
+      defvalue = ttyname (0);
+      if (!defvalue)
+        defvalue = "/dev/tty";
+    }
   if (defvalue)
     {
       /* Record the default value for later use so that we are safe
diff -ur common/simple-pwquery.c.orig common/simple-pwquery.c
--- common/simple-pwquery.c.orig	2012-03-27 01:00:37.000000000 -0700
+++ common/simple-pwquery.c	2012-07-29 18:37:38.000000000 -0700
@@ -224,7 +224,11 @@
   dft_ttyname = getenv ("GPG_TTY");
 #ifndef HAVE_W32_SYSTEM
   if ((!dft_ttyname || !*dft_ttyname) && ttyname (0))
-    dft_ttyname = ttyname (0);
+    {
+      dft_ttyname = ttyname (0);
+      if (!dft_ttyname)
+        dft_ttyname = "/dev/tty";
+    }
 #endif
   if (dft_ttyname && *dft_ttyname)
     {


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207300615.q6U6FMBC007636>