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 <dkg@fifthhorseman.net>
This commit is contained in:
Daniel Kahn Gillmor 2018-06-11 18:33:26 -04:00
parent dc96fd8835
commit e051c27921
1 changed files with 18 additions and 9 deletions

View File

@ -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);