From d13c5bc244ce1daed285424d920171fc2bcd7290 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 19 Apr 2021 11:33:19 +0200 Subject: gpg,gpgsm: Move use-keyboxd to the new conf file common.conf * common/comopt.c, common/comopt.h: New. * common/Makefile.am: Add them. * g10/gpg.c: Include comopt.h. (main): Also parse common.conf. * sm/gpgsm.c: Include comopt.h. (main): Set a flag for the --no-logfile option. Parse common.conf. * tools/gpgconf-comp.c (known_options_gpg): Remove "use-keyboxd", add pseudo option "use_keyboxd". (known_pseudo_options_gpg): Add pseudo option "use_keyboxd". (known_options_gpgsm): Remove "use-keyboxd". * tests/openpgp/defs.scm (create-gpghome): Create common.conf. * doc/examples/common.conf: New. -- Note that --use-keybox still works but prints a warning. We will eventually remove this option becuase it was marked as an experimental feature anyway. It would be too confusing if gpg and gpgsm use different key storages. Further, other components (e.g. dirmngr or gpg-wks-client) which call gpg or gpgsm need to be aware that the keyboxd is used and pass that option on the command line. Now that common.conf is always read (even if --no-options is used) those tools will work instantly. --- sm/gpgsm.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'sm/gpgsm.c') diff --git a/sm/gpgsm.c b/sm/gpgsm.c index fd59fc7c7..e292aa160 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -1,7 +1,7 @@ /* gpgsm.c - GnuPG for S/MIME * Copyright (C) 2001-2020 Free Software Foundation, Inc. * Copyright (C) 2001-2019 Werner Koch - * Copyright (C) 2015-2020 g10 Code GmbH + * Copyright (C) 2015-2021 g10 Code GmbH * * This file is part of GnuPG. * @@ -47,6 +47,7 @@ #include "../common/asshelp.h" #include "../common/init.h" #include "../common/compliance.h" +#include "../common/comopt.h" #include "minip12.h" #ifndef O_BINARY @@ -1005,6 +1006,7 @@ main ( int argc, char **argv) estream_t htmlauditfp = NULL; struct assuan_malloc_hooks malloc_hooks; int pwfd = -1; + int no_logfile = 0; static const char *homedirvalue; static const char *changeuser; @@ -1354,7 +1356,7 @@ main ( int argc, char **argv) break; case oLogFile: logfile = pargs.r.ret_str; break; - case oNoLogFile: logfile = NULL; break; + case oNoLogFile: logfile = NULL; no_logfile = 1; break; case oAuditLog: auditlog = pargs.r.ret_str; break; case oHtmlAuditLog: htmlauditlog = pargs.r.ret_str; break; @@ -1613,6 +1615,34 @@ main ( int argc, char **argv) gpgsm_exit(2); } + /* Process common component options. */ + if (parse_comopt (GNUPG_MODULE_NAME_GPGSM, debug_argparser)) + { + gpgsm_status_with_error (&ctrl, STATUS_FAILURE, + "option-parser", gpg_error (GPG_ERR_GENERAL)); + gpgsm_exit(2); + } + + if (!logfile && !no_logfile) + { + logfile = comopt.logfile; + comopt.logfile = NULL; + } + + if (opt.use_keyboxd) + log_info ("Note: Please move option \"%s\" to \"common.conf\"\n", + "use-keyboxd"); + opt.use_keyboxd = comopt.use_keyboxd; /* Override. */ + + if (opt.keyboxd_program) + log_info ("Note: Please move option \"%s\" to \"common.conf\"\n", + "keyboxd-program"); + if (!opt.keyboxd_program && comopt.keyboxd_program) + { + opt.keyboxd_program = comopt.keyboxd_program; + comopt.keyboxd_program = NULL; + } + if (pwfd != -1) /* Read the passphrase now. */ read_passphrase_from_fd (pwfd); -- cgit v1.2.3