gpg: Make sure to mark a duplicate registered keybox as primary.
authorWerner Koch <wk@gnupg.org>
Wed, 13 Jan 2016 08:29:39 +0000 (09:29 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 13 Jan 2016 09:43:33 +0000 (10:43 +0100)
commit9dc355ad3ae0026ab04c424dc984d748b8fad393
tree31a6eb986c5a6f89cbbf8f33ed34352696b91cf2
parent96237b9a63a50aed1884cb06f84279b977d6a8fa
gpg: Make sure to mark a duplicate registered keybox as primary.

* kbx/keybox-init.c (keybox_register_file): Change interface to return
the token even if the file has already been registered.
* g10/keydb.c (primary_keyring): Rename to primary_keydb.
(maybe_create_keyring_or_box): Change return type to gpg_error_t.
(keydb_add_resource): Ditto. s/rc/err/.
(keydb_add_resource): Mark an already registered as primary.
* sm/keydb.c (maybe_create_keybox): Change return type to gpg_error_t.
(keydb_add_resource): Ditto. s/rc/err/.
(keydb_add_resource): Adjust for changed keybox_register_file.
--

This change aligns the registering of keyboxes with those of
keyrings.  This fixes a potential bug:

  gpg --keyring foo.kbx --keyring bar.gpg --keyring foo.kbx

would have marked bar.gpg as primary resource and thus inserting new
keys there.  The correct and now fixed behavior is to insert to
foo.kbx.

Signed-off-by: Werner Koch <wk@gnupg.org>
g10/keydb.c
kbx/keybox-init.c
kbx/keybox.h
sm/keydb.c
sm/keydb.h