[git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-379-gdb85fec

by Werner Koch cvs at cvs.gnupg.org
Tue Apr 8 17:06:16 CEST 2014


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  db85feceaf43ebd6d44421bb14fcb60495804ae0 (commit)
       via  b4cf4686f7349be9558217f20e51157398cd88a0 (commit)
      from  36dfc37e438660632d3a2bf5d5526be9005fa8c5 (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 db85feceaf43ebd6d44421bb14fcb60495804ae0
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Apr 8 17:06:02 2014 +0200

    dirmngr: Fix compiler warning.
    
    * common/mischelp.h (JNLIB_GCC_HAVE_PUSH_PRAGMA): New.
    * dirmngr/dirmngr.c (handle_tick): Factor time check out to ...
    (time_for_housekeeping_p): new.
    --
    
    I am not sure whether that y2038 hack is really useful but it might
    make me smile in my retirement.

diff --git a/common/mischelp.h b/common/mischelp.h
index e3c4fd1..884e861 100644
--- a/common/mischelp.h
+++ b/common/mischelp.h
@@ -52,10 +52,12 @@ time_t timegm (struct tm *tm);
 #define DIMof(type,member)   DIM(((type *)0)->member)
 
 
+#undef JNLIB_GCC_HAVE_PUSH_PRAGMA
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
 # define JNLIB_GCC_M_FUNCTION 1
 # define JNLIB_GCC_A_NR 	     __attribute__ ((noreturn))
 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
+#   define JNLIB_GCC_HAVE_PUSH_PRAGMA 1
 #   define JNLIB_GCC_A_PRINTF( f, a ) \
                     __attribute__ ((format (__gnu_printf__,f,a)))
 #   define JNLIB_GCC_A_NR_PRINTF( f, a ) \
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index ab65720..81da029 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -1686,18 +1686,36 @@ housekeeping_thread (void *arg)
 }
 
 
-/* This is the worker for the ticker.  It is called every few seconds
-   and may only do fast operations. */
-static void
-handle_tick (void)
+#if JNLIB_GCC_HAVE_PUSH_PRAGMA
+# pragma GCC push_options
+# pragma GCC optimize ("no-strict-overflow")
+#endif
+static int
+time_for_housekeeping_p (time_t curtime)
 {
   static time_t last_housekeeping;
-  time_t curtime;
 
-  curtime = gnupg_get_time ();
   if (!last_housekeeping)
     last_housekeeping = curtime;
 
+  if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime
+      || last_housekeeping > curtime /*(be prepared for y2038)*/)
+    {
+      last_housekeeping = curtime;
+      return 1;
+    }
+  return 0;
+}
+#if JNLIB_GCC_HAVE_PUSH_PRAGMA
+# pragma GCC pop_options
+#endif
+
+
+/* This is the worker for the ticker.  It is called every few seconds
+   and may only do fast operations. */
+static void
+handle_tick (void)
+{
   /* Under Windows we don't use signals and need a way for the loop to
      check for the shutdown flag.  */
 #ifdef HAVE_W32_SYSTEM
@@ -1712,16 +1730,12 @@ handle_tick (void)
     }
 #endif /*HAVE_W32_SYSTEM*/
 
-  /* Start a housekeeping thread every 10 minutes  */
-  if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime
-      || last_housekeeping > curtime /*(be prepared for y2038)*/)
+  if (time_for_housekeeping_p (gnupg_get_time ()))
     {
       npth_t thread;
       npth_attr_t tattr;
       int err;
 
-      last_housekeeping = curtime;
-
       err = npth_attr_init (&tattr);
       if (err)
         log_error ("error preparing housekeeping thread: %s\n", strerror (err));

commit b4cf4686f7349be9558217f20e51157398cd88a0
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Apr 8 15:55:51 2014 +0200

    gpgconf: Add command --launch.
    
    * tools/gpgconf.c: Add command --launch.
    * tools/gpgconf-comp.c (gc_component_launch): New.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/doc/tools.texi b/doc/tools.texi
index 734d619..2a1d38f 100644
--- a/doc/tools.texi
+++ b/doc/tools.texi
@@ -305,6 +305,14 @@ Reload all or the given component. This is basically the same as sending
 a SIGHUP to the component.  Components which don't support reloading are
 ignored.
 
+ at item --launch [@var{component}]
+ at opindex launch
+If the @var{component} is not already running, start it.
+ at command{component} must be a daemon.  This is in general not required
+because the system starts these daemons as needed.  However, external
+software making direct use of @command{gpg-agent} or @command{dirmngr}
+may use this command to ensure that they are started.
+
 @item --kill [@var{component}]
 @opindex kill
 Kill the given component.  Components which support killing are
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 356b251..65c116b 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1108,6 +1108,44 @@ scdaemon_runtime_change (int killflag)
 }
 
 
