From e051c279216ecd4ec9a48e13ccc695f5ab667b2a Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 11 Jun 2018 18:33:26 -0400 Subject: [PATCH] gpg: set full --dry-run when used with --show-keys * g10/gpg.c (main): ensure that opt.dry_run matches opt.import_options[IMPORT_DRY_RUN]. -- It seems that the import_options IMPORT_DRY_RUN bit doesn't have the same power as the opt.dry_run bit itself. When one is set or cleared by command-line options or other option parsing, we should ensure that the other is also set or cleared. It would probably be cleaner to have just a single bit, stored in a single place, but that kind of overhaul is beyond the scope of this bugfix. GnuPG-Bug-id: 4017 Signed-off-by: Daniel Kahn Gillmor --- g10/gpg.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/g10/gpg.c b/g10/gpg.c index c117de375..4f4aae79c 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -2609,6 +2609,7 @@ main (int argc, char **argv) set_cmd (&cmd, pargs.r_opt); opt.import_options |= IMPORT_SHOW; opt.import_options |= IMPORT_DRY_RUN; + opt.dry_run = 1; opt.import_options &= ~IMPORT_REPAIR_KEYS; opt.list_options |= LIST_SHOW_UNUSABLE_UIDS; opt.list_options |= LIST_SHOW_UNUSABLE_SUBKEYS; @@ -2647,7 +2648,10 @@ main (int argc, char **argv) case oQuiet: opt.quiet = 1; break; case oNoTTY: tty_no_terminal(1); break; - case oDryRun: opt.dry_run = 1; break; + case oDryRun: + opt.dry_run = 1; + opt.import_options |= IMPORT_DRY_RUN; + break; case oInteractive: opt.interactive = 1; break; case oVerbose: opt.verbose++; @@ -3208,14 +3212,19 @@ main (int argc, char **argv) } break; case oImportOptions: - if(!parse_import_options(pargs.r.ret_str,&opt.import_options,1)) - { - if(configname) - log_error(_("%s:%d: invalid import options\n"), - configname,configlineno); - else - log_error(_("invalid import options\n")); - } + { + unsigned int old_import_options = opt.import_options; + if(!parse_import_options(pargs.r.ret_str,&opt.import_options,1)) + { + if(configname) + log_error(_("%s:%d: invalid import options\n"), + configname,configlineno); + else + log_error(_("invalid import options\n")); + } + if ((old_import_options & IMPORT_DRY_RUN) != (opt.import_options & IMPORT_DRY_RUN)) + opt.dry_run = !!(opt.import_options & IMPORT_DRY_RUN); + } break; case oImportFilter: rc = parse_and_set_import_filter (pargs.r.ret_str);