[git] GpgOL - branch, master, updated. gpgol-1.3.0-46-gf716ca6

by Andre Heinecke cvs at cvs.gnupg.org
Thu Feb 25 15:20:54 CET 2016


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 "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  f716ca623114844537924825e25e45ca12ad0b1d (commit)
      from  1097fe9bf5d5d5f7b43f01cbf0cc161ba1706c83 (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 f716ca623114844537924825e25e45ca12ad0b1d
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Feb 25 15:12:22 2016 +0100

    Search for uiserver more agressively
    
    This is supposed to work for both gpg4win 2.x and 3.x and the new
    install layout.
    
    * configure.ac (gpg4win-3-reg-keys): Remove option.
    * src/common.c (default_homedir): Fallback to Gpg4win 2 regkey.
      (get_gpg4win_dir): New. Search at multiple places.
      (get_data_dir): Use get_gpg4win_dir.
    * src/common.h (get_gpg4win_dir): Declare.
      (GPG4WIN_REGKEY_2, GPG4WIN_REGKEY_3): New for old and ney keys.
    * src/engine-assuan.c (get_uiserver_name): Rewrite to look for more
      names.
    * src/main.c (get_locale_dir): Use get_gpg4win_dir.
    
    --
    This fixes gpgol for the new install layout where the uiserver
    executables are installed in the bin subdirectory.

diff --git a/configure.ac b/configure.ac
index 4e82a41..359505a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,14 +247,6 @@ if test "$mime_send" != "no"; then
    [Sending Mime messages will be supported.])
 fi
 
-AC_ARG_ENABLE(gpg4win-3-reg-keys,
-            AC_HELP_STRING([--enable-gpg4win-3-reg-keys], [Use the gpg4win-3 style registry keys]),
-            new_keys=$enableval, new_keys=no)
-if test "$new_keys" != "no"; then
-  AC_DEFINE(NEW_STYLE_REG_KEYS, 1,
-   [The registry keys of Gpg4win-3 will be used])
-fi
-
 #
 # Print errors here so that they are visible all
 # together and the user can acquire them all together.
diff --git a/src/common.c b/src/common.c
index 2142a80..b7b48b0 100644
--- a/src/common.c
+++ b/src/common.c
@@ -710,7 +710,11 @@ default_homedir (void)
         {
           char *tmp;
 
-          tmp = read_w32_registry_string (NULL, GNUPG_REGKEY, "HomeDir");
+          tmp = read_w32_registry_string (NULL, GPG4WIN_REGKEY_3, "HomeDir");
+          if (!tmp)
+            {
+              tmp = read_w32_registry_string (NULL, GPG4WIN_REGKEY_2, "HomeDir");
+            }
           if (tmp && !*tmp)
             {
               free (tmp);
@@ -736,8 +740,7 @@ get_data_dir (void)
   char *p;
   char *dname;
 
-  instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", GNUPG_REGKEY,
-				      "Install Directory");
+  instdir = get_gpg4win_dir();
   if (!instdir)
     return NULL;
   
@@ -1228,3 +1231,32 @@ get_tmp_outfile (wchar_t *name, HANDLE *outHandle)
 
   return outName;
 }
