diff options
author | Neal H. Walfield <[email protected]> | 2016-11-21 21:47:30 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2016-11-21 21:47:30 +0000 |
commit | 037f9de09298a31026ea2ab5fbd4a599b11cc34f (patch) | |
tree | 001dddfff8d6557ce9e24c8d1decb0ae692de8ff /g10/keydb.c | |
parent | g10: Correctly parameterize ngettext. (diff) | |
download | gnupg-037f9de09298a31026ea2ab5fbd4a599b11cc34f.tar.gz gnupg-037f9de09298a31026ea2ab5fbd4a599b11cc34f.zip |
g10: Cache the effective policy. Recompute it when required.
* g10/tofu.c (initdb): Add column effective_policy to the bindings
table.
(record_binding): New parameters effective_policy and set_conflict.
Save the effective policy. If SET_CONFLICT is set, then set conflict
according to CONFLICT. Otherwise, preserve the current value of
conflict. Update callers.
(get_trust): Don't compute the effective policy here...
(get_policy): ... do it here, if it was not cached. Take new
parameters, PK, the public key, and NOW, the time that the operation
started. Update callers.
(show_statistics): New parameter PK. Pass it to get_policy. Update
callers.
(tofu_notice_key_changed): New function.
* g10/gpgv.c (tofu_notice_key_changed): New stub.
* g10/import.c (import_revoke_cert): Take additional argument CTRL.
Pass it to keydb_update_keyblock.
* g10/keydb.c (keydb_update_keyblock): Take additional argument CTRL.
Update callers.
[USE_TOFU]: Call tofu_notice_key_changed.
* g10/test-stubs.c (tofu_notice_key_changed): New stub.
* tests/openpgp/tofu.scm: Assume that manually setting a binding's
policy to auto does not cause the tofu engine to forget about any
conflict.
--
Signed-off-by: Neal H. Walfield <[email protected]>
We now store the computed policy in the tofu DB (in the
effective_policy column of the bindings table) to avoid computing it
every time, which is expensive. Further, policy is never overridden
in case of a conflict. Instead, we detect a conflict if CONFLICT is
not empty.
This change is backwards compatible to existing DBs. The only minor
incompatibility is that unresolved conflicts won't be automatically
resolved in case we import a direct signature, or cross signatures.
Diffstat (limited to 'g10/keydb.c')
-rw-r--r-- | g10/keydb.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/g10/keydb.c b/g10/keydb.c index 1467b2d53..aab90e380 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -1518,7 +1518,7 @@ build_keyblock_image (kbnode_t keyblock, iobuf_t *r_iobuf, u32 **r_sigstatus) * you should use keydb_push_found_state and keydb_pop_found_state to * save and restore it. */ gpg_error_t -keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb) +keydb_update_keyblock (ctrl_t ctrl, KEYDB_HANDLE hd, kbnode_t kb) { gpg_error_t err; PKT_public_key *pk; @@ -1542,6 +1542,10 @@ keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb) if (err) return err; +#ifdef USE_TOFU + tofu_notice_key_changed (ctrl, kb); +#endif + memset (&desc, 0, sizeof (desc)); fingerprint_from_pk (pk, desc.u.fpr, &len); if (len == 20) |