diff options
author | Werner Koch <[email protected]> | 2014-04-08 13:55:51 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-04-08 13:57:14 +0000 |
commit | b4cf4686f7349be9558217f20e51157398cd88a0 (patch) | |
tree | ed04e4493fc4a55697cd83a189592e0522f0ccd1 /tools/gpgconf-comp.c | |
parent | scd: Silent compiler warnings about unused variables. (diff) | |
download | gnupg-b4cf4686f7349be9558217f20e51157398cd88a0.tar.gz gnupg-b4cf4686f7349be9558217f20e51157398cd88a0.zip |
gpgconf: Add command --launch.
* tools/gpgconf.c: Add command --launch.
* tools/gpgconf-comp.c (gc_component_launch): New.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/gpgconf-comp.c')
-rw-r--r-- | tools/gpgconf-comp.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c index 356b25126..65c116b7d 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) |