1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-03-28 22:49:59 +01:00

gpg: If a conflict occurs in batch mode, record that.

* g10/tofu.c (get_trust): If a conflict occurs when MAY_ASK is false,
set conflict to the key.  When prompting the user, don't show the
conflicting key if the conflicting key is the current key.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
Neal H. Walfield 2015-10-19 10:34:15 +02:00
parent c2c4007148
commit 55d8845465

View File

@ -1450,7 +1450,10 @@ get_trust (struct db *dbs, const char *fingerprint, const char *email,
es_fprintf (fp, _("The binding %s is NOT known. "), binding); es_fprintf (fp, _("The binding %s is NOT known. "), binding);
binding_shown = 1; binding_shown = 1;
} }
else if (policy == TOFU_POLICY_ASK && conflict) else if (policy == TOFU_POLICY_ASK
/* If there the conflict is with itself, then don't
display this message. */
&& conflict && strcmp (conflict, fingerprint) != 0)
{ {
es_fprintf (fp, es_fprintf (fp,
_("%s raised a conflict with this binding. Since this" _("%s raised a conflict with this binding. Since this"
@ -1718,11 +1721,22 @@ get_trust (struct db *dbs, const char *fingerprint, const char *email,
out: out:
if (change_conflicting_to_ask) if (change_conflicting_to_ask)
{ {
rc = sqlite3_exec_printf if (! may_ask)
(db, NULL, NULL, &err, /* If we weren't allowed to ask, also update this key as
"update bindings set policy = %d, conflict = %Q" conflicting with itself. */
" where email = %Q and fingerprint != %Q and policy = %d;", rc = sqlite3_exec_printf
TOFU_POLICY_ASK, fingerprint, email, fingerprint, TOFU_POLICY_AUTO); (db, NULL, NULL, &err,
"update bindings set policy = %d, conflict = %Q"
" where email = %Q"
" and (policy = %d or (policy = %d and fingerprint = %Q));",
TOFU_POLICY_ASK, fingerprint, email, TOFU_POLICY_AUTO,
TOFU_POLICY_ASK, fingerprint);
else
rc = sqlite3_exec_printf
(db, NULL, NULL, &err,
"update bindings set policy = %d, conflict = %Q"
" where email = %Q and fingerprint != %Q and policy = %d;",
TOFU_POLICY_ASK, fingerprint, email, fingerprint, TOFU_POLICY_AUTO);
if (rc) if (rc)
{ {
log_error (_("error changing TOFU policy: %s\n"), err); log_error (_("error changing TOFU policy: %s\n"), err);