From 165bc38cefbc03515403b60b704cabf4dc0b71f4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 22 Mar 2018 10:23:00 +0100 Subject: [PATCH] gpg: Implement --dry-run for --passwd. * g10/keyedit.c (change_passphrase): Take care of --dry-run. Signed-off-by: Werner Koch --- doc/gpg.texi | 4 +++- g10/keyedit.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/gpg.texi b/doc/gpg.texi index e3c3662a8..ad044ffc0 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -1126,7 +1126,9 @@ all affected self-signatures is set one second ahead. @opindex passwd Change the passphrase of the secret key belonging to the certificate specified as @var{user-id}. This is a shortcut for the sub-command -@code{passwd} of the edit key menu. +@code{passwd} of the edit key menu. When using together with the +option @option{--dry-run} this will not actually change the passphrase +but check that the current passphrase is correct. @end table diff --git a/g10/keyedit.c b/g10/keyedit.c index 17cf7d6ea..4ade5cdba 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1134,8 +1134,10 @@ change_passphrase (ctrl_t ctrl, kbnode_t keyblock) if (err) goto leave; + /* Note that when using --dry-run we don't change the + * passphrase but merely verify the current passphrase. */ desc = gpg_format_keydesc (ctrl, pk, FORMAT_KEYDESC_NORMAL, 1); - err = agent_passwd (ctrl, hexgrip, desc, 0, + err = agent_passwd (ctrl, hexgrip, desc, !!opt.dry_run, &cache_nonce, &passwd_nonce); xfree (desc);