gpg: Keep a lock during the read-update/insert cycle in import.
authorWerner Koch <wk@gnupg.org>
Wed, 18 Oct 2017 16:28:52 +0000 (18:28 +0200)
committerWerner Koch <wk@gnupg.org>
Wed, 18 Oct 2017 16:28:52 +0000 (18:28 +0200)
commit645f30ad310a518a863eb7bd3e11251a7e7f2eca
tree5e40963b60cf50eb7169d09624ae4be4401a2035
parent3bb06531d38b85be295308e826a50a1a7ba935ec
gpg: Keep a lock during the read-update/insert cycle in import.

* g10/keydb.c (keydb_handle): New field 'keep_lock'.
(keydb_release): Clear that flag.
(keydb_lock): New function.
(unlock_all): Skip if KEEP_LOCK is set.
* g10/getkey.c (get_keyblock_byfprint_fast): Call keep_lock if
requested.
--

That change is straightforward.  It helps to avoid the race condition
that another gpg process inserts a key while the first process is
between the search and the insert.

A similar change is due for gpgsm.

Note that the key edit operations may still suffer from a race.

GnuPG-bug-id: 3446
g10/getkey.c
g10/keydb.c
g10/keydb.h