mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Allow multiple --default-key options. Take the last available key.
* g10/getkey.c (parse_def_secret_key): New function. (get_seckey_default): Add parameter ctrl. Update callers. Use parse_def_secret_key to get the default secret key, if any. (getkey_byname): Likewise. (enum_secret_keys): Likewise. * g10/options.h (opt): Change def_secret_key's type from a char * to a strlist_t. * g10/gpg.c (main): When processing --default-key, add the key to OPT.DEF_SECRET_KEY. * g10/gpgv.c (get_session_key): Add parameter ctrl. Update callers. * g10/mainproc.c (proc_pubkey_enc): Likewise. (do_proc_packets): Likewise. * g10/pkclist.c (default_recipient): Likewise. * g10/pubkey-enc.c (get_session_key): Likewise. * g10/sign.c (clearsign_file): Likewise. (sign_symencrypt_file): Likewise. * g10/skclist.c (build_sk_list): Likewise. * g10/test-stubs.c (get_session_key): Likewise. -- Signed-off-by: Neal H. Walield <neal@g10code.com> GnuPG-bug-id: 806
This commit is contained in:
parent
1e94a672ef
commit
e16d7168c5
16 changed files with 145 additions and 53 deletions
|
@ -702,7 +702,7 @@ key_present_in_pk_list(PK_LIST pk_list, PKT_public_key *pk)
|
|||
* Return a malloced string with a default recipient if there is any
|
||||
*/
|
||||
static char *
|
||||
default_recipient(void)
|
||||
default_recipient(ctrl_t ctrl)
|
||||
{
|
||||
PKT_public_key *pk;
|
||||
byte fpr[MAX_FINGERPRINT_LEN+1];
|
||||
|
@ -715,7 +715,7 @@ default_recipient(void)
|
|||
if( !opt.def_recipient_self )
|
||||
return NULL;
|
||||
pk = xmalloc_clear( sizeof *pk );
|
||||
i = get_seckey_default (pk);
|
||||
i = get_seckey_default (ctrl, pk);
|
||||
if( i ) {
|
||||
free_public_key( pk );
|
||||
return NULL;
|
||||
|
@ -1010,7 +1010,7 @@ build_pk_list (ctrl_t ctrl,
|
|||
|
||||
if (pk_list)
|
||||
any_recipients = 1;
|
||||
def_rec = default_recipient();
|
||||
def_rec = default_recipient(ctrl);
|
||||
have_def_rec = !!def_rec;
|
||||
if ( !have_def_rec )
|
||||
tty_printf(_("You did not specify a user ID. (you may use \"-r\")\n"));
|
||||
|
@ -1153,7 +1153,7 @@ build_pk_list (ctrl_t ctrl,
|
|||
pk = NULL;
|
||||
}
|
||||
}
|
||||
else if ( !any_recipients && (def_rec = default_recipient()) )
|
||||
else if ( !any_recipients && (def_rec = default_recipient(ctrl)) )
|
||||
{
|
||||
/* We are in batch mode and have only a default recipient. */
|
||||
pk = xmalloc_clear( sizeof *pk );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue