diff options
author | Stef Walter <stef@memberwebs.com> | 2006-05-23 16:16:15 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2006-05-23 16:16:15 +0000 |
commit | dfb0082b45e9a721920fa0da2019b63fbd1160b3 (patch) | |
tree | d0711a0d2679ce97ca628fc59e253a9bdb7ff934 /daemon/ntlm.c | |
parent | 771c2be67b01f26776335f945a44a05d3a510d17 (diff) |
- Fix locking while connecting to SMB server
Diffstat (limited to 'daemon/ntlm.c')
-rw-r--r-- | daemon/ntlm.c | 28 |
1 files changed, 19 insertions, 9 deletions
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); |