diff options
author | Werner Koch <[email protected]> | 2025-08-28 13:26:36 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-08-28 13:26:36 +0000 |
commit | f64a456271dd0b3e027386de30d734820c878978 (patch) | |
tree | 1f7acf52670c9b9a4d2250b5df2654c1b1ad18bf | |
parent | gpg: New option --auto-key-upload (diff) | |
download | gnupg-f64a456271dd0b3e027386de30d734820c878978.tar.gz gnupg-f64a456271dd0b3e027386de30d734820c878978.zip |
gpg: Make --auto-upload also work for --edit-key
* g10/keyedit.c (keyedit_menu): Add an upload flag and set it as
needed. On save upload to the keyserver.
--
That is the second part of
GnuPG-bug-id: 7333
and the next part will be to implement this for the quick commands.
-rw-r--r-- | g10/keyedit.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c index 12e127452..d3c3c8e2e 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1550,6 +1550,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, char *answer = NULL; int redisplay = 1; int modified = 0; + int upload = 0; /* Set if the key maybe be uploaded. */ int sec_shadowing = 0; int run_subkey_warnings = 0; int have_commands = !!commands; @@ -1792,6 +1793,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, case cmdSIGN: { unsigned int myflags = 0; + int my_modified = 0; if (pk->flags.revoked) { @@ -1845,7 +1847,12 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, break; } - sign_uids (ctrl, NULL, keyblock, locusr, myflags, NULL, &modified); + sign_uids (ctrl, NULL, keyblock, locusr, myflags, + NULL, &my_modified); + if (my_modified) /* sign_uids modified the keyblock */ + modified = 1; /* thus set the general modified flag. */ + if (my_modified && !(myflags & SIGN_UIDS_LOCAL)) + upload = 1; /* exportable signature -> mark uploadable. */ } break; @@ -1876,6 +1883,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, update_trust = 1; redisplay = 1; modified = 1; + upload = 1; merge_keys_and_selfsig (ctrl, keyblock); } break; @@ -1900,6 +1908,8 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, menu_deluid (keyblock); redisplay = 1; modified = 1; + /* upload does not make sense here. Eventually we may + * decide to delete a key from the keyserver.*/ } } break; @@ -1928,6 +1938,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { redisplay = 1; modified = 1; + upload = 1; merge_keys_and_selfsig (ctrl, keyblock); } break; @@ -1938,6 +1949,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { redisplay = 1; modified = 1; + upload = 1; merge_keys_and_selfsig (ctrl, keyblock); } break; @@ -2137,6 +2149,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, menu_delkey (keyblock); redisplay = 1; modified = 1; + /* upload does not make sense. */ } } break; @@ -2151,6 +2164,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { redisplay = 1; modified = 1; + upload = 1; merge_keys_and_selfsig (ctrl, keyblock); } } @@ -2161,6 +2175,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { redisplay = 1; modified = 1; + upload = 1; merge_keys_and_selfsig (ctrl, keyblock); } break; @@ -2184,6 +2199,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { modified = 1; redisplay = 1; + upload = 1; } } } @@ -2200,7 +2216,10 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, " the entire key? (y/N) "))) { if (menu_revkey (ctrl, keyblock)) - modified = 1; + { + modified = 1; + upload = 1; + } redisplay = 1; } @@ -2213,7 +2232,10 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, " this subkey? (y/N) "))) { if (menu_revsubkey (ctrl, keyblock)) - modified = 1; + { + modified = 1; + upload = 1; + } redisplay = 1; } @@ -2229,6 +2251,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, merge_keys_and_selfsig (ctrl, keyblock); run_subkey_warnings = 1; modified = 1; + upload = 1; redisplay = 1; } break; @@ -2238,6 +2261,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { merge_keys_and_selfsig (ctrl, keyblock); modified = 1; + upload = 1; redisplay = 1; } break; @@ -2246,6 +2270,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, if (menu_backsign (ctrl, keyblock)) { modified = 1; + upload = 1; redisplay = 1; } break; @@ -2255,6 +2280,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { merge_keys_and_selfsig (ctrl, keyblock); modified = 1; + upload = 1; redisplay = 1; } break; @@ -2327,6 +2353,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { merge_keys_and_selfsig (ctrl, keyblock); modified = 1; + upload = 1; redisplay = 1; } } @@ -2339,6 +2366,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { merge_keys_and_selfsig (ctrl, keyblock); modified = 1; + upload = 1; redisplay = 1; } break; @@ -2349,6 +2377,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { merge_keys_and_selfsig (ctrl, keyblock); modified = 1; + upload = 1; redisplay = 1; } break; @@ -2361,6 +2390,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, { redisplay = 1; modified = 1; + upload = 1; } break; @@ -2413,6 +2443,15 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, log_error (_("update failed: %s\n"), gpg_strerror (err)); break; } + if (upload && opt.flags.auto_key_upload) + { + unsigned int saved_options = opt.keyserver_options.options; + + opt.keyserver_options.options |= KEYSERVER_LDAP_ONLY; + opt.keyserver_options.options |= KEYSERVER_WARN_ONLY; + keyserver_export_pubkey (ctrl, pk, 0); + opt.keyserver_options.options = saved_options; + } } if (delseckey_list) |