summaryrefslogtreecommitdiffstats
path: root/tools/gpgconf-comp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-03-19 12:43:08 +0100
committerWerner Koch <wk@gnupg.org>2020-03-19 12:43:08 +0100
commitc1844ca7520f9a67bff85ee4fbf49c6725668289 (patch)
tree4b97a388639c51e17b74d23fa0b6b7925ec1296e /tools/gpgconf-comp.c
parentgpg: Also allow a v5 fingerprint for --trusted-key. (diff)
downloadgnupg2-c1844ca7520f9a67bff85ee4fbf49c6725668289.tar.xz
gnupg2-c1844ca7520f9a67bff85ee4fbf49c6725668289.zip
gpgconf: Take care of --homedir when reading/updating options.
* tools/gpgconf-comp.c (gpg_agent_runtime_change): Remove unused var. (scdaemon_runtime_change): Ditto. (dirmngr_runtime_change): Ditto. (gc_component_check_options): Pass --homedir if needed. (retrieve_options_from_program): Take care of --homedir. -- This is related to bug 4882 but different due all the code changes. GnuPG-bug-id: 4882 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tools/gpgconf-comp.c')
-rw-r--r--tools/gpgconf-comp.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 1643eb94c..c757d41bb 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -676,7 +676,6 @@ gpg_agent_runtime_change (int killflag)
const char *pgmname;
const char *argv[5];
pid_t pid = (pid_t)(-1);
- char *abs_homedir = NULL;
int i = 0;
pgmname = gnupg_module_name (GNUPG_MODULE_NAME_CONNECT_AGENT);
@@ -697,7 +696,6 @@ gpg_agent_runtime_change (int killflag)
gc_error (0, 0, "error running '%s %s': %s",
pgmname, argv[1], gpg_strerror (err));
gnupg_release_process (pid);
- xfree (abs_homedir);
}
@@ -708,7 +706,6 @@ scdaemon_runtime_change (int killflag)
const char *pgmname;
const char *argv[9];
pid_t pid = (pid_t)(-1);
- char *abs_homedir = NULL;
int i = 0;
(void)killflag; /* For scdaemon kill and reload are synonyms. */
@@ -740,7 +737,6 @@ scdaemon_runtime_change (int killflag)
gc_error (0, 0, "error running '%s %s': %s",
pgmname, argv[4], gpg_strerror (err));
gnupg_release_process (pid);
- xfree (abs_homedir);
}
@@ -751,7 +747,6 @@ dirmngr_runtime_change (int killflag)
const char *pgmname;
const char *argv[6];
pid_t pid = (pid_t)(-1);
- char *abs_homedir = NULL;
pgmname = gnupg_module_name (GNUPG_MODULE_NAME_CONNECT_AGENT);
argv[0] = "--no-autostart";
@@ -774,7 +769,6 @@ dirmngr_runtime_change (int killflag)
gc_error (0, 0, "error running '%s %s': %s",
pgmname, argv[2], gpg_strerror (err));
gnupg_release_process (pid);
- xfree (abs_homedir);
}
@@ -1170,7 +1164,7 @@ gc_component_check_options (int component, estream_t out, const char *conf_file)
gpg_error_t err;
unsigned int result;
const char *pgmname;
- const char *argv[4];
+ const char *argv[5];
int i;
pid_t pid;
int exitcode;
@@ -1186,6 +1180,12 @@ gc_component_check_options (int component, estream_t out, const char *conf_file)
pgmname = gnupg_module_name (gc_component[component].module_name);
i = 0;
+ if (!gnupg_default_homedir_p ()
+ && component != GC_COMPONENT_PINENTRY)
+ {
+ argv[i++] = "--homedir";
+ argv[i++] = gnupg_homedir ();
+ }
if (conf_file)
{
argv[i++] = "--options";
@@ -1517,6 +1517,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
const char *config_name;
gpgrt_argparse_t pargs;
int dummy_argc;
+ char *twopartconfig_name = NULL;
gpgrt_opt_t *opt_table = NULL; /* A malloced option table. */
size_t opt_table_used = 0; /* Its current length. */
size_t opt_table_size = 0; /* Its allocated length. */
@@ -1797,6 +1798,17 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
if (!config_name)
gc_error (1, 0, "name of config file for %s is not known\n", pgmname);
+ if (!gnupg_default_homedir_p ())
+ {
+ /* This is not the default homedir. We need to take an absolute
+ * config name for the user config file; gpgrt_argparser
+ * fortunately supports this. */
+ char *tmp = make_filename (gnupg_homedir (), config_name, NULL);
+ twopartconfig_name = xstrconcat (config_name, PATHSEP_S, tmp, NULL);
+ xfree (tmp);
+ config_name = twopartconfig_name;
+ }
+
memset (&pargs, 0, sizeof pargs);
dummy_argc = 0;
pargs.argc = &dummy_argc;
@@ -1876,6 +1888,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
}
xfree (line);
+ xfree (twopartconfig_name);
}