summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-05-23 16:16:15 +0000
committerStef Walter <stef@memberwebs.com>2006-05-23 16:16:15 +0000
commitdfb0082b45e9a721920fa0da2019b63fbd1160b3 (patch)
treed0711a0d2679ce97ca628fc59e253a9bdb7ff934
parent771c2be67b01f26776335f945a44a05d3a510d17 (diff)
- Fix locking while connecting to SMB server
-rw-r--r--ChangeLog1
-rw-r--r--daemon/ntlm.c28
2 files changed, 20 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d226ae..bde0b0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
0.5.1
- Fix problem with NTLM connection caching
- Fix problem with NTLM not authenticating POST in IE properly
+ - Fix locking while connecting to SMB server
- Better log handling when things are fast and furious
- Don't hang on exit on FreeBSD
diff --git a/daemon/ntlm.c b/daemon/ntlm.c
index bb08995..2cd20db 100644
--- a/daemon/ntlm.c
+++ b/daemon/ntlm.c
@@ -103,13 +103,18 @@ static ntlm_connection_t* makeconnection(ha_request_t* rq, ntlm_context_t* ctx)
memset(conn, 0, sizeof(*conn));
- /*
- * Open a connection to to the domain controller. I don't think
- * we can cache these connections or use them again as opening
- * a connection here results in an nonce being generated.
- */
- conn->handle = ntlmssp_connect(ctx->server, ctx->backup,
- ctx->domain, (char*)conn->nonce);
+ ha_lock(&g_smblib_mutex);
+
+ /*
+ * Open a connection to to the domain controller. I don't think
+ * we can cache these connections or use them again as opening
+ * a connection here results in an nonce being generated.
+ */
+ conn->handle = ntlmssp_connect(ctx->server, ctx->backup,
+ ctx->domain, (char*)conn->nonce);
+
+ ha_unlock(&g_smblib_mutex);
+
if(!conn->handle)
{
ha_messagex(rq, LOG_ERR, "couldn't connect to the domain server %s (backup: %s)",
@@ -128,9 +133,14 @@ static void freeconnection(ha_request_t* rq, ntlm_connection_t* conn)
if(conn->handle)
{
+ ha_lock(&g_smblib_mutex);
+
+ ntlmssp_disconnect(conn->handle);
+ conn->handle = NULL;
+
+ ha_unlock(&g_smblib_mutex);
+
ha_messagex(rq, LOG_DEBUG, "disconnected from server");
- ntlmssp_disconnect(conn->handle);
- conn->handle = NULL;
}
free(conn);