[git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.20-23-g4f90c7b

by Werner Koch cvs at cvs.gnupg.org
Thu Aug 1 20:22:28 CEST 2013


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, STABLE-BRANCH-2-0 has been updated
       via  4f90c7b914693b72341fa1e93dda7e075f9717c0 (commit)
       via  aff557409cde6ee38ac086046d9bb5eb2dc5c95b (commit)
       via  1b89863ec195dbfdbc33432569a7b2e7f0f83821 (commit)
      from  c3a57d767719a58ec791a0791842bcc80c859081 (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 4f90c7b914693b72341fa1e93dda7e075f9717c0
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 1 19:50:52 2013 +0200

    w32: Add code to support a portable use of GnuPG.
    
    * common/homedir.c (w32_bin_is_bin, w32_portable_app) [W32]: New.
    (check_portable_app) [W32]: New.
    (standard_homedir, default_homedir) [W32]: Support the portable flag.
    (w32_rootdir, w32_commondir) [W32]: Ditto.
    (gnupg_bindir) [W32]: Ditto.
    --
    
    A portable use of GnuPG under Windows means that GnuPG uses a home
    directory depending on the location of the actual binary.  No registry
    variables are considered.  The portable mode is enabled if in the
    installation directory of the the binary "gpgconf.exe" and a file
    "gpgconf.ctl" are found.  The latter file shall be empty or consist
    only of empty or '#'-style comment lines.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/NEWS b/NEWS
index 782a54b..990e241 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Noteworthy changes in version 2.0.21 (unreleased)
  * The new option --enable-putty-support allows gpg-agent on Windows
    to act as a Pageant replacement with full smartcard support.
 
+ * Support installation as portable application under Windows.
+
 
 Noteworthy changes in version 2.0.20 (2013-05-10)
 -------------------------------------------------
diff --git a/common/homedir.c b/common/homedir.c
index 5adf46a..4b03cfe 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -1,5 +1,6 @@
 /* homedir.c - Setup the home directory.
- *	Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2013 Werner Koch
  *
  * This file is part of GnuPG.
  *
@@ -47,6 +48,33 @@
 #include "sysutils.h"
 
 
+#ifdef HAVE_W32_SYSTEM
+/* A flag used to indicate that a control file for gpgconf has been
+   detected.  Under Windows the presence of this file indicates a
+   portable installations and triggers several changes:
+
+   - The GNUGHOME directory is fixed relative to installation
+     directory.  All other means to set the home directory are
+     ignored.
+
+   - All registry variables are ignored.
+
+   This flag is not used on Unix systems.
+ */
+static int w32_portable_app;
+
+/* This flag is true if this process' binary has been installed under
+   bin and not in the root directory. */
+static int w32_bin_is_bin;
+
+/* Just a little prototype.  */
+static const char *w32_rootdir (void);
+
+#endif /*HAVE_W32_SYSTEM*/
+
+
+
+
 /* This is a helper function to load a Windows function from either of
    one DLLs. */
 #ifdef HAVE_W32_SYSTEM
@@ -99,28 +127,39 @@ standard_homedir (void)
 
   if (!dir)
     {
-      char path[MAX_PATH];
+      const char *rdir;
 
-      /* It might be better to use LOCAL_APPDATA because this is
-         defined as "non roaming" and thus more likely to be kept
-         locally.  For private keys this is desired.  However, given
-         that many users copy private keys anyway forth and back,
-         using a system roaming services might be better than to let
-         them do it manually.  A security conscious user will anyway
-         use the registry entry to have better control.  */
-      if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
-                               NULL, 0, path) >= 0)
+      rdir = w32_rootdir ();
+      if (w32_portable_app)
         {
-          char *tmp = xmalloc (strlen (path) + 6 +1);
-          strcpy (stpcpy (tmp, path), "\\gnupg");
-          dir = tmp;
-
-          /* Try to create the directory if it does not yet exists.  */
-          if (access (dir, F_OK))
-            CreateDirectory (dir, NULL);
+          dir = xstrconcat (rdir, DIRSEP_S "home", NULL);
         }
       else
-        dir = GNUPG_DEFAULT_HOMEDIR;
+        {
+          char path[MAX_PATH];
+
+          /* It might be better to use LOCAL_APPDATA because this is
+             defined as "non roaming" and thus more likely to be kept
+             locally.  For private keys this is desired.  However,
+             given that many users copy private keys anyway forth and
+             back, using a system roaming services might be better
+             than to let them do it manually.  A security conscious
+             user will anyway use the registry entry to have better
+             control.  */
+          if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
+                                   NULL, 0, path) >= 0)
+            {
+              char *tmp = xmalloc (strlen (path) + 6 +1);
+              strcpy (stpcpy (tmp, path), "\\gnupg");
+              dir = tmp;
+
+              /* Try to create the directory if it does not yet exists.  */
+              if (access (dir, F_OK))
+                CreateDirectory (dir, NULL);
+            }
+          else
+            dir = GNUPG_DEFAULT_HOMEDIR;
+        }
     }
   return dir;
 #else/*!HAVE_W32_SYSTEM*/