+/* Launch the gpg-agent or the dirmngr if not already running.  */
+void
+gc_component_launch (int component)
+{
+  gpg_error_t err;
+  const char *pgmname;
+  const char *argv[3];
+  int i;
+  pid_t pid;
+
+  if (!(component == GC_COMPONENT_GPG_AGENT
+        || component == GC_COMPONENT_DIRMNGR))
+    {
+      es_fputs (_("Component not suitable for launching"), es_stderr);
+      es_putc ('\n', es_stderr);
+      exit (1);
+    }
+
+  pgmname = gnupg_module_name (GNUPG_MODULE_NAME_CONNECT_AGENT);
+  i = 0;
+  if (component == GC_COMPONENT_DIRMNGR)
+    argv[i++] = "--dirmngr";
+  argv[i++] = "NOP";
+  argv[i] = NULL;
+
+  err = gnupg_spawn_process_fd (pgmname, argv, -1, -1, -1, &pid);
+  if (!err)
+    err = gnupg_wait_process (pgmname, pid, 1, NULL);
+  if (err)
+    gc_error (0, 0, "error running '%s%s%s': %s",
+              pgmname,
+              component == GC_COMPONENT_DIRMNGR? " --dirmngr":"",
+              " NOP",
+              gpg_strerror (err));
+  gnupg_release_process (pid);
+}
+
+
 /* Unconditionally restart COMPONENT.  */
 void
 gc_component_kill (int component)
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index fbce6d3..96313f6 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -51,6 +51,7 @@ enum cmd_and_opt_values
     aListConfig,
     aCheckConfig,
     aListDirs,
+    aLaunch,
     aKill,
     aReload
   };
@@ -75,6 +76,7 @@ static ARGPARSE_OPTS opts[] =
     { aCheckConfig,   "check-config", 256,
       N_("check global configuration file") },
     { aReload,        "reload", 256, N_("reload all or a given component")},
+    { aLaunch,        "launch", 256, N_("launch a given component")},
     { aKill,          "kill", 256,   N_("kill a given component")},
 
     { 301, NULL, 0, N_("@\nOptions:\n ") },
@@ -184,6 +186,7 @@ main (int argc, char **argv)
         case aListConfig:
         case aCheckConfig:
         case aReload:
+        case aLaunch:
         case aKill:
 	  cmd = pargs.r_opt;
 	  break;
@@ -255,6 +258,7 @@ main (int argc, char **argv)
 	}
       break;
 
+    case aLaunch:
     case aKill:
       if (!fname)
 	{
@@ -266,7 +270,7 @@ main (int argc, char **argv)
 	}
       else
         {
-          /* Kill a given component.  */
+          /* Launch/Kill a given component.  */
           int idx;
 
           idx = gc_component_find (fname);
@@ -276,10 +280,10 @@ main (int argc, char **argv)
               es_putc ('\n', es_stderr);
               exit (1);
             }
+          else if (cmd == aLaunch)
+            gc_component_launch (idx);
           else
-            {
-              gc_component_kill (idx);
-            }
+            gc_component_kill (idx);
         }
       break;
 
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 9caa0d4..0286c27 100644
--- a/tools/gpgconf.h
+++ b/tools/gpgconf.h
@@ -44,6 +44,9 @@ char *gc_percent_escape (const char *src);
 
 void gc_error (int status, int errnum, const char *fmt, ...);
 
+/* Launch given component.  */
+void gc_component_launch (int component);
+
 /* Kill given component.  */
 void gc_component_kill (int component);
 

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

Summary of changes:
 common/mischelp.h    |    2 ++
 dirmngr/dirmngr.c    |   36 +++++++++++++++++++++++++-----------
 doc/tools.texi       |    8 ++++++++
 tools/gpgconf-comp.c |   38 ++++++++++++++++++++++++++++++++++++++
 tools/gpgconf.c      |   12 ++++++++----
 tools/gpgconf.h      |    3 +++
 6 files changed, 84 insertions(+), 15 deletions(-)


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




More information about the Gnupg-commits mailing list