From dfb0082b45e9a721920fa0da2019b63fbd1160b3 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 23 May 2006 16:16:15 +0000 Subject: - Fix locking while connecting to SMB server --- ChangeLog | 1 + daemon/ntlm.c | 28 +++++++++++++++++++--------- 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); -- cgit v1.2.3