aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2008-10-17 13:12:11 +0000
committerWerner Koch <[email protected]>2008-10-17 13:12:11 +0000
commitdd96bd44d44e9e8b7ac22479472965671513d9c4 (patch)
tree20b29810595b0637a4c21d48350a72632ba3e8a1
parentMade scdaemon more robust on Windows. (diff)
downloadgnupg-dd96bd44d44e9e8b7ac22479472965671513d9c4.tar.gz
gnupg-dd96bd44d44e9e8b7ac22479472965671513d9c4.zip
Reset the context lock flag after a failed dirmngr start which may happend
due to --disable-dirmngr.
Diffstat (limited to '')
-rw-r--r--sm/ChangeLog7
-rw-r--r--sm/call-dirmngr.c35
2 files changed, 34 insertions, 8 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index ccc61dc8f..796724354 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-17 Werner Koch <[email protected]>
+
+ * call-dirmngr.c (start_dirmngr, start_dirmngr2): Reset the lock
+ flag on error.
+ (release_dirmngr, release_dirmngr2): Replace asserts by error messages.
+ (gpgsm_dirmngr_lookup): Replace assert by fatal error message.
+
2008-10-13 Werner Koch <[email protected]>
* gpgsm.c: Add alias --delete-keys.
diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c
index 377709251..4d0977a4a 100644
--- a/sm/call-dirmngr.c
+++ b/sm/call-dirmngr.c
@@ -141,7 +141,7 @@ get_membuf (struct membuf *mb, size_t *len)
}
-/* This fucntion prepares the dirmngr for a new session. The
+/* This function prepares the dirmngr for a new session. The
audit-events option is used so that other dirmngr clients won't get
disturbed by such events. */
static void
@@ -320,17 +320,27 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r)
static int
start_dirmngr (ctrl_t ctrl)
{
+ gpg_error_t err;
+
assert (! dirmngr_ctx_locked);
dirmngr_ctx_locked = 1;
- return start_dirmngr_ext (ctrl, &dirmngr_ctx);
+ err = start_dirmngr_ext (ctrl, &dirmngr_ctx);
+ /* We do not check ERR but the existance of a context because the
+ error might come from a failed command send to the dirmngr.
+ Fixme: Why don't we close the drimngr context if we encountered
+ an error in prepare_dirmngr? */
+ if (!dirmngr_ctx)
+ dirmngr_ctx_locked = 0;
+ return err;
}
static void
release_dirmngr (ctrl_t ctrl)
{
- assert (dirmngr_ctx_locked);
+ if (!dirmngr_ctx_locked)
+ log_error ("WARNING: trying to release a non-locked dirmngr ctx\n");
dirmngr_ctx_locked = 0;
}
@@ -338,17 +348,23 @@ release_dirmngr (ctrl_t ctrl)
static int
start_dirmngr2 (ctrl_t ctrl)
{
+ gpg_error_t err;
+
assert (! dirmngr2_ctx_locked);
dirmngr2_ctx_locked = 1;
- return start_dirmngr_ext (ctrl, &dirmngr2_ctx);
+ err = start_dirmngr_ext (ctrl, &dirmngr2_ctx);
+ if (!dirmngr2_ctx)
+ dirmngr2_ctx_locked = 0;
+ return err;
}
static void
release_dirmngr2 (ctrl_t ctrl)
{
- assert (dirmngr2_ctx_locked);
+ if (!dirmngr2_ctx_locked)
+ log_error ("WARNING: trying to release a non-locked dirmngr2 ctx\n");
dirmngr2_ctx_locked = 0;
}
@@ -780,21 +796,24 @@ gpgsm_dirmngr_lookup (ctrl_t ctrl, strlist_t names, int cache_only,
/* The lookup function can be invoked from the callback of a lookup
function, for example to walk the chain. */
- assert (!dirmngr_ctx_locked || !dirmngr2_ctx_locked);
- if (! dirmngr_ctx_locked)
+ if (!dirmngr_ctx_locked)
{
rc = start_dirmngr (ctrl);
if (rc)
return rc;
ctx = dirmngr_ctx;
}
- else
+ else if (!dirmngr2_ctx_locked)
{
rc = start_dirmngr2 (ctrl);
if (rc)
return rc;
ctx = dirmngr2_ctx;
}
+ else
+ {
+ log_fatal ("both dirmngr contexts are in use\n");
+ }
pattern = pattern_from_strlist (names);
if (!pattern)