[PATCH] Use $DIRMNGR_INFO to find dirmngr.

Phil Pennock gnupg-devel at spodhuis.org
Wed Apr 17 01:44:15 CEST 2013


From: Phil Pennock <pdp at spodhuis.org>

Since dirmngr can take --socket-name to point the socket location
to somewhere acceptable for the user, the path from $DIRMNGR_INFO
is the safest way to find how to communicate.
---
 common/homedir.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/common/homedir.c b/common/homedir.c
index 28e5c9a..526cc16 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -469,7 +469,26 @@ dirmngr_socket_name (void)
     }
   return name;
 #else /*!HAVE_W32_SYSTEM*/
-  return GNUPG_LOCALSTATEDIR "/run/" PACKAGE_NAME "/S.dirmngr";
+  const char *default_dirmngr = GNUPG_LOCALSTATEDIR "/run/" PACKAGE_NAME "/S.dirmngr";
+  static char *existing;
+  char *found, *p;
+
+  if (existing != NULL) {
+    return existing;
+  }
+  found = getenv("DIRMNGR_INFO");
+  if (found == NULL) {
+    return default_dirmngr;
+  }
+  found = xstrdup(found);
+  p = strchr(found, ':');
+  if (p == NULL) {
+    free(found);
+    return default_dirmngr;
+  }
+  *p = '\0';
+  existing = found;
+  return existing;
 #endif /*!HAVE_W32_SYSTEM*/
 }
 
-- 
1.8.0.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: </pipermail/attachments/20130416/185595cc/attachment.sig>


More information about the Gnupg-devel mailing list