diff options
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r-- | g10/keyedit.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c index 017e53e0c..e1a0ab83a 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -2194,6 +2194,40 @@ show_key_and_fingerprint( KBNODE keyblock ) } +/* Show a warning if no uids on the key have the primary uid flag + set. */ +static void +no_primary_warning(KBNODE keyblock, int uids) +{ + KBNODE node; + int select_all=1,have_uid=0,uid_count=0; + + if(uids) + select_all=!count_selected_uids(keyblock); + + /* TODO: if we ever start behaving differently with a primary or + non-primary attribute ID, we will need to check for attributes + here as well. */ + + for(node=keyblock; node; node = node->next) + { + if(node->pkt->pkttype==PKT_USER_ID + && node->pkt->pkt.user_id->attrib_data==NULL) + { + uid_count++; + + if((select_all || (node->flag & NODFLG_SELUID)) + && node->pkt->pkt.user_id->is_primary==2) + have_uid|=2; + else + have_uid|=1; + } + } + + if(uid_count>1 && have_uid&1 && !(have_uid&2)) + log_info(_("WARNING: no user ID has been marked as primary. This command " + "may\n cause a different user ID to become the assumed primary.\n")); +} /**************** * Ask for a new user id, do the selfsignature and put it into @@ -2721,6 +2755,8 @@ menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock ) mainkey=1; } + no_primary_warning(pub_keyblock,0); + expiredate = ask_expiredate(); node = find_kbnode( sec_keyblock, PKT_SECRET_KEY ); sk = copy_secret_key( NULL, node->pkt->pkt.secret_key); @@ -2970,6 +3006,8 @@ menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock ) int selected, select_all; int modified = 0; + no_primary_warning(pub_keyblock,1); + select_all = !count_selected_uids (pub_keyblock); node = find_kbnode( sec_keyblock, PKT_SECRET_KEY ); |