1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-03 12:11:33 +01:00

* keygen.c (keygen_get_std_prefs): Set reference count when creating the

temporary user ID.

* keyedit.c (keyedit_menu): Merge updpref and setpref.  Keep updpref as an
invisible alias.  Add invisible alias for revphoto. Fix small memory leak
when using "setpref" (not all of the uid was freed). (menu_revkey):
Trigger a trust rebuild after revoking a key. Don't allow revoking an
already-revoked whole key. (menu_revsubkey): Don't allow revoking an
already-revoked subkey.
This commit is contained in:
David Shaw 2004-12-19 05:20:07 +00:00
parent 06c27b8a38
commit 1e487ab1d6
3 changed files with 61 additions and 28 deletions

View File

@ -1,3 +1,16 @@
2004-12-19 David Shaw <dshaw@jabberwocky.com>
* keygen.c (keygen_get_std_prefs): Set reference count when
creating the temporary user ID.
* keyedit.c (keyedit_menu): Merge updpref and setpref. Keep
updpref as an invisible alias. Add invisible alias for revphoto.
Fix small memory leak when using "setpref" (not all of the uid was
freed).
(menu_revkey): Trigger a trust rebuild after revoking a key.
Don't allow revoking an already-revoked whole key.
(menu_revsubkey): Don't allow revoking an already-revoked subkey.
2004-12-18 David Shaw <dshaw@jabberwocky.com> 2004-12-18 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (menu_revkey): Rename to menu_revsubkey. * keyedit.c (menu_revkey): Rename to menu_revsubkey.

View File

