summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <mb@g10code.com>2006-05-22 16:35:04 +0200
committerMarcus Brinkmann <mb@g10code.com>2006-05-22 16:35:04 +0200
commit11544e7184b0eab8f3058ee3c5f87e94118a7bf3 (patch)
tree67f5b64a79b37cd78c866edd41bb9e6895deaddb
parentAdded sample certificates. (diff)
downloadgnupg2-11544e7184b0eab8f3058ee3c5f87e94118a7bf3.tar.xz
gnupg2-11544e7184b0eab8f3058ee3c5f87e94118a7bf3.zip
2006-05-19 Marcus Brinkmann <marcus@g10code.de>
* keydb.c (keydb_insert_cert): Do not lock here, but only check if it is locked. (keydb_store_cert): Lock here. * keydb.h (keydb_delete): Accept new argument UNLOCK. * keydb.c (keydb_delete): Likewise. Only unlock if this is set. * delete.c (delete_one): Add new argument to invocation of keydb_delete.
-rw-r--r--sm/ChangeLog11
-rw-r--r--sm/delete.c2
-rw-r--r--sm/keydb.c14
-rw-r--r--sm/keydb.h2
4 files changed, 22 insertions, 7 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 02505962c..f161d444c 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,14 @@
+2006-05-19 Marcus Brinkmann <marcus@g10code.de>
+
+ * keydb.c (keydb_insert_cert): Do not lock here, but only check if
+ it is locked.
+ (keydb_store_cert): Lock here.
+
+ * keydb.h (keydb_delete): Accept new argument UNLOCK.
+ * keydb.c (keydb_delete): Likewise. Only unlock if this is set.
+ * delete.c (delete_one): Add new argument to invocation of
+ keydb_delete.
+
2006-03-21 Werner Koch <wk@g10code.com>
* certchain.c (get_regtp_ca_info): New.
diff --git a/sm/delete.c b/sm/delete.c
index 8e06b9489..7533f7291 100644
--- a/sm/delete.c
+++ b/sm/delete.c
@@ -124,7 +124,7 @@ delete_one (CTRL ctrl, const char *username)
goto leave;
}
- rc = keydb_delete (kh);
+ rc = keydb_delete (kh, duplicates ? 0 : 1);
if (rc)
goto leave;
if (opt.verbose)
diff --git a/sm/keydb.c b/sm/keydb.c
index 17f04fe4b..15f5dbdac 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -696,9 +696,8 @@ keydb_insert_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
else
return gpg_error (GPG_ERR_GENERAL);
- rc = lock_all (hd);
- if (rc)
- return rc;
+ if (!hd->locked)
+ return gpg_error (GPG_ERR_NOT_LOCKED);
gpgsm_get_fingerprint (cert, GCRY_MD_SHA1, digest, NULL); /* kludge*/
@@ -759,7 +758,7 @@ keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert)
* The current keyblock or cert will be deleted.
*/
int
-keydb_delete (KEYDB_HANDLE hd)
+keydb_delete (KEYDB_HANDLE hd, int unlock)
{
int rc = -1;
@@ -785,7 +784,8 @@ keydb_delete (KEYDB_HANDLE hd)
break;
}
- unlock_all (hd);
+ if (unlock)
+ unlock_all (hd);
return rc;
}
@@ -1337,6 +1337,10 @@ keydb_store_cert (ksba_cert_t cert, int ephemeral, int *existed)
if (ephemeral)
keydb_set_ephemeral (kh, 1);
+ rc = lock_all (kh);
+ if (rc)
+ return rc;
+
rc = keydb_search_fpr (kh, fpr);
if (rc != -1)
{
diff --git a/sm/keydb.h b/sm/keydb.h
index 924ad77c4..fb4001b64 100644
--- a/sm/keydb.h
+++ b/sm/keydb.h
@@ -53,7 +53,7 @@ int keydb_get_cert (KEYDB_HANDLE hd, ksba_cert_t *r_cert);
int keydb_insert_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
int keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
-int keydb_delete (KEYDB_HANDLE hd);
+int keydb_delete (KEYDB_HANDLE hd, int unlock);
int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
void keydb_rebuild_caches (void);