aboutsummaryrefslogtreecommitdiffstats
path: root/sm/delete.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2025-10-22 02:03:18 +0000
committerNIIBE Yutaka <[email protected]>2025-10-22 02:03:18 +0000
commit2d9e1295a1f4a6929efeccfb1d8492eee4ff588b (patch)
tree8f988527ea48654641344f97369dd872e555eeca /sm/delete.c
parentgpgsm: Fix delete and store certificate locking glitches. (diff)
downloadgnupg-2d9e1295a1f4a6929efeccfb1d8492eee4ff588b.tar.gz
gnupg-2d9e1295a1f4a6929efeccfb1d8492eee4ff588b.zip
gpg,gpgsm: Serialize write access to keybox/keyring to protect.
* g10/keydb.c (internal_keydb_update_keyblock): Caller should lock the resource by keydb_lock, before use of this routine. (internal_keydb_insert_keyblock): Likewise. (internal_keydb_delete_keyblock): Likewise. * g10/delkey.c (do_delete_key): Serialize the access to the resource. * g10/import.c (import_revoke_cert): Likewise. * g10/keyedit.c (quick_find_keyblock): Likewise. * g10/keygen.c (quick_find_keyblock): Likewise. * sm/delete.c (delete_one): Lock earlier to protect the resource correctly. * sm/keydb.c (do_set_flags): Rename from keydb_set_flags. (keydb_set_cert_flags): Follow the change. (keydb_update_cert): Require locked by caller. * sm/keydb.h (keydb_set_flags): Remove. -- GnuPG-bug-id: 7855 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'sm/delete.c')
-rw-r--r--sm/delete.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sm/delete.c b/sm/delete.c
index ccd389313..46d3a6f2a 100644
--- a/sm/delete.c
+++ b/sm/delete.c
@@ -60,6 +60,14 @@ delete_one (ctrl_t ctrl, const char *username)
goto leave;
}
+ /* Note that the lock is kept until the KH is released. */
+ rc = keydb_lock (kh);
+ if (rc)
+ {
+ log_error (_("error locking keybox: %s\n"), gpg_strerror (rc));
+ goto leave;
+ }
+
/* If the key is specified in a unique way, include ephemeral keys
in the search. */
if ( desc.mode == KEYDB_SEARCH_MODE_FPR
@@ -112,15 +120,7 @@ delete_one (ctrl_t ctrl, const char *username)
goto leave;
}
- /* We need to search again to get back to the right position. Note
- * that the lock is kept until the KH is released. */
- rc = keydb_lock (kh);
- if (rc)
- {
- log_error (_("error locking keybox: %s\n"), gpg_strerror (rc));
- goto leave;
- }
-
+ /* We need to search again to get back to the right position. */
do
{
keydb_search_reset (kh);