gpg: --delete-secret-key - check that a secret key exists.

* g10/delkey.c (do_delete_key): Check availibility of a secret key.
--

Actually we check that at least one secret subkey exists.
This commit is contained in:
Werner Koch 2014-09-18 16:00:34 +02:00
parent cf648fc5c8
commit 1d33d03f0b
1 changed files with 9 additions and 0 deletions

View File

@ -111,6 +111,15 @@ do_delete_key( const char *username, int secret, int force, int *r_sec_avail )
err = 0;
}
if (secret && !have_secret_key_with_kid (keyid))
{
err = gpg_error (GPG_ERR_NOT_FOUND);
log_error (_("key \"%s\" not found: %s\n"), username, gpg_strerror (err));
write_status_text (STATUS_DELETE_PROBLEM, "1");
goto leave;
}
if (opt.batch && exactmatch)
okay++;
else if (opt.batch && secret)