aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/ChangeLog11
-rw-r--r--tools/gpgconf-comp.c55
-rw-r--r--tools/gpgconf.c32
-rw-r--r--tools/gpgconf.h3
4 files changed, 95 insertions, 6 deletions
diff --git a/tools/ChangeLog b/tools/ChangeLog
index dbe090f0b..6c0920e11 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,14 @@
+2009-03-03 Werner Koch <[email protected]>
+
+ * gpgconf.c: New command --reload.
+
+ * gpgconf-comp.c (gc_component_reload): New.
+
+2009-03-02 Werner Koch <[email protected]>
+
+ * gpgconf-comp.c (scdaemon_runtime_change): Killsc d only if it is
+ not running.
+
2009-02-27 Werner Koch <[email protected]>
* gpgconf-comp.c (gpg_agent_runtime_change): Declare static.
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 66fe30dcb..92016efc4 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1,5 +1,5 @@
/* gpgconf-comp.c - Configuration utility for GnuPG.
- * Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -1051,12 +1051,21 @@ scdaemon_runtime_change (void)
{
gpg_error_t err;
const char *pgmname;
- const char *argv[2];
+ const char *argv[6];
pid_t pid;
+ /* We use "GETINFO app_running" to see whether the agent is already
+ running and kill it only in this case. This avoids an explicit
+ starting of the agent in case it is not yet running. There is
+ obviously a race condition but that should not harm too much. */
+
pgmname = gnupg_module_name (GNUPG_MODULE_NAME_CONNECT_AGENT);
- argv[0] = "scd killscd";
- argv[1] = NULL;
+ argv[0] = "-s";
+ argv[1] = "GETINFO scd_running";
+ argv[2] = "/if ${! $?}";
+ argv[3] = "scd killscd";
+ argv[4] = "/end";
+ argv[5] = NULL;
err = gnupg_spawn_process_fd (pgmname, argv, -1, -1, -1, &pid);
if (!err)
@@ -1067,6 +1076,44 @@ scdaemon_runtime_change (void)
}
+/* Unconditionally reload COMPONENT or all components if COMPONENT is -1. */
+void
+gc_component_reload (int component)
+{
+ int runtime[GC_BACKEND_NR];
+ gc_option_t *option;
+ gc_backend_t backend;
+
+ /* Set a flag for the backends to be reloaded. */
+ for (backend = 0; backend < GC_BACKEND_NR; backend++)
+ runtime[backend] = 0;
+
+ if (component == -1)
+ {
+ for (component = 0; component < GC_COMPONENT_NR; component++)
+ {
+ option = gc_component[component].options;
+ for (; option && option->name; option++)
+ runtime[option->backend] = 1;
+ }
+ }
+ else
+ {
+ assert (component < GC_COMPONENT_NR);
+ option = gc_component[component].options;
+ for (; option && option->name; option++)
+ runtime[option->backend] = 1;
+ }
+
+ /* Do the reload for all selected backends. */
+ for (backend = 0; backend < GC_BACKEND_NR; backend++)
+ {
+ if (runtime[backend] && gc_backend[backend].runtime_change)
+ (*gc_backend[backend].runtime_change) ();
+ }
+}
+
+
/* More or less Robust version of dgettext. It has the side effect of
switching the codeset to utf-8 because this is what we want to
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index fdd77c461..6f1fcbb54 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -1,5 +1,5 @@
/* gpgconf.c - Configuration utility for GnuPG
- * Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -47,7 +47,8 @@ enum cmd_and_opt_values
aApplyDefaults,
aListConfig,
aCheckConfig,
- aListDirs
+ aListDirs,
+ aReload
};
@@ -70,6 +71,7 @@ static ARGPARSE_OPTS opts[] =
N_("list global configuration file") },
{ aCheckConfig, "check-config", 256,
N_("check global configuration file") },
+ { aReload, "reload", 256, "@" },
{ 301, NULL, 0, N_("@\nOptions:\n ") },
@@ -176,6 +178,7 @@ main (int argc, char **argv)
case aApplyDefaults:
case aListConfig:
case aCheckConfig:
+ case aReload:
cmd = pargs.r_opt;
break;
@@ -233,6 +236,31 @@ main (int argc, char **argv)
}
break;
+ case aReload:
+ if (!fname)
+ {
+ /* Reload all. */
+ gc_component_reload (-1);
+ }
+ else
+ {
+ /* Reload given component. */
+ int idx;
+
+ idx = gc_component_find (fname);
+ if (idx < 0)
+ {
+ fputs (_("Component not found"), stderr);
+ putc ('\n', stderr);
+ exit (1);
+ }
+ else
+ {
+ gc_component_reload (idx);
+ }
+ }
+ break;
+
case aListConfig:
if (gc_process_gpgconf_conf (fname, 0, 0, get_outfp (&outfp)))
exit (1);
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 39d2d097b..be9172aa6 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, ...);
+/* Reload given component. */
+void gc_component_reload (int component);
+
/* List all components that are available. */
void gc_component_list_components (FILE *out);