mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Pass CTRL to many more functions.
-- For proper operations as a server we need to avoid global variables. Thus we need to pass the session state CTRL to most functions. Quite a lot of changes but fortunately straightforward to do. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
5e89144cbc
commit
8f2671d2cc
38 changed files with 885 additions and 751 deletions
|
@ -110,7 +110,7 @@ do_show_revocation_reason( PKT_signature *sig )
|
|||
subkeys, etc.) Mode 1: use only the revocation on the main pk */
|
||||
|
||||
void
|
||||
show_revocation_reason( PKT_public_key *pk, int mode )
|
||||
show_revocation_reason (ctrl_t ctrl, PKT_public_key *pk, int mode)
|
||||
{
|
||||
/* Hmmm, this is not so easy because we have to duplicate the code
|
||||
* used in the trustbd to calculate the keyflags. We need to find
|
||||
|
@ -127,7 +127,7 @@ show_revocation_reason( PKT_public_key *pk, int mode )
|
|||
|
||||
/* get the keyblock */
|
||||
fingerprint_from_pk( pk, fingerprint, &fingerlen );
|
||||
rc = get_pubkey_byfprint(NULL, &keyblock, fingerprint, fingerlen);
|
||||
rc = get_pubkey_byfprint (ctrl, NULL, &keyblock, fingerprint, fingerlen);
|
||||
if( rc ) { /* that should never happen */
|
||||
log_debug( "failed to get the keyblock\n");
|
||||
return;
|
||||
|
@ -160,7 +160,7 @@ show_revocation_reason( PKT_public_key *pk, int mode )
|
|||
|
||||
/* We didn't find it, so check if the whole key is revoked */
|
||||
if(!node && !mode)
|
||||
show_revocation_reason(pk,1);
|
||||
show_revocation_reason (ctrl, pk, 1);
|
||||
|
||||
release_kbnode( keyblock );
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ do_edit_ownertrust (ctrl_t ctrl, PKT_public_key *pk, int mode,
|
|||
int show=0;
|
||||
int min_num;
|
||||
int did_help=defer_help;
|
||||
unsigned int minimum = tdb_get_min_ownertrust (pk, 0);
|
||||
unsigned int minimum = tdb_get_min_ownertrust (ctrl, pk, 0);
|
||||
|
||||
switch(minimum)
|
||||
{
|
||||
|
@ -222,13 +222,13 @@ do_edit_ownertrust (ctrl_t ctrl, PKT_public_key *pk, int mode,
|
|||
KBNODE keyblock, un;
|
||||
|
||||
tty_printf (_("No trust value assigned to:\n"));
|
||||
print_key_line (NULL, pk, 0);
|
||||
print_key_line (ctrl, NULL, pk, 0);
|
||||
|
||||
p = get_user_id_native(keyid);
|
||||
p = get_user_id_native (ctrl, keyid);
|
||||
tty_printf (_(" \"%s\"\n"),p);
|
||||
xfree (p);
|
||||
|
||||
keyblock = get_pubkeyblock (keyid);
|
||||
keyblock = get_pubkeyblock (ctrl, keyid);
|
||||
if (!keyblock)
|
||||
BUG ();
|
||||
for (un=keyblock; un; un = un->next)
|
||||
|
@ -257,7 +257,7 @@ do_edit_ownertrust (ctrl_t ctrl, PKT_public_key *pk, int mode,
|
|||
tty_printf(_(" aka \"%s\"\n"),p);
|
||||
}
|
||||
|
||||
print_fingerprint (NULL, pk, 2);
|
||||
print_fingerprint (ctrl, NULL, pk, 2);
|
||||
tty_printf("\n");
|
||||
release_kbnode (keyblock);
|
||||
}
|
||||
|
@ -391,8 +391,8 @@ edit_ownertrust (ctrl_t ctrl, PKT_public_key *pk, int mode )
|
|||
break;
|
||||
case 1: /* trust value set */
|
||||
trust &= ~TRUST_FLAG_DISABLED;
|
||||
trust |= get_ownertrust (pk) & TRUST_FLAG_DISABLED;
|
||||
update_ownertrust (pk, trust );
|
||||
trust |= get_ownertrust (ctrl, pk) & TRUST_FLAG_DISABLED;
|
||||
update_ownertrust (ctrl, pk, trust );
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -467,7 +467,7 @@ do_we_trust( PKT_public_key *pk, unsigned int trustlevel )
|
|||
* key anyway.
|
||||
*/
|
||||
static int
|
||||
do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
|
||||
do_we_trust_pre (ctrl_t ctrl, PKT_public_key *pk, unsigned int trustlevel )
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
@ -475,8 +475,8 @@ do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
|
|||
|
||||
if( !opt.batch && !rc )
|
||||
{
|
||||
print_pubkey_info(NULL,pk);
|
||||
print_fingerprint (NULL, pk, 2);
|
||||
print_pubkey_info (ctrl, NULL,pk);
|
||||
print_fingerprint (ctrl, NULL, pk, 2);
|
||||
tty_printf("\n");
|
||||
|
||||
if ((trustlevel & TRUST_MASK) == TRUST_NEVER)
|
||||
|
@ -499,7 +499,7 @@ do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
|
|||
char *hint_str;
|
||||
|
||||
keyid_from_pk (pk, kid);
|
||||
hint_str = get_long_user_id_string ( kid );
|
||||
hint_str = get_long_user_id_string (ctrl, kid);
|
||||
write_status_text ( STATUS_USERID_HINT, hint_str );
|
||||
xfree (hint_str);
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
unsigned int trustlevel = TRUST_UNKNOWN;
|
||||
int rc=0;
|
||||
|
||||
rc = get_pubkey( pk, sig->keyid );
|
||||
rc = get_pubkey (ctrl, pk, sig->keyid );
|
||||
if (rc)
|
||||
{ /* this should not happen */
|
||||
log_error("Ooops; the key vanished - can't check the trust\n");
|
||||
|
@ -561,7 +561,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
if( !opt.quiet )
|
||||
log_info(_("WARNING: Using untrusted key!\n"));
|
||||
if (opt.with_fingerprint)
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
@ -580,13 +580,13 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
else
|
||||
log_info(_("WARNING: This key has been revoked by its owner!\n"));
|
||||
log_info(_(" This could mean that the signature is forged.\n"));
|
||||
show_revocation_reason( pk, 0 );
|
||||
show_revocation_reason (ctrl, pk, 0);
|
||||
}
|
||||
else if ((trustlevel & TRUST_FLAG_SUB_REVOKED) )
|
||||
{
|
||||
write_status( STATUS_KEYREVOKED );
|
||||
log_info(_("WARNING: This subkey has been revoked by its owner!\n"));
|
||||
show_revocation_reason( pk, 0 );
|
||||
show_revocation_reason (ctrl, pk, 0);
|
||||
}
|
||||
|
||||
if ((trustlevel & TRUST_FLAG_DISABLED))
|
||||
|
@ -602,7 +602,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
|
||||
|
||||
primary_pk = xmalloc_clear (sizeof *primary_pk);
|
||||
get_pubkey (primary_pk, pk->main_keyid);
|
||||
get_pubkey (ctrl, primary_pk, pk->main_keyid);
|
||||
fingerprint_from_pk (primary_pk, fpr, &fprlen);
|
||||
free_public_key (primary_pk);
|
||||
|
||||
|
@ -649,7 +649,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
{
|
||||
case TRUST_EXPIRED:
|
||||
log_info(_("Note: This key has expired!\n"));
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -663,7 +663,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
" a trusted signature!\n"));
|
||||
log_info(_(" There is no indication that the "
|
||||
"signature belongs to the owner.\n" ));
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
break;
|
||||
|
||||
case TRUST_NEVER:
|
||||
|
@ -673,7 +673,7 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
log_info(_("WARNING: We do NOT trust this key!\n"));
|
||||
log_info(_(" The signature is probably a FORGERY.\n"));
|
||||
if (opt.with_fingerprint)
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
rc = gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
break;
|
||||
|
||||
|
@ -683,19 +683,19 @@ check_signatures_trust (ctrl_t ctrl, PKT_signature *sig)
|
|||
" sufficiently trusted signatures!\n"));
|
||||
log_info(_(" It is not certain that the"
|
||||
" signature belongs to the owner.\n" ));
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
break;
|
||||
|
||||
case TRUST_FULLY:
|
||||
write_trust_status (STATUS_TRUST_FULLY, trustlevel);
|
||||
if (opt.with_fingerprint)
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
break;
|
||||
|
||||
case TRUST_ULTIMATE:
|
||||
write_trust_status (STATUS_TRUST_ULTIMATE, trustlevel);
|
||||
if (opt.with_fingerprint)
|
||||
print_fingerprint (NULL, pk, 1);
|
||||
print_fingerprint (ctrl, NULL, pk, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -882,7 +882,7 @@ find_and_check_key (ctrl_t ctrl, const char *name, unsigned int use,
|
|||
return GPG_ERR_UNUSABLE_PUBKEY;
|
||||
}
|
||||
|
||||
if ( !do_we_trust_pre (pk, trustlevel) )
|
||||
if ( !do_we_trust_pre (ctrl, pk, trustlevel) )
|
||||
{
|
||||
/* We don't trust this key. */
|
||||
send_status_inv_recp (10, name);
|
||||
|
@ -1151,8 +1151,8 @@ build_pk_list (ctrl_t ctrl, strlist_t rcpts, PK_LIST *ret_pk_list)
|
|||
else
|
||||
{
|
||||
size_t n;
|
||||
char *p = get_user_id( keyid, &n );
|
||||
tty_print_utf8_string( p, n );
|
||||
char *p = get_user_id (ctrl, keyid, &n );
|
||||
tty_print_utf8_string ( p, n );
|
||||
xfree(p);
|
||||
}
|
||||
tty_printf("\"\n");
|
||||
|
@ -1218,7 +1218,7 @@ build_pk_list (ctrl_t ctrl, strlist_t rcpts, PK_LIST *ret_pk_list)
|
|||
{
|
||||
tty_printf (_("Public key is disabled.\n") );
|
||||
}
|
||||
else if ( do_we_trust_pre (pk, trustlevel) )
|
||||
else if ( do_we_trust_pre (ctrl, pk, trustlevel) )
|
||||
{
|
||||
/* Skip the actual key if the key is already
|
||||
* present in the list */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue