1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

* helptext.c, pkclist.c (do_we_trust): It is not possible to get here with

a revoked or expired key, so BUG() that case.  Remove question about
overriding revoked/expired.  Also --keyid-format-ify. (do_we_trust_pre):
Use print_pubkey_info() instead of printing the info ourselves.

* passphrase.c (passphrase_to_dek): Improve translatability of user ID
prompts.

* keylist.c (print_pubkey_info): Use the user ID the pk was selected by,
if any.
This commit is contained in:
David Shaw 2004-10-06 21:50:23 +00:00
parent 27b2c9356a
commit b1e2c5398f
5 changed files with 84 additions and 134 deletions

View File

@ -1,5 +1,18 @@
2004-10-06 David Shaw <dshaw@jabberwocky.com> 2004-10-06 David Shaw <dshaw@jabberwocky.com>
* helptext.c, pkclist.c (do_we_trust): It is not possible to get
here with a revoked or expired key, so BUG() that case. Remove
question about overriding revoked/expired. Also
--keyid-format-ify.
(do_we_trust_pre): Use print_pubkey_info() instead of printing the
info ourselves.
* passphrase.c (passphrase_to_dek): Improve translatability of
user ID prompts.
* keylist.c (print_pubkey_info): Use the user ID the pk was
selected by, if any.
* keyedit.c (sign_uids, ask_revoke_sig): Improve translatability * keyedit.c (sign_uids, ask_revoke_sig): Improve translatability
of user ID prompts. of user ID prompts.
(ask_revoke_sig, menu_revsig): Try and use common strings for (ask_revoke_sig, menu_revsig): Try and use common strings for

View File

@ -57,10 +57,6 @@ static struct helptexts { const char *key; const char *help; } helptexts[] = {
"ultimately trusted\n" "ultimately trusted\n"
)}, )},
{ "revoked_key.override", N_(
"If you want to use this revoked key anyway, answer \"yes\"."
)},
{ "untrusted_key.override", N_( { "untrusted_key.override", N_(
"If you want to use this untrusted key anyway, answer \"yes\"." "If you want to use this untrusted key anyway, answer \"yes\"."
)}, )},

View File

@ -137,6 +137,12 @@ print_pubkey_info (FILE *fp, PKT_public_key *pk)
char *p; char *p;
keyid_from_pk (pk, keyid); keyid_from_pk (pk, keyid);
/* If the pk was chosen by a particular user ID, that is the one to
print. */
if(pk->user_id)
p=utf8_to_native(pk->user_id->name,pk->user_id->len,0);
else
p=get_user_id_native(keyid); p=get_user_id_native(keyid);
if (fp) if (fp)

View File

@ -1133,15 +1133,13 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
information on that key. */ information on that key. */
if( keyid && !opt.batch && !next_pw && mode!=1 ) { if( keyid && !opt.batch && !next_pw && mode!=1 ) {
PKT_public_key *pk = m_alloc_clear( sizeof *pk ); PKT_public_key *pk = m_alloc_clear( sizeof *pk );
size_t n;
char *p; char *p;
tty_printf(_("\nYou need a passphrase to unlock the secret key for\n" p=get_user_id_native(keyid);
"user: \"") ); tty_printf("\n");
p = get_user_id( keyid, &n ); tty_printf(_("You need a passphrase to unlock the secret key for\n"
tty_print_utf8_string( p, n ); "user: \"%s\"\n"),p);
m_free(p); m_free(p);
tty_printf("\"\n");
if( !get_pubkey( pk, keyid ) ) { if( !get_pubkey( pk, keyid ) ) {
const char *s = pubkey_algo_to_string( pk->pubkey_algo ); const char *s = pubkey_algo_to_string( pk->pubkey_algo );

View File

@ -371,75 +371,37 @@ edit_ownertrust (PKT_public_key *pk, int mode )
* Returns: true if we trust. * Returns: true if we trust.
*/ */
static int static int
do_we_trust( PKT_public_key *pk, unsigned int *trustlevel ) do_we_trust( PKT_public_key *pk, unsigned int trustlevel )
{ {
unsigned int trustmask = 0; /* We should not be able to get here with a revoked or expired
key */
if(trustlevel & TRUST_FLAG_REVOKED
|| trustlevel & TRUST_FLAG_SUB_REVOKED
|| (trustlevel & TRUST_MASK) == TRUST_EXPIRED)
BUG();
/* FIXME: get_pubkey_byname already checks the validity and won't if( opt.trust_model==TM_ALWAYS )
* return keys which are either expired or revoked - so these {
* question here won't get triggered. We have to find a solution
* for this. It might make sense to have a function in getkey.c
* which does only the basic checks and returns even revoked and
* expired keys. This fnction could then also returhn a list of
* keys if the speicified name is ambiguous
*/
if( (*trustlevel & TRUST_FLAG_REVOKED) ) {
log_info(_("key %08lX: key has been revoked!\n"),
(ulong)keyid_from_pk( pk, NULL) );
show_revocation_reason( pk, 0 );
if( opt.batch )
return 0; /* no */
if( !cpr_get_answer_is_yes("revoked_key.override",
_("Use this key anyway? ")) )
return 0; /* no */
trustmask |= TRUST_FLAG_REVOKED;
}
if( (*trustlevel & TRUST_FLAG_SUB_REVOKED) ) {
log_info(_("key %08lX: subkey has been revoked!\n"),
(ulong)keyid_from_pk( pk, NULL) );
show_revocation_reason( pk, 0 );
if( opt.batch )
return 0;
if( !cpr_get_answer_is_yes("revoked_key.override",
_("Use this key anyway? ")) )
return 0;
trustmask |= TRUST_FLAG_SUB_REVOKED;
}
*trustlevel &= ~trustmask;
if( opt.trust_model==TM_ALWAYS ) {
if( opt.verbose ) if( opt.verbose )
log_info("No trust check due to --trust-model always option\n"); log_info("No trust check due to `--trust-model always' option\n");
return 1; return 1;
} }
switch( (*trustlevel & TRUST_MASK) ) { switch(trustlevel & TRUST_MASK)
case TRUST_EXPIRED: {
log_info(_("%08lX: key has expired\n"),
(ulong)keyid_from_pk( pk, NULL) );
return 0; /* no */
default: default:
log_error ("invalid trustlevel %u returned from validation layer\n", log_error ("invalid trustlevel %u returned from validation layer\n",
*trustlevel); trustlevel);
/* fall thru */ /* fall thru */
case TRUST_UNKNOWN: case TRUST_UNKNOWN:
case TRUST_UNDEFINED: case TRUST_UNDEFINED:
log_info(_("%08lX: There is no assurance this key belongs " log_info(_("%s: There is no assurance this key belongs"
"to the named user\n"),(ulong)keyid_from_pk( pk, NULL) ); " to the named user\n"),keystr_from_pk(pk));
return 0; /* no */
/* No way to get here? */
case TRUST_NEVER:
log_info(_("%08lX: We do NOT trust this key\n"),
(ulong)keyid_from_pk( pk, NULL) );
return 0; /* no */ return 0; /* no */
case TRUST_MARGINAL: case TRUST_MARGINAL:
log_info(_("%08lX: There is limited assurance this key belongs " log_info(_("%s: There is limited assurance this key belongs"
"to the named user\n"),(ulong)keyid_from_pk(pk,NULL)); " to the named user\n"),keystr_from_pk(pk));
return 1; /* yes */ return 1; /* yes */
case TRUST_FULLY: case TRUST_FULLY:
@ -457,7 +419,6 @@ do_we_trust( PKT_public_key *pk, unsigned int *trustlevel )
} }
/**************** /****************
* wrapper around do_we_trust, so we can ask whether to use the * wrapper around do_we_trust, so we can ask whether to use the
* key anyway. * key anyway.
@ -467,39 +428,20 @@ do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
{ {
int rc; int rc;
rc = do_we_trust( pk, &trustlevel ); rc = do_we_trust( pk, trustlevel );
if( (trustlevel & TRUST_FLAG_REVOKED) && !rc ) if( !opt.batch && !rc )
return 0;
if( (trustlevel & TRUST_FLAG_SUB_REVOKED) && !rc )
return 0;
if( !opt.batch && !rc ) {
u32 keyid[2];
keyid_from_pk( pk, keyid);
tty_printf( "%4u%c/%08lX %s \"",
nbits_from_pk( pk ), pubkey_letter( pk->pubkey_algo ),
(ulong)keyid[1], datestr_from_pk( pk ) );
/* If the pk was chosen by a particular user ID, this is the
one to ask about. */
if(pk->user_id)
tty_print_utf8_string(pk->user_id->name,pk->user_id->len);
else
{ {
size_t n; print_pubkey_info(NULL,pk);
char *p = get_user_id( keyid, &n );
tty_print_utf8_string( p, n );
m_free(p);
}
tty_printf("\"\n");
print_fingerprint (pk, NULL, 2); print_fingerprint (pk, NULL, 2);
tty_printf("\n"); tty_printf("\n");
tty_printf(_( tty_printf(
"It is NOT certain that the key belongs to the person named\n" _("It is NOT certain that the key belongs to the person named\n"
"in the user ID. If you *really* know what you are doing,\n" "in the user ID. If you *really* know what you are doing,\n"
"you may answer the next question with yes\n\n")); "you may answer the next question with yes.\n"));
tty_printf("\n");
if( cpr_get_answer_is_yes("untrusted_key.override", if( cpr_get_answer_is_yes("untrusted_key.override",
_("Use this key anyway? ")) ) _("Use this key anyway? ")) )
@ -509,16 +451,11 @@ do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
* his decision the next time he encrypts for this recipient? * his decision the next time he encrypts for this recipient?
*/ */
} }
else if( opt.trust_model==TM_ALWAYS && !rc ) {
if( !opt.quiet )
log_info(_("WARNING: Using untrusted key!\n"));
rc = 1;
}
return rc; return rc;
} }
/**************** /****************
* Check whether we can trust this signature. * Check whether we can trust this signature.
* Returns: Error if we shall not trust this signatures. * Returns: Error if we shall not trust this signatures.