[svn] GnuPG - r4852 - trunk/sm
svn author wk
cvs at cvs.gnupg.org
Fri Oct 17 15:12:12 CEST 2008
Author: wk
Date: 2008-10-17 15:12:11 +0200 (Fri, 17 Oct 2008)
New Revision: 4852
Modified:
trunk/sm/ChangeLog
trunk/sm/call-dirmngr.c
Log:
Reset the context lock flag after a failed dirmngr start which may happend
due to --disable-dirmngr.
Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog 2008-10-15 13:23:10 UTC (rev 4851)
+++ trunk/sm/ChangeLog 2008-10-17 13:12:11 UTC (rev 4852)
@@ -1,3 +1,10 @@
+2008-10-17 Werner Koch <wk at g10code.com>
+
+ * 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 <wk at g10code.com>
* gpgsm.c: Add alias --delete-keys.
Modified: trunk/sm/call-dirmngr.c
===================================================================
--- trunk/sm/call-dirmngr.c 2008-10-15 13:23:10 UTC (rev 4851)
+++ trunk/sm/call-dirmngr.c 2008-10-17 13:12:11 UTC (rev 4852)
@@ -141,7 +141,7 @@
}
-/* 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 @@
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 @@
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 @@
/* 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)
More information about the Gnupg-commits
mailing list