+
+/** Get the Gpg4win Install directory.
+ *
+ * Looks first for the Gpg4win 3.x registry key. Then for the Gpg4win
+ * 2.x registry key. And checks that the directory can be read.
+ *
+ * @returns NULL if no dir could be found. Otherwise a malloced string.
+ */
+char *
+get_gpg4win_dir()
+{
+  const char *g4win_keys[] = {GPG4WIN_REGKEY_3,
+                              GPG4WIN_REGKEY_2,
+                              NULL};
+  const char *key;
+  for (key = *g4win_keys; *key; key++)
+    {
+      char *tmp = read_w32_registry_string (NULL, key, "Install Directory");
+      if (!tmp)
+        {
+          continue;
+        }
+      if (!access(tmp, R_OK))
+        {
+          return tmp;
+        }
+    }
+  return NULL;
+}
diff --git a/src/common.h b/src/common.h
index 4316697..c5c1d68 100644
--- a/src/common.h
+++ b/src/common.h
@@ -36,19 +36,16 @@ extern "C" {
 #endif
 #endif
 
-/* The Registry key used by GnuPg and closley related software.  */
-#ifndef NEW_STYLE_REG_KEYS /* Gpg4win 3 changed the key */
-# ifdef WIN64
-#  define GNUPG_REGKEY  "Software\\Wow6432Node\\GNU\\GnuPG"
-# else
-#  define GNUPG_REGKEY  "Software\\GNU\\GnuPG"
-# endif
-# else
-# ifdef WIN64
-#  define GNUPG_REGKEY  "Software\\Wow6432Node\\Gpg4win"
-# else
-#  define GNUPG_REGKEY  "Software\\Gpg4win"
-# endif
+/* The Registry key used by Gpg4win.  */
+#ifdef WIN64
+# define GPG4WIN_REGKEY_2  "Software\\Wow6432Node\\GNU\\GnuPG"
+#else
+# define GPG4WIN_REGKEY_2  "Software\\GNU\\GnuPG"
+#endif
+#ifdef WIN64
+# define GPG4WIN_REGKEY_3  "Software\\Wow6432Node\\Gpg4win"
+#else
+# define GPG4WIN_REGKEY_3  "Software\\Gpg4win"
 #endif
 /* Identifiers for the protocol.  We use different one than those use
    by gpgme.  FIXME: We might want to define an unknown protocol to
@@ -198,6 +195,7 @@ char *utf8_to_wincp (const char *string);
 
 const char *default_homedir (void);
 char *get_data_dir (void);
+char *get_gpg4win_dir (void);
 
 size_t qp_decode (char *buffer, size_t length, int *r_slbrk);
 char *qp_encode (const char *input, size_t length, size_t* outlen);
diff --git a/src/engine-assuan.c b/src/engine-assuan.c
index 988258b..f2e0b09 100644
--- a/src/engine-assuan.c
+++ b/src/engine-assuan.c
@@ -346,58 +346,72 @@ get_uiserver_name (void)
 {
   char *name = NULL;
   char *dir, *uiserver, *p;
-  int extra_arglen = 0;
+  int extra_arglen = 9;
 
-  dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", GNUPG_REGKEY,
-                                  "Install Directory");
-  if (dir)
+  const char * server_names[] = {"bin\\kleopatra.exe",
+                                 "kleopatra.exe",
+                                 "bin\\gpa.exe",
+                                 "gpa.exe",
+                                 NULL};
+  const char *tmp = NULL;
+
+  dir = get_gpg4win_dir ();
+  if (!dir)
+    {
+      log_error ("Failed to find gpg4win dir");
+      return NULL;
+    }
+  uiserver = read_w32_registry_string (NULL, GPG4WIN_REGKEY_3,
+                                       "UI Server");
+  if (!uiserver)
     {
-      uiserver = read_w32_registry_string (NULL, GNUPG_REGKEY, 
+      uiserver = read_w32_registry_string (NULL, GPG4WIN_REGKEY_2,
                                            "UI Server");
-      if (!uiserver)
-        {
-          uiserver = xstrdup ("kleopatra.exe");
-          extra_arglen = 9; /* Space required for " --daemon".  */
-        }
-
+    }
+  if (uiserver)
+    {
       name = xmalloc (strlen (dir) + strlen (uiserver) + extra_arglen + 2);
       strcpy (stpcpy (stpcpy (name, dir), "\\"), uiserver);
       for (p = name; *p; p++)
         if (*p == '/')
           *p = '\\';
       xfree (uiserver);
-      if (extra_arglen && access (name, F_OK))
+    }
+  if (name && !access (name, F_OK))
+    {
+      /* Set through registry and is accessible */
+      xfree(dir);
+      return name;
+    }
+  /* Fallbacks */
+  for (tmp = *server_names; *tmp; tmp++)
+    {
+      if (name)
         {
-          /* Kleopatra is not installed: Try GPA instead but if it is
-             also not available return the Kleopatra filename.  */
-          const char gpaserver[] = "gpa.exe";
-          char *name2;
-          
-          name2 = xmalloc (strlen (dir) + strlen (gpaserver) + extra_arglen+2);
-          strcpy (stpcpy (stpcpy (name2, dir), "\\"), gpaserver);
-          for (p = name2; *p; p++)
-            if (*p == '/')
-              *p = '\\';
-          if (access (name2, F_OK ))
-            xfree (name2);
-          else
+          xfree (name);
+        }
+      name = xmalloc (strlen (dir) + strlen (tmp) + extra_arglen + 2);
+      strcpy (stpcpy (stpcpy (name, dir), "\\"), tmp);
+      for (p = name; *p; p++)
+        if (*p == '/')
+          *p = '\\';
+      if (!access (name, F_OK))
+        {
+          /* Found a viable candidate */
+          if (strstr (name, "kleopatra.exe"))
             {
-              xfree (name);
-              name = name2;
+              strcat (name, " --daemon");
             }
+          xfree (dir);
+          return name;
         }
-      xfree (dir);
-
-      /* Append the arg for Kleopatra.  */
-      if (name && extra_arglen)
-        strcat (name, " --daemon");
     }
-  
-  return name;
+  xfree (dir);
+  log_error ("Failed to find a viable UIServer");
+  return NULL;
 }
 
 
-
 static gpg_error_t
 send_one_option (assuan_context_t ctx, const char *name, const char *value)
 {
diff --git a/src/main.c b/src/main.c
index 147bf0d..b30a68e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -500,8 +500,7 @@ get_locale_dir (void)
   char *p;
   char *dname;
 
-  instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", GNUPG_REGKEY,
-				      "Install Directory");
+  instdir = get_gpg4win_dir();
   if (!instdir)
     return NULL;
 

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

Summary of changes:
 configure.ac        |  8 -----
 src/common.c        | 38 ++++++++++++++++++++++--
 src/common.h        | 24 +++++++--------
 src/engine-assuan.c | 84 +++++++++++++++++++++++++++++++----------------------
 src/main.c          |  3 +-
 5 files changed, 96 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list