aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-03-19 11:43:08 +0000
committerWerner Koch <[email protected]>2021-12-29 09:10:44 +0000
commit5934027115239cb7b39659f14f7a1dfecada6b76 (patch)
treece1f23c08df228987c0c07f5c0124cfb2a8e1652
parentgpgconf: Rewrite the gpgconf-comp module. (diff)
downloadgnupg-5934027115239cb7b39659f14f7a1dfecada6b76.tar.gz
gnupg-5934027115239cb7b39659f14f7a1dfecada6b76.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 <[email protected]> This is a backport from master (2.3).
-rw-r--r--tools/gpgconf-comp.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 582adf0aa..ba21bf423 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -681,7 +681,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);
@@ -702,7 +701,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);
}
@@ -713,7 +711,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. */
@@ -745,7 +742,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);
}
@@ -1536,6 +1532,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
const char *config_name;
gnupg_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. */
@@ -1814,6 +1811,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;
@@ -1893,6 +1901,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
}
xfree (line);
+ xfree (twopartconfig_name);
}