@@ -135,6 +174,13 @@ default_homedir (void)
 {
   const char *dir;
 
+#ifdef HAVE_W32_SYSTEM
+  /* For a portable application we only use the standard homedir.  */
+  w32_rootdir ();
+  if (w32_portable_app)
+    return standard_homedir ();
+#endif /*HAVE_W32_SYSTEM*/
+
   dir = getenv ("GNUPGHOME");
 #ifdef HAVE_W32_SYSTEM
   if (!dir || !*dir)
@@ -172,6 +218,31 @@ default_homedir (void)
 
 
 #ifdef HAVE_W32_SYSTEM
+/* Check whether gpgconf is installed and if so read the gpgconf.ctl
+   file. */
+static void
+check_portable_app (const char *dir)
+{
+  char *fname;
+
+  fname = xstrconcat (dir, DIRSEP_S "gpgconf.exe", NULL);
+  if (access (fname, F_OK))
+    log_error ("required binary '%s' is not installed\n", fname);
+  else
+    {
+      strcpy (fname + strlen (fname) - 3, "ctl");
+      if (!access (fname, F_OK))
+        {
+          /* gpgconf.ctl file found.  Record this fact.  */
+          w32_portable_app = 1;
+
+          /* FIXME: We should read the file to detect special flags
+             and print a warning if we don't understand them.  */
+        }
+    }
+  xfree (fname);
+}
+
 static const char *
 w32_rootdir (void)
 {
@@ -190,8 +261,22 @@ w32_rootdir (void)
       got_dir = 1;
       p = strrchr (dir, DIRSEP_C);
       if (p)
-        *p = 0;
-      else
+        {
+          *p = 0;
+
+          check_portable_app (dir);
+
+          /* If we are installed below "bin" we strip that and use
+             the top directory instead.  */
+          p = strrchr (dir, DIRSEP_C);
+
+          if (p && !strcmp (p+1, "bin"))
+            {
+              *p = 0;
+              w32_bin_is_bin = 1;
+            }
+        }
+      if (!p)
         {
           log_debug ("bad filename `%s' returned for this process\n", dir);
           *dir = 0;
@@ -211,8 +296,17 @@ w32_commondir (void)
 
   if (!dir)
     {
+      const char *rdir;
       char path[MAX_PATH];
 
+      /* Make sure that w32_rootdir has been called so that we are
+         able to check the portable application flag.  The common dir
+         is identical to the rootdir.  In that case there is also no
+         need to strdup its value.  */
+      rdir = w32_rootdir ();
+      if (w32_portable_app)
+        return rdir;
+
       if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA,
                                NULL, 0, path) >= 0)
         {
@@ -226,7 +320,7 @@ w32_commondir (void)
         {
           /* Ooops: Not defined - probably an old Windows version.
              Use the installation directory instead.  */
-          dir = xstrdup (w32_rootdir ());
+          dir = xstrdup (rdir);
         }
     }
 
@@ -235,8 +329,6 @@ w32_commondir (void)
 #endif /*HAVE_W32_SYSTEM*/
 
 
-
-
 /* Return the name of the sysconfdir.  This is a static string.  This
    function is required because under Windows we can't simply compile
    it in.  */
@@ -265,7 +357,19 @@ const char *
 gnupg_bindir (void)
 {
 #ifdef HAVE_W32_SYSTEM
-  return w32_rootdir ();
+  const char *rdir;
+
+  rdir = w32_rootdir ();
+  if (w32_bin_is_bin)
+    {
+      static char *name;
+
+      if (!name)
+        name = xstrconcat (rdir, DIRSEP_S "bin", NULL);
+      return name;
+    }
+  else
+    return rdir;
 #else /*!HAVE_W32_SYSTEM*/
   return GNUPG_BINDIR;
 #endif /*!HAVE_W32_SYSTEM*/
@@ -278,7 +382,7 @@ const char *
 gnupg_libexecdir (void)
 {
 #ifdef HAVE_W32_SYSTEM
-  return w32_rootdir ();
+  return gnupg_bindir ();
 #else /*!HAVE_W32_SYSTEM*/
   return GNUPG_LIBEXECDIR;
 #endif /*!HAVE_W32_SYSTEM*/
diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi
index dcd96fb..f832b8e 100644
--- a/doc/gpg-agent.texi
+++ b/doc/gpg-agent.texi
@@ -449,6 +449,16 @@ Do not make use of the scdaemon tool.  This option has the effect of
 disabling the ability to do smartcard operations.  Note, that enabling
 this option at runtime does not kill an already forked scdaemon.
 
+ at ifset gpgtwoone
+ at item --disable-check-own-socket
+ at opindex disable-check-own-socket
+ at command{gpg-agent} employs a periodic self-test to detect a stolen
+socket.  This usually means a second instance of @command{gpg-agent}
+has taken over the socket and @command{gpg-agent} will then terminate
+itself.  This option may be used to disable this self-test for
+debugging purposes.
+ at end ifset
+
 @item --use-standard-socket
 @itemx --no-use-standard-socket
 @opindex use-standard-socket
@@ -695,14 +705,16 @@ Here is a list of supported signals:
 @item SIGHUP
 @cpindex SIGHUP
 This signal flushes all cached passphrases and if the program has been
-started with a configuration file, the configuration file is read again.
-Only certain options are honored: @code{quiet}, @code{verbose},
- at code{debug}, @code{debug-all}, @code{debug-level}, @code{no-grab},
- at code{pinentry-program}, @code{default-cache-ttl}, @code{max-cache-ttl},
- at code{ignore-cache-for-signing}, @code{allow-mark-trusted} and
- at code{disable-scdaemon}.  @code{scdaemon-program} is also supported but
-due to the current implementation, which calls the scdaemon only once,
-it is not of much use unless you manually kill the scdaemon.
+started with a configuration file, the configuration file is read
+again.  Only certain options are honored: @code{quiet},
+ at code{verbose}, @code{debug}, @code{debug-all}, @code{debug-level},
+ at code{no-grab}, @code{pinentry-program}, @code{default-cache-ttl},
+ at code{max-cache-ttl}, @code{ignore-cache-for-signing},
+ at code{allow-mark-trusted}, @code{disable-scdaemon}, and
+ at code{disable-check-own-socket}.  @code{scdaemon-program} is also
+supported but due to the current implementation, which calls the
+scdaemon only once, it is not of much use unless you manually kill the
+scdaemon.
 
 
 @item SIGTERM

commit aff557409cde6ee38ac086046d9bb5eb2dc5c95b
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 1 19:48:00 2013 +0200

    w32: Always require libiconv.
    
    * configure.ac (missing_iconv): Set and die if we have no libiconv.
    * m4/iconv.m4: Update from libiconv 1.14.
    * tools/Makefile.am (gpgtar_LDADD): Add LIBICONV.
    * jnlib/utf8conv.c: Always include iconv.h
    (load_libiconv): Remove this w32 only function.
    (iconv_open, iconv, iconv_close): Remove W32 function pointer.
    (set_native_charset): Do not call load_libiconv.
    (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): Ditto.
    --
    
    This patch removes the on-demand-loading of libiconv which we did for
    13 years or so.  The rationale back then was that libiconv is too
    large and often not used.  Nowadays all kind of Unix software has been
    ported to Windows and many of them require libiconv.  Thus in the end
    there is no saving from not requiring it.  It also remove a common
    source of trouble with awrong or missing iconv.dll.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/autogen.sh b/autogen.sh
index b81a6b2..605babf 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -94,6 +94,7 @@ if test "$1" = "--build-w32"; then
 	     --with-zlib=${w32root} \
 	     --with-regex=${w32root} \
              --with-pth-prefix=${w32root} \
+             --with-libiconv-prefix=${w32root} \
              --with-adns=${w32root} "$@"
     rc=$?
     exit $rc
diff --git a/configure.ac b/configure.ac
index 702b8d3..4080699 100644
--- a/configure.ac
+++ b/configure.ac
@@ -979,7 +979,11 @@ AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
 #
 # Checking for iconv
 #
+missing_iconv=no
 AM_ICONV
+if test "$am_cv_func_iconv" != yes; then
+   missing_iconv=yes
+fi
 
 
 #
@@ -1498,6 +1502,14 @@ if test "$missing_pth" = "yes"; then
 ***]])
    die=yes
 fi
+if test "$missing_iconv" = "yes"; then
+    AC_MSG_NOTICE([[
+***
+*** It is now required to build with support for iconv
+*** Please install a suitable iconv implementation.
+***]])
+   die=yes
+fi
 
 if test "$die" = "yes"; then
     AC_MSG_ERROR([[
diff --git a/jnlib/utf8conv.c b/jnlib/utf8conv.c
index fee4dc6..b5cf6a8 100644
--- a/jnlib/utf8conv.c
+++ b/jnlib/utf8conv.c
@@ -27,9 +27,7 @@
 #include <langinfo.h>
 #endif
 #include <errno.h>
-#ifndef HAVE_W32_SYSTEM
-# include <iconv.h>
-#endif
+#include <iconv.h>
 
 #include "libjnlib-config.h"
 #include "stringhelp.h"
@@ -45,59 +43,6 @@ static int no_translation;     /* Set to true if we let simply pass through. */
 static int use_iconv;          /* iconv comversion fucntions required. */
 
 
-/* Under W32 we dlopen the iconv dll and don't require any iconv
-   related headers at all.  However we need to define some stuff.  */
-#ifdef HAVE_W32_SYSTEM
-typedef void *iconv_t;
-#ifndef ICONV_CONST
-#define ICONV_CONST const 
-#endif
-static iconv_t (* __stdcall iconv_open) (const char *tocode,
-                                         const char *fromcode);
-static size_t  (* __stdcall iconv) (iconv_t cd,
-                                    const char **inbuf, size_t *inbytesleft,
-                                    char **outbuf, size_t *outbytesleft);
-static int     (* __stdcall iconv_close) (iconv_t cd);
-
-static int 
-load_libiconv (void)
-{
-  static int done;
-  
-  if (!done)
-    {
-      void *handle;
-
-      done = 1; /* Do it right now because we might get called recursivly
-                   through gettext.  */
-    
-      handle = dlopen ("iconv.dll", RTLD_LAZY);
-      if (handle)
-        {
-          iconv_open  = dlsym (handle, "libiconv_open");
-          if (iconv_open)
-            iconv = dlsym (handle, "libiconv");
-          if (iconv)    
-            iconv_close = dlsym (handle, "libiconv_close");
-        }
-      if (!handle || !iconv_close)
-        {
-          log_info (_("error loading `%s': %s\n"),
-                     "iconv.dll",  dlerror ());
-          log_info (_("please see %s for more information\n"),
-                    "http://www.gnupg.org/download/iconv.html");
-          iconv_open = NULL;
-          iconv = NULL;
-          iconv_close = NULL;
-          if (handle)
-            dlclose (handle);
-        }
-    }
-  return iconv_open? 0: -1;
-}    
-#endif /*HAVE_W32_SYSTEM*/
-
-
 /* Error handler for iconv failures. This is needed to not clutter the
    output with repeated diagnostics about a missing conversion. */
 static void
@@ -152,13 +97,13 @@ set_native_charset (const char *newset)
 {
   const char *full_newset;
 
-  if (!newset) 
+  if (!newset)
     {
 #ifdef HAVE_W32_SYSTEM
       static char codepage[30];
       unsigned int cpno;
       const char *aliases;
-      
+
       /* We are a console program thus we need to use the
          GetConsoleOutputCP function and not the the GetACP which
          would give the codepage for a GUI program.  Note this is not
@@ -201,7 +146,7 @@ set_native_charset (const char *newset)
         }
 
 #else /*!HAVE_W32_SYSTEM*/
-      
+
 #ifdef HAVE_LANGINFO_CODESET
       newset = nl_langinfo (CODESET);
 #else /*!HAVE_LANGINFO_CODESET*/
@@ -225,7 +170,7 @@ set_native_charset (const char *newset)
               mod = strchr (++dot, '@');
               if (!mod)
                 mod = dot + strlen (dot);
-              if (mod - dot < sizeof codepage && dot != mod) 
+              if (mod - dot < sizeof codepage && dot != mod)
                 {
                   memcpy (codepage, dot, mod - dot);
                   codepage [mod - dot] = 0;
@@ -272,21 +217,16 @@ set_native_charset (const char *newset)
   else
     {
       iconv_t cd;
-      
-#ifdef HAVE_W32_SYSTEM
-      if (load_libiconv ())
-        return -1;
-#endif /*HAVE_W32_SYSTEM*/      
 
       cd = iconv_open (full_newset, "utf-8");
-      if (cd == (iconv_t)-1) 
+      if (cd == (iconv_t)-1)
         {
           handle_iconv_error (full_newset, "utf-8", 0);
           return -1;
         }
       iconv_close (cd);
       cd = iconv_open ("utf-8", full_newset);
-      if (cd == (iconv_t)-1) 
+      if (cd == (iconv_t)-1)
         {
           handle_iconv_error ("utf-8", full_newset, 0);
           return -1;
@@ -306,7 +246,7 @@ get_native_charset ()
 }
 
 /* Return true if the native charset is utf-8.  */
-int 
+int
 is_native_utf8 (void)
 {
   return no_translation;
@@ -353,13 +293,13 @@ native_to_utf8 (const char *orig_string)
       *p = 0;
     }
   else
-    { 
+    {
       /* Need to use iconv.  */
       iconv_t cd;
       const char *inptr;
       char *outptr;
       size_t inbytes, outbytes;
-     
+
       cd = iconv_open ("utf-8", active_charset_name);
       if (cd == (iconv_t)-1)
         {
@@ -367,14 +307,14 @@ native_to_utf8 (const char *orig_string)
           return native_to_utf8 (string);
         }
 
-      for (s=string; *s; s++ ) 
+      for (s=string; *s; s++ )
         {
           length++;
           if ((*s & 0x80))
             length += 5; /* We may need up to 6 bytes for the utf8 output. */
         }
       buffer = jnlib_xmalloc (length + 1);
-      
+
       inptr = string;
       inbytes = strlen (string);
       outptr = buffer;
@@ -448,10 +388,10 @@ do_utf8_to_native (const char *string, size_t length, int delim,
 	  if (!nleft)
 	    {
 	      if (!(*s & 0x80))
-		{	
+		{
                   /* Plain ascii. */
 		  if ( delim != -1
-                       && (*s < 0x20 || *s == 0x7f || *s == delim 
+                       && (*s < 0x20 || *s == 0x7f || *s == delim
                            || (delim && *s == '\\')))
 		    {
 		      n++;
@@ -490,35 +430,35 @@ do_utf8_to_native (const char *string, size_t length, int delim,
 		  encbuf[encidx++] = *s;
 		}
 	      else if ((*s & 0xf0) == 0xe0) /* 1110 xxxx */
-		{	
+		{
 		  val = *s & 0x0f;
 		  nleft = 2;
 		  encidx = 0;
 		  encbuf[encidx++] = *s;
 		}
 	      else if ((*s & 0xf8) == 0xf0) /* 1111 0xxx */
-		{	
+		{
 		  val = *s & 0x07;
 		  nleft = 3;
 		  encidx = 0;
 		  encbuf[encidx++] = *s;
 		}
 	      else if ((*s & 0xfc) == 0xf8) /* 1111 10xx */
-		{	
+		{
 		  val = *s & 0x03;
 		  nleft = 4;
 		  encidx = 0;
 		  encbuf[encidx++] = *s;
 		}
 	      else if ((*s & 0xfe) == 0xfc) /* 1111 110x */
-		{		
+		{
 		  val = *s & 0x01;
 		  nleft = 5;
 		  encidx = 0;
 		  encbuf[encidx++] = *s;
 		}
 	      else /* Invalid encoding: print as \xNN. */
-		{		
+		{
 		  if (p)
 		    {
 		      sprintf (p, "\\x%02x", *s);
@@ -551,7 +491,7 @@ do_utf8_to_native (const char *string, size_t length, int delim,
 	      val <<= 6;
 	      val |= *s & 0x3f;
 	      if (!--nleft)  /* Ready. */
-		{ 
+		{
 		  if (no_translation)
 		    {
 		      if (p)
@@ -590,12 +530,12 @@ do_utf8_to_native (const char *string, size_t length, int delim,
 		      if (val >= 0x80 && val < 256)
 			{
                           /* We can simply print this character */
-			  n++;	
+			  n++;
 			  if (p)
 			    *p++ = val;
 			}
 		      else
-			{	
+			{
                           /* We do not have a translation: print utf8. */
 			  if (p)
 			    {
@@ -625,7 +565,7 @@ do_utf8_to_native (const char *string, size_t length, int delim,
           const char *inptr;
           char *outbuf, *outptr;
           size_t inbytes, outbytes;
-          
+
           *p = 0;  /* Terminate the buffer. */
 
           cd = iconv_open (active_charset_name, "utf-8");
@@ -642,14 +582,14 @@ do_utf8_to_native (const char *string, size_t length, int delim,
           inbytes = n - 1;;
           inptr = buffer;
           outbytes = n * MB_LEN_MAX;
-          if (outbytes / MB_LEN_MAX != n) 
+          if (outbytes / MB_LEN_MAX != n)
             BUG (); /* Actually an overflow. */
           outbuf = outptr = jnlib_xmalloc (outbytes);
           if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
-                      &outptr, &outbytes) == (size_t)-1) 
+                      &outptr, &outbytes) == (size_t)-1)
             {
               static int shown;
-              
+
               if (!shown)
                 log_info (_("conversion from `%s' to `%s' failed: %s\n"),
                           "utf-8", active_charset_name, strerror (errno));
@@ -661,7 +601,7 @@ do_utf8_to_native (const char *string, size_t length, int delim,
               outbuf = do_utf8_to_native (string, length, delim, 0);
             }
             else /* Success.  */
-              { 
+              {
                 *outptr = 0; /* Make sure it is a string. */
                 /* We could realloc the buffer now but I doubt that it
                    makes much sense given that it will get freed
@@ -694,45 +634,29 @@ utf8_to_native (const char *string, size_t length, int delim)
 
 
 
-/* Wrapper function for iconv_open, required for W32 as we dlopen that
-   library on that system.  */
-jnlib_iconv_t 
+/* Wrapper function for iconv_open, formerly required for W32 as we
+   used to dlopen that library on that system.  */
+jnlib_iconv_t
 jnlib_iconv_open (const char *tocode, const char *fromcode)
 {
-#ifdef HAVE_W32_SYSTEM
-  if (load_libiconv ())
-    return (jnlib_iconv_t)(-1);
-#endif /*HAVE_W32_SYSTEM*/      
-
   return (jnlib_iconv_t)iconv_open (tocode, fromcode);
 }
 
 
-/* Wrapper function for iconv, required for W32 as we dlopen that
-   library on that system.  */
+/* Wrapper function for iconv, formerly required for W32 as we used to
+   dlopen that library on that system.  */
 size_t
 jnlib_iconv (jnlib_iconv_t cd,
              const char **inbuf, size_t *inbytesleft,
              char **outbuf, size_t *outbytesleft)
 {
-
-#ifdef HAVE_W32_SYSTEM
-  if (load_libiconv ())
-    return 0;
-#endif /*HAVE_W32_SYSTEM*/      
-
   return iconv ((iconv_t)cd, (char**)inbuf, inbytesleft, outbuf, outbytesleft);
 }
 
-/* Wrapper function for iconv_close, required for W32 as we dlopen that
-   library on that system.  */
+/* Wrapper function for iconv_close, formerly required for W32 as we
+   used to dlopen that library on that system.  */
 int
 jnlib_iconv_close (jnlib_iconv_t cd)
 {
-#ifdef HAVE_W32_SYSTEM
-  if (load_libiconv ())
-    return 0;
-#endif /*HAVE_W32_SYSTEM*/      
-
   return iconv_close ((iconv_t)cd);
 }
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 66bc76f..085cd06 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,5 +1,5 @@
-# iconv.m4 serial AM6 (gettext-0.17)
-dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc.
+# iconv.m4 serial 17 (gettext-0.18.2)
+dnl Copyright (C) 2000-2002, 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -30,44 +30,55 @@ AC_DEFUN([AM_ICONV_LINK],
   dnl Add $INCICONV to CPPFLAGS before performing the following checks,
   dnl because if the user has installed libiconv and not disabled its use
   dnl via --without-libiconv-prefix, he wants to use it. The first
-  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
   am_save_CPPFLAGS="$CPPFLAGS"
   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
 
-  AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [
+  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
-    AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
-      [iconv_t cd = iconv_open("","");
-       iconv(cd,NULL,NULL,NULL,NULL);
-       iconv_close(cd);],
-      am_cv_func_iconv=yes)
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[
+#include <stdlib.h>
+#include <iconv.h>
+         ]],
+         [[iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);]])],
+      [am_cv_func_iconv=yes])
     if test "$am_cv_func_iconv" != yes; then
       am_save_LIBS="$LIBS"
       LIBS="$LIBS $LIBICONV"
-      AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
-        [iconv_t cd = iconv_open("","");
-         iconv(cd,NULL,NULL,NULL,NULL);
-         iconv_close(cd);],
-        am_cv_lib_iconv=yes
-        am_cv_func_iconv=yes)
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[
+#include <stdlib.h>
+#include <iconv.h>
+           ]],
+           [[iconv_t cd = iconv_open("","");
+             iconv(cd,NULL,NULL,NULL,NULL);
+             iconv_close(cd);]])],
+        [am_cv_lib_iconv=yes]
+        [am_cv_func_iconv=yes])
       LIBS="$am_save_LIBS"
     fi
   ])
   if test "$am_cv_func_iconv" = yes; then
-    AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [
-      dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
+    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
+      dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
+      dnl Solaris 10.
       am_save_LIBS="$LIBS"
       if test $am_cv_lib_iconv = yes; then
         LIBS="$LIBS $LIBICONV"
       fi
-      AC_TRY_RUN([
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
 #include <iconv.h>
 #include <string.h>
 int main ()
 {
+  int result = 0;
   /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
      returns.  */
   {
@@ -84,7 +95,47 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if (res == 0)
-          return 1;
+          result |= 1;
+        iconv_close (cd_utf8_to_88591);
+      }
+  }
+  /* Test against Solaris 10 bug: Failures are not distinguishable from
+     successful returns.  */
+  {
+    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
+    if (cd_ascii_to_88591 != (iconv_t)(-1))
+      {
+        static const char input[] = "\263";
+        char buf[10];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_ascii_to_88591,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          result |= 2;
+        iconv_close (cd_ascii_to_88591);
+      }
+  }
+  /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
+  {
+    iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
+    if (cd_88591_to_utf8 != (iconv_t)(-1))
+      {
+        static const char input[] = "\304";
+        static char buf[2] = { (char)0xDE, (char)0xAD };
+        const char *inptr = input;
+        size_t inbytesleft = 1;
+        char *outptr = buf;
+        size_t outbytesleft = 1;
+        size_t res = iconv (cd_88591_to_utf8,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
+          result |= 4;
+        iconv_close (cd_88591_to_utf8);
       }
   }
 #if 0 /* This bug could be worked around by the caller.  */
@@ -103,7 +154,8 @@ int main ()
                             (char **) &inptr, &inbytesleft,
                             &outptr, &outbytesleft);
         if ((int)res > 0)
-          return 1;
+          result |= 8;
+        iconv_close (cd_88591_to_utf8);
       }
   }
 #endif
@@ -117,13 +169,19 @@ int main ()
       && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
       /* Try HP-UX names.  */
       && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
-    return 1;
-  return 0;
-}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
-        [case "$host_os" in
+    result |= 16;
+  return result;
+}]])],
+        [am_cv_func_iconv_works=yes],
+        [am_cv_func_iconv_works=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
            aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
            *)            am_cv_func_iconv_works="guessing yes" ;;
-         esac])
+         esac
+changequote([,])dnl
+        ])
       LIBS="$am_save_LIBS"
     ])
     case "$am_cv_func_iconv_works" in
@@ -134,7 +192,7 @@ int main ()
     am_func_iconv=no am_cv_lib_iconv=no
   fi
   if test "$am_func_iconv" = yes; then
-    AC_DEFINE(HAVE_ICONV, 1,
+    AC_DEFINE([HAVE_ICONV], [1],
       [Define if you have the iconv() function and it works.])
   fi
   if test "$am_cv_lib_iconv" = yes; then
@@ -147,17 +205,37 @@ int main ()
     LIBICONV=
     LTLIBICONV=
   fi
-  AC_SUBST(LIBICONV)
-  AC_SUBST(LTLIBICONV)
+  AC_SUBST([LIBICONV])
+  AC_SUBST([LTLIBICONV])
 ])
 
-AC_DEFUN([AM_ICONV],
+dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
+dnl avoid warnings like
+dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
+dnl This is tricky because of the way 'aclocal' is implemented:
+dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
+dnl   Otherwise aclocal's initial scan pass would miss the macro definition.
+dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
+dnl   Otherwise aclocal would emit many "Use of uninitialized value $1"
+dnl   warnings.
+m4_define([gl_iconv_AC_DEFUN],
+  m4_version_prereq([2.64],
+    [[AC_DEFUN_ONCE(
+        [$1], [$2])]],
+    [m4_ifdef([gl_00GNULIB],
+       [[AC_DEFUN_ONCE(
+           [$1], [$2])]],
+       [[AC_DEFUN(
+           [$1], [$2])]])]))
+gl_iconv_AC_DEFUN([AM_ICONV],
 [
   AM_ICONV_LINK
   if test "$am_cv_func_iconv" = yes; then
     AC_MSG_CHECKING([for iconv declaration])
-    AC_CACHE_VAL(am_cv_proto_iconv, [
-      AC_TRY_COMPILE([
+    AC_CACHE_VAL([am_cv_proto_iconv], [
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[
 #include <stdlib.h>
 #include <iconv.h>
 extern
@@ -169,12 +247,22 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si
 #else
 size_t iconv();
 #endif
-], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+           ]],
+           [[]])],
+        [am_cv_proto_iconv_arg1=""],
+        [am_cv_proto_iconv_arg1="const"])
       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
-    AC_MSG_RESULT([$]{ac_t:-
-         }[$]am_cv_proto_iconv)
-    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+    AC_MSG_RESULT([
+         $am_cv_proto_iconv])
+    AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
       [Define as const if the declaration of iconv() needs const.])
+    dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
+    m4_ifdef([gl_ICONV_H_DEFAULTS],
+      [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
+       if test -n "$am_cv_proto_iconv_arg1"; then
+         ICONV_CONST="const"
+       fi
+      ])
   fi
 ])
diff --git a/tools/Makefile.am b/tools/Makefile.am
index bacdaf3..a94fbcd 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -118,7 +118,8 @@ gpgtar_SOURCES = \
 	gpgtar-list.c \
 	no-libgcrypt.c
 gpgtar_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS)
-gpgtar_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(W32SOCKLIBS)
+gpgtar_LDADD = $(common_libs) $(GPG_ERROR_LIBS) \
+               $(NETLIBS) $(LIBICONV) $(W32SOCKLIBS)
 
 # Make sure that all libs are build before we use them.  This is
 # important for things like make -j2.

commit 1b89863ec195dbfdbc33432569a7b2e7f0f83821
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 1 14:02:50 2013 +0200

    w32: Remove unused code.
    
    * jnlib/w32-reg.c (write_w32_registry_string): Remove.

diff --git a/jnlib/w32-reg.c b/jnlib/w32-reg.c
index a6e2395..e55f806 100644
--- a/jnlib/w32-reg.c
+++ b/jnlib/w32-reg.c
@@ -148,38 +148,4 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
 }
 
 
-int
-write_w32_registry_string (const char *root, const char *dir,
-                           const char *name, const char *value)
-{
-  HKEY root_key, reg_key;
-
-  if ( !(root_key = get_root_key(root) ) )
-    return -1;
-
-  if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, &reg_key )
-       != ERROR_SUCCESS )
-    return -1;
-
-  if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value,
-                      strlen( value ) ) != ERROR_SUCCESS )
-    {
-      if ( RegCreateKey( root_key, name, &reg_key ) != ERROR_SUCCESS )
-        {
-          RegCloseKey(reg_key);
-          return -1;
-        }
-      if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value,
-                          strlen( value ) ) != ERROR_SUCCESS )
-        {
-          RegCloseKey(reg_key);
-          return -1;
-        }
-    }
-
-  RegCloseKey (reg_key);
-
-  return 0;
-}
-
 #endif /*HAVE_W32_SYSTEM*/
diff --git a/jnlib/w32help.h b/jnlib/w32help.h
index c503ad2..c7aa5cb 100644
--- a/jnlib/w32help.h
+++ b/jnlib/w32help.h
@@ -24,8 +24,6 @@
 /*-- w32-reg.c --*/
 char *read_w32_registry_string (const char *root,
 				const char *dir, const char *name );
-int write_w32_registry_string (const char *root, const char *dir,
-                               const char *name, const char *value);
 
 #ifdef USE_SIMPLE_GETTEXT
 char *bindtextdomain (const char *domainname, const char *dirname);

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

Summary of changes:
 NEWS               |    2 +
 autogen.sh         |    1 +
 common/homedir.c   |  156 +++++++++++++++++++++++++++++++++++++++++--------
 configure.ac       |   12 ++++
 doc/gpg-agent.texi |   28 +++++++---
 jnlib/utf8conv.c   |  144 +++++++++++-----------------------------------
 jnlib/w32-reg.c    |   34 -----------
 jnlib/w32help.h    |    2 -
 m4/iconv.m4        |  162 ++++++++++++++++++++++++++++++++++++++++------------
 tools/Makefile.am  |    3 +-
 10 files changed, 326 insertions(+), 218 deletions(-)


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




More information about the Gnupg-commits mailing list