From b8e317c2a634907810564598cde8cf691ef03d88 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 16 Sep 2022 07:45:18 +0900 Subject: Imported Upstream version 2.3.1 --- agent/gpg-agent.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'agent/gpg-agent.c') diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 74c2108..0a9e903 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -59,6 +59,7 @@ #include "../common/gc-opt-flags.h" #include "../common/exechelp.h" #include "../common/asshelp.h" +#include "../common/comopt.h" #include "../common/init.h" @@ -1317,6 +1318,13 @@ main (int argc, char **argv) finalize_rereadable_options (); + /* Get a default log file from common.conf. */ + if (!logfile && !parse_comopt (GNUPG_MODULE_NAME_AGENT, debug_argparser)) + { + logfile = comopt.logfile; + comopt.logfile = NULL; + } + /* Print a warning if an argument looks like an option. */ if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN)) { @@ -1986,6 +1994,7 @@ reread_configuration (void) gpgrt_argparse_t pargs; char *twopart; int dummy; + int logfile_seen = 0; if (!config_filename) return; /* No config file. */ @@ -2013,12 +2022,29 @@ reread_configuration (void) else if (pargs.r_opt < -1) pargs.err = ARGPARSE_PRINT_WARNING; else /* Try to parse this option - ignore unchangeable ones. */ - parse_rereadable_options (&pargs, 1); + { + if (pargs.r_opt == oLogFile) + logfile_seen = 1; + parse_rereadable_options (&pargs, 1); + } } gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ xfree (twopart); + finalize_rereadable_options (); set_debug (); + + /* Get a default log file from common.conf. */ + if (!logfile_seen && !parse_comopt (GNUPG_MODULE_NAME_AGENT, !!opt.debug)) + { + if (!current_logfile || !comopt.logfile + || strcmp (current_logfile, comopt.logfile)) + { + log_set_file (comopt.logfile); + xfree (current_logfile); + current_logfile = comopt.logfile? xtrystrdup (comopt.logfile) : NULL; + } + } } -- cgit v1.2.3