[RFC PATCH] dirmngr: Try to recognize user-daemon mode

Tomáš Trnka tomastrnka at gmx.com
Sun Jul 3 21:34:03 CEST 2016


* dirmngr/dirmngr.c (main): Detect user-daemon mode

Signed-off-by: Tomáš Trnka <tomastrnka at gmx.com>
--
Dirmngr needs to tell when it is started as an user daemon through
start_new_dirmngr(), in order to switch off code paths specific for
the systemwide case (internal OCSP validation, root-only remote
control etc.)

There's no reliable indication of the user-daemon mode, but
start_new_dirmngr() currently uses the combination of --daemon and
(hopefully) default --homedir. Let's thus make dirmngr understand
that for now.

Of course this is a horrible hack, it would be best to solve this by
introducing a new --user-daemon option, by signalling it through an
environment variable or something like that.
---
 dirmngr/dirmngr.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 7e629db..7ba176c 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -716,6 +716,7 @@ main (int argc, char **argv)
   int rc;
   int homedir_seen = 0;
   struct assuan_malloc_hooks malloc_hooks;
+  char *abs_homedir;
 
   early_system_init ();
 
@@ -868,7 +869,17 @@ main (int argc, char **argv)
       socket_name = dirmngr_sys_socket_name ();
     }
   else if (dirmngr_user_socket_name ())
-    socket_name = dirmngr_user_socket_name ();
+    {
+      socket_name = dirmngr_user_socket_name ();
+
+      /* The combination of --daemon and --homedir $default_homedir
+         indicates we're being started as a user daemon by other GnuPG
+         components. Let's turn off special system-daemon behavior. */
+      abs_homedir = make_absfilename (default_homedir (), NULL);
+      if (strcmp(opt.homedir, abs_homedir) == 0)
+        opt.system_daemon = 0;
+      xfree (abs_homedir);
+    }
   else
     socket_name = dirmngr_sys_socket_name ();
 
-- 
2.7.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2214 bytes
Desc: not available
URL: </pipermail/attachments/20160703/ba2a762a/attachment.bin>


More information about the Gnupg-devel mailing list