]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Supply ALE to request_header_access/reply_header_access (#477)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sat, 21 Sep 2019 12:46:03 +0000 (12:46 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 21 Sep 2019 12:46:07 +0000 (12:46 +0000)
Commit cb36505 already covered many (but not all) similar cases.

Also supply HttpReply to cache_peer_access. Lack of reply
caused "ACL is used in context without an HTTP response" bug.

src/HttpHeaderTools.cc
src/neighbors.cc

index f2cded7add3c7e233daf7e7a9d3fa9df0c78fd5b..b4f1ab111b6a38eb174bec9b209453f70c8cc44d 100644 (file)
@@ -273,7 +273,7 @@ httpHeaderQuoteString(const char *raw)
  * \retval 1    Header has no access controls to test
  */
 static int
-httpHdrMangle(HttpHeaderEntry * e, HttpRequest * request, HeaderManglers *hms)
+httpHdrMangle(HttpHeaderEntry * e, HttpRequest * request, HeaderManglers *hms, const AccessLogEntryPointer &al)
 {
     int retval;
 
@@ -289,6 +289,12 @@ httpHdrMangle(HttpHeaderEntry * e, HttpRequest * request, HeaderManglers *hms)
 
     ACLFilledChecklist checklist(hm->access_list, request, NULL);
 
+    checklist.al = al;
+    if (al && al->reply) {
+        checklist.reply = al->reply.getRaw();
+        HTTPMSGLOCK(checklist.reply);
+    }
+
     if (checklist.fastCheck().allowed()) {
         /* aclCheckFast returns true for allow. */
         debugs(66, 7, "checklist for mangler is positive. Mangle");
@@ -335,7 +341,7 @@ httpHdrMangleList(HttpHeader *l, HttpRequest *request, const AccessLogEntryPoint
     if (hms) {
         int headers_deleted = 0;
         while ((e = l->getEntry(&p))) {
-            if (0 == httpHdrMangle(e, request, hms))
+            if (httpHdrMangle(e, request, hms, al) == 0)
                 l->delAt(p, headers_deleted);
         }
 
index b5684cda02e71af20f087b506fc291df964b2a86..9259b082e6c55eca4056ed7fdbdbbdac626af322 100644 (file)
@@ -168,6 +168,10 @@ peerAllowedToUse(const CachePeer * p, PeerSelector * ps)
 
     ACLFilledChecklist checklist(p->access, request, NULL);
     checklist.al = ps->al;
+    if (ps->al && ps->al->reply) {
+        checklist.reply = ps->al->reply.getRaw();
+        HTTPMSGLOCK(checklist.reply);
+    }
     checklist.syncAle(request, nullptr);
     return checklist.fastCheck().allowed();
 }