@ -1272,8 +1272,8 @@ keyedit_menu( const char *username, STRLIST locusr,
cmdSAVE, cmdADDUID, cmdADDPHOTO, cmdDELUID, cmdADDKEY, cmdDELKEY, cmdSAVE, cmdADDUID, cmdADDPHOTO, cmdDELUID, cmdADDKEY, cmdDELKEY,
cmdADDREVOKER, cmdTOGGLE, cmdSELKEY, cmdPASSWD, cmdTRUST, cmdPREF, cmdADDREVOKER, cmdTOGGLE, cmdSELKEY, cmdPASSWD, cmdTRUST, cmdPREF,
cmdEXPIRE, cmdENABLEKEY, cmdDISABLEKEY, cmdSHOWPREF, cmdSETPREF, cmdEXPIRE, cmdENABLEKEY, cmdDISABLEKEY, cmdSHOWPREF, cmdSETPREF,
cmdUPDPREF, cmdPREFKS, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST, cmdPREFKS, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST, cmdCHKTRUST,
cmdCHKTRUST, cmdADDCARDKEY, cmdKEYTOCARD, cmdADDCARDKEY, cmdKEYTOCARD,
cmdNOP }; cmdNOP };
static struct static struct
{ {
@ -1298,7 +1298,8 @@ keyedit_menu( const char *username, STRLIST locusr,
{ "sign" , cmdSIGN , KEYEDIT_NOT_SK|KEYEDIT_TAIL_MATCH, N_("sign the key") }, { "sign" , cmdSIGN , KEYEDIT_NOT_SK|KEYEDIT_TAIL_MATCH, N_("sign the key") },
{ "s" , cmdSIGN , KEYEDIT_NOT_SK, NULL }, { "s" , cmdSIGN , KEYEDIT_NOT_SK, NULL },
/* "lsign" will never match since "sign" comes first and it is a /* "lsign" will never match since "sign" comes first and it is a
tail match. It is here so it shows up in the help menu. */ tail match. It is just here so it shows up in the help
menu. */
{ "lsign" , cmdNOP , 0, N_("sign the key locally") }, { "lsign" , cmdNOP , 0, N_("sign the key locally") },
{ "debug" , cmdDEBUG , 0, NULL }, { "debug" , cmdDEBUG , 0, NULL },
{ "adduid" , cmdADDUID , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("add a user ID") }, { "adduid" , cmdADDUID , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("add a user ID") },
@ -1321,12 +1322,15 @@ keyedit_menu( const char *username, STRLIST locusr,
{ "pref" , cmdPREF , KEYEDIT_NOT_SK, N_("list preferences (expert)")}, { "pref" , cmdPREF , KEYEDIT_NOT_SK, N_("list preferences (expert)")},
{ "showpref", cmdSHOWPREF , KEYEDIT_NOT_SK, N_("list preferences (verbose)") }, { "showpref", cmdSHOWPREF , KEYEDIT_NOT_SK, N_("list preferences (verbose)") },
{ "setpref" , cmdSETPREF , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("set preference list") }, { "setpref" , cmdSETPREF , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("set preference list") },
{ "updpref" , cmdUPDPREF , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("updated preferences") }, /* Alias */
{ "updpref" , cmdSETPREF , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, NULL },
{ "keyserver",cmdPREFKS , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("set preferred keyserver URL")}, { "keyserver",cmdPREFKS , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("set preferred keyserver URL")},
{ "passwd" , cmdPASSWD , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("change the passphrase") }, { "passwd" , cmdPASSWD , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("change the passphrase") },
{ "trust" , cmdTRUST , KEYEDIT_NOT_SK, N_("change the ownertrust") }, { "trust" , cmdTRUST , KEYEDIT_NOT_SK, N_("change the ownertrust") },
{ "revsig" , cmdREVSIG , KEYEDIT_NOT_SK, N_("revoke signatures") }, { "revsig" , cmdREVSIG , KEYEDIT_NOT_SK, N_("revoke signatures") },
{ "revuid" , cmdREVUID , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("revoke a user ID") }, { "revuid" , cmdREVUID , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("revoke a user ID") },
/* Alias */
{ "revphoto", cmdREVUID , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, NULL },
{ "revkey" , cmdREVKEY , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("revoke a secondary key") }, { "revkey" , cmdREVKEY , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("revoke a secondary key") },
{ "disable" , cmdDISABLEKEY, KEYEDIT_NOT_SK, N_("disable a key") }, { "disable" , cmdDISABLEKEY, KEYEDIT_NOT_SK, N_("disable a key") },
{ "enable" , cmdENABLEKEY , KEYEDIT_NOT_SK, N_("enable a key") }, { "enable" , cmdENABLEKEY , KEYEDIT_NOT_SK, N_("enable a key") },
@ -1784,13 +1788,14 @@ keyedit_menu( const char *username, STRLIST locusr,
break; break;
case cmdEXPIRE: case cmdEXPIRE:
if( menu_expire( keyblock, sec_keyblock ) ) { if( menu_expire( keyblock, sec_keyblock ) )
{
merge_keys_and_selfsig( sec_keyblock ); merge_keys_and_selfsig( sec_keyblock );
merge_keys_and_selfsig( keyblock ); merge_keys_and_selfsig( keyblock );
sec_modified = 1; sec_modified = 1;
modified = 1; modified = 1;
redisplay = 1; redisplay = 1;
} }
break; break;
case cmdPRIMARY: case cmdPRIMARY:
@ -1835,30 +1840,30 @@ keyedit_menu( const char *username, STRLIST locusr,
break; break;
case cmdSETPREF: case cmdSETPREF:
keygen_set_std_prefs ( !*arg_string? "default" : arg_string, 0); {
break; PKT_user_id *tempuid;
case cmdUPDPREF: keygen_set_std_prefs(!*arg_string?"default" : arg_string, 0);
{
PKT_user_id *temp=keygen_get_std_prefs(); tempuid=keygen_get_std_prefs();
tty_printf(_("Set preference list to:\n")); tty_printf(_("Set preference list to:\n"));
show_prefs(temp,NULL,1); show_prefs(tempuid,NULL,1);
m_free(temp); free_user_id(tempuid);
}
if (cpr_get_answer_is_yes ("keyedit.updpref.okay",
count_selected_uids (keyblock)?
_("Really update the preferences"
" for the selected user IDs? (y/N) "):
_("Really update the preferences? (y/N) ")))
{
if ( menu_set_preferences (keyblock, sec_keyblock) ) if(cpr_get_answer_is_yes("keyedit.setpref.okay",
{ count_selected_uids (keyblock)?
merge_keys_and_selfsig (keyblock); _("Really update the preferences"
modified = 1; " for the selected user IDs? (y/N) "):
redisplay = 1; _("Really update the preferences? (y/N) ")))
} {
} if ( menu_set_preferences (keyblock, sec_keyblock) )
{
merge_keys_and_selfsig (keyblock);
modified = 1;
redisplay = 1;
}
}
}
break; break;
case cmdPREFKS: case cmdPREFKS:
@ -4093,6 +4098,12 @@ menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
PACKET *pkt; PACKET *pkt;
PKT_signature *sig; PKT_signature *sig;
if(pk->is_revoked)
{
tty_printf(_("Key %s is already revoked.\n"),keystr_from_pk(pk));
return 0;
}
reason = ask_revocation_reason( 1, 0, 0 ); reason = ask_revocation_reason( 1, 0, 0 );
/* user decided to cancel */ /* user decided to cancel */
if( !reason ) if( !reason )
@ -4117,7 +4128,7 @@ menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
insert_kbnode( pub_keyblock, new_kbnode(pkt), 0 ); insert_kbnode( pub_keyblock, new_kbnode(pkt), 0 );
commit_kbnode( &pub_keyblock ); commit_kbnode( &pub_keyblock );
/* TODO: set update_trust here? */ update_trust=1;
scram: scram:
release_revocation_reason_info( reason ); release_revocation_reason_info( reason );
@ -4149,6 +4160,13 @@ menu_revsubkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
PKT_public_key *subpk = node->pkt->pkt.public_key; PKT_public_key *subpk = node->pkt->pkt.public_key;
struct sign_attrib attrib; struct sign_attrib attrib;
if(subpk->is_revoked)
{
tty_printf(_("Subkey %s is already revoked.\n"),
keystr_from_pk(subpk));
continue;
}
memset( &attrib, 0, sizeof attrib ); memset( &attrib, 0, sizeof attrib );
attrib.reason = reason; attrib.reason = reason;

View File

@ -510,6 +510,8 @@ PKT_user_id *keygen_get_std_prefs(void)
if(!prefs_initialized) if(!prefs_initialized)
keygen_set_std_prefs(NULL,0); keygen_set_std_prefs(NULL,0);
uid->ref=1;
uid->prefs=m_alloc((sizeof(prefitem_t *)* uid->prefs=m_alloc((sizeof(prefitem_t *)*
(nsym_prefs+nhash_prefs+nzip_prefs+1))); (nsym_prefs+nhash_prefs+nzip_prefs+1)));