[git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-99-g835698b

by Werner Koch cvs at cvs.gnupg.org
Tue Nov 20 20:33:11 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  835698b72bc509565aad52b0753f1c56c1a8f062 (commit)
      from  e7bc5012c568da9ceb0a80a8f3fe3edf3dac9564 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 835698b72bc509565aad52b0753f1c56c1a8f062
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Nov 20 19:01:13 2012 +0100

    Do not use a broken ttyname.
    
    * configure.ac (HAVE_BROKEN_TTYNAME): New ac_define set for Android
    systems.
    * common/util.h (gnupg_ttyname): New macro.  Change all callers of
    ttyname to use this macro instead.
    (ttyname) [W32]: Rename to _gnupg_ttyname and use also if
    HAVE_BROKEN_TTYNAME is defined.
    * common/simple-pwquery.c (agent_send_all_options): Keep on using
    ttyname unless HAVE_BROKEN_TTYNAME is set.  This is because this file
    may be used standalone.

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index b117849..32da578 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -662,7 +662,7 @@ main (int argc, char **argv )
       }
     if (!err)
       {
-        s = ttyname (0);
+        s = gnupg_ttyname (0);
         if (s)
           err = session_env_setenv (opt.startup_env, "GPG_TTY", s);
       }
@@ -984,7 +984,7 @@ main (int argc, char **argv )
     }
 
   /* Make sure that we have a default ttyname. */
-  if (!default_ttyname && ttyname (1))
+  if (!default_ttyname && gnupg_ttyname (1))
     default_ttyname = xstrdup (ttyname (1));
   if (!default_ttytype && getenv ("TERM"))
     default_ttytype = xstrdup (getenv ("TERM"));
diff --git a/common/session-env.c b/common/session-env.c
index ff90447..478d5e3 100644
--- a/common/session-env.c
+++ b/common/session-env.c
@@ -338,8 +338,11 @@ session_env_getenv_or_default (session_env_t se, const char *name,
 
   /* Get the default value with an 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")
+      && gnupg_ttyname (0))
+    {
+      defvalue = gnupg_ttyname (0);
+    }
   if (defvalue)
     {
       /* Record the default value for later use so that we are safe
diff --git a/common/simple-pwquery.c b/common/simple-pwquery.c
index 23e4b89..08f59d2 100644
--- a/common/simple-pwquery.c
+++ b/common/simple-pwquery.c
@@ -222,7 +222,7 @@ agent_send_all_options (int fd)
     }
 
   dft_ttyname = getenv ("GPG_TTY");
-#ifndef HAVE_W32_SYSTEM
+#if !defined(HAVE_W32_SYSTEM) && !defined(HAVE_BROKEN_TTYNAME)
   if ((!dft_ttyname || !*dft_ttyname) && ttyname (0))
     dft_ttyname = ttyname (0);
 #endif
diff --git a/common/util.h b/common/util.h
index 5ea7b81..c8a008f 100644
--- a/common/util.h
+++ b/common/util.h
@@ -291,15 +291,21 @@ int gnupg_compare_version (const char *a, const char *b);
 
 
 /*-- Simple replacement functions. */
-#ifndef HAVE_TTYNAME
+
+/* We use the gnupg_ttyname macro to be safe not to run into conflicts
+   which an extisting but broken ttyname.  */
+#if !defined(HAVE_TTYNAME) || defined(HAVE_BROKEN_TTYNAME)
+# define gnupg_ttyname(n) _gnupg_ttyname ((n))
 /* Systems without ttyname (W32) will merely return NULL. */
 static inline char *
-ttyname (int fd)
+_gnupg_ttyname (int fd)
 {
   (void)fd;
   return NULL;
 }
-#endif /* !HAVE_TTYNAME */
+#else /*HAVE_TTYNAME*/
+# define gnupg_ttyname(n) ttyname ((n))
+#endif /*HAVE_TTYNAME */
 
 #ifdef HAVE_W32CE_SYSTEM
 #define getpid() GetCurrentProcessId ()
diff --git a/configure.ac b/configure.ac
index 90c77fa..e821b99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1247,6 +1247,12 @@ AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale])
 AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe getaddrinfo])
 AC_CHECK_FUNCS([ttyname rand ftello fsync stat lstat])
 
+if test "$have_android_system" = yes; then
+   # On Android ttyname is a stub but prints an error message.
+   AC_DEFINE(HAVE_BROKEN_TTYNAME,1,
+             [Defined if ttyname does not work properly])
+fi
+
 AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
 
 # Dirmngr requires mmap on Unix systems.
diff --git a/sm/misc.c b/sm/misc.c
index 4c6293f..ec9f97e 100644
--- a/sm/misc.c
+++ b/sm/misc.c
@@ -57,7 +57,7 @@ setup_pinentry_env (void)
     {
       log_error (_("GPG_TTY has not been set - "
                    "using maybe bogus default\n"));
-      lc = ttyname (0);
+      lc = gnupg_ttyname (0);
       if (!lc)
         lc = "/dev/tty";
       gnupg_setenv ("GPG_TTY", lc, 1);

-----------------------------------------------------------------------

Summary of changes:
 agent/gpg-agent.c       |    4 ++--
 common/session-env.c    |    7 +++++--
 common/simple-pwquery.c |    2 +-
 common/util.h           |   12 +++++++++---
 configure.ac            |    6 ++++++
 sm/misc.c               |    2 +-
 6 files changed, 24 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list