]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
merge in bugfix for bug 872 - NTLM locking improvements to prevent crashes
authorrobertc <>
Tue, 21 Dec 2004 00:35:58 +0000 (00:35 +0000)
committerrobertc <>
Tue, 21 Dec 2004 00:35:58 +0000 (00:35 +0000)
src/ACLChecklist.cc
src/AuthUserRequest.cc
src/auth/ntlm/auth_ntlm.cc
src/client_side_reply.cc

index 4bc36026cf46975d82ca8b882728ba279c07adf0..fe43a93cd853ef64629683dd5776f9c7824a91f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLChecklist.cc,v 1.21 2004/12/20 16:30:32 robertc Exp $
+ * $Id: ACLChecklist.cc,v 1.22 2004/12/20 17:35:58 robertc Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -61,7 +61,7 @@ ACLChecklist::authenticated()
     }
 
     /* get authed here */
-    /* Note: this fills in auth_user_request when applicable */
+    /* Note: this fills in auth_user_request when applicable (auth incomplete)*/
     switch (AuthUserRequest::tryToAuthenticateAndSetAuthUser (&auth_user_request, headertype, request, conn(), src_addr)) {
 
     case AUTH_ACL_CANNOT_AUTHENTICATE:
@@ -69,6 +69,12 @@ ACLChecklist::authenticated()
         return 0;
 
     case AUTH_AUTHENTICATED:
+
+        if (auth_user_request) {
+            auth_user_request->unlock();
+            auth_user_request = NULL;
+        }
+
         return 1;
         break;
 
@@ -220,18 +226,6 @@ ACLChecklist::checkCallback(allow_t answer)
     PF *callback_;
     void *cbdata_;
     debug(28, 3) ("ACLChecklist::checkCallback: %p answer=%d\n", this, answer);
-    /* During reconfigure, we can end up not finishing call
-     * sequences into the auth code */
-
-    if (auth_user_request) {
-        /* the checklist lock */
-        auth_user_request->unlock();
-        /* it might have been connection based */
-        assert(conn().getRaw() != NULL);
-        conn()->auth_user_request = NULL;
-        conn()->auth_type = AUTH_BROKEN;
-        auth_user_request = NULL;
-    }
 
     callback_ = callback;
     callback = NULL;
@@ -325,6 +319,21 @@ ACLChecklist::~ACLChecklist()
     if (extacl_entry)
         cbdataReferenceDone(extacl_entry);
 
+    /* During reconfigure or if authentication is used in aclCheckFast without
+     * first being authenticated in http_access we can end up not finishing call
+     * sequences into the auth code. In such case we must make sure to forget
+     * the authentication state completely
+     */
+    if (auth_user_request) {
+        /* the checklist lock */
+        auth_user_request->unlock();
+        /* it might have been connection based */
+        assert(conn().getRaw() != NULL);
+        conn()->auth_user_request = NULL;
+        conn()->auth_type = AUTH_BROKEN;
+        auth_user_request = NULL;
+    }
+
     if (request)
         requestUnlink(request);
 
index 611385afa675abbb1e1df9be2ae0809b7b26e017..50d31d5ba4023490b01bb388f7e1c02bcb915654 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUserRequest.cc,v 1.1 2004/08/30 03:28:56 robertc Exp $
+ * $Id: AuthUserRequest.cc,v 1.2 2004/12/20 17:35:58 robertc Exp $
  *
  * DO NOT MODIFY NEXT 2 LINES:
  * arch-tag: 6803fde1-d5a2-4c29-9034-1c0c9f650eb4
@@ -624,9 +624,23 @@ AuthUserRequest::tryToAuthenticateAndSetAuthUser(auth_user_request_t ** auth_use
     if (t && t->lastReply != AUTH_ACL_CANNOT_AUTHENTICATE
             && t->lastReply != AUTH_ACL_HELPER)
     {
-        if (!*auth_user_request)
+        if (!*auth_user_request) {
             *auth_user_request = t;
 
+            (*auth_user_request)->lock()
+
+            ;
+            //TODO: check if needed. If there's a leak, it is not
+        }
+
+        if (!request->auth_user_request) {
+            request->auth_user_request=t;
+
+            request->auth_user_request->lock()
+
+            ;
+        }
+
         return t->lastReply;
     }
 
index 33c77928aa469f5f9bf577b324e973213cb945b1..308fbbb61b29e27345ff64936fa8d3f0c2b12fa3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: auth_ntlm.cc,v 1.44 2004/12/20 16:30:40 robertc Exp $
+ * $Id: auth_ntlm.cc,v 1.45 2004/12/20 17:35:58 robertc Exp $
  *
  * DEBUG: section 29    NTLM Authenticator
  * AUTHOR: Robert Collins
@@ -51,6 +51,8 @@
 static void
 authenticateStateFree(authenticateStateData * r)
 {
+    r->auth_user_request->unlock();
+    r->auth_user_request = NULL;
     cbdataFree(r);
 }
 
@@ -762,6 +764,10 @@ AuthNTLMUserRequest::module_start(RH * handler, void *data)
             r->data = cbdataReference(data);
             r->auth_user_request = this;
 
+            lock()
+
+                ; /* locking myself */
+
             if (server == NULL) {
                 helperStatefulSubmit(ntlmauthenticators, NULL, authenticateNTLMHandleplaceholder, r, NULL);
             } else {
@@ -790,11 +796,19 @@ AuthNTLMUserRequest::module_start(RH * handler, void *data)
         r->handler = handler;
         r->data = cbdataReference(data);
         r->auth_user_request = this;
+
+        lock()
+
+            ;
         snprintf(buf, 8192, "KK %s\n", sent_string);
+
         /* getting rid of deferred request status */
         authserver_deferred = 0;
+
         helperStatefulSubmit(ntlmauthenticators, buf, authenticateNTLMHandleReply, r, authserver);
+
         debug(29, 9) ("authenticateNTLMstart: finished\n");
+
         break;
 
     default:
index 68e824875924dc58da4097cf13e37b5754f9c80a..376ab44e5128c5a4b5af901248812d0c3a37900a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.cc,v 1.78 2004/12/20 16:30:35 robertc Exp $
+ * $Id: client_side_reply.cc,v 1.79 2004/12/20 17:35:58 robertc Exp $
  *
  * DEBUG: section 88    Client-side Reply Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -1834,7 +1834,11 @@ clientReplyContext::buildMaxBodySize(HttpReply * reply)
     acl_size_t *l = Config.ReplyBodySize;
     ACLChecklist *ch;
 
+    if (http->logType == LOG_TCP_DENIED)
+        return;
+
     ch = clientAclChecklistCreate(NULL, http);
+
     ch->reply = reply;
 
     for (l = Config.ReplyBodySize; l; l = l -> next) {