]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Backwards compatibility for 3.5 external_acl_type formats (#52)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sun, 26 Nov 2017 13:41:58 +0000 (13:41 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Mon, 27 Nov 2017 05:24:29 +0000 (18:24 +1300)
* Fix missing Squid-3 external_acl_type format codes compatibility

  The %<{...} and %>{...} may produce header, or header-element type codes.

* Fix incomplete compatibility for %EXT_TAG code

* Add config test for old external_acl_type format codes

src/external_acl.cc
src/format/Token.cc
test-suite/squidconf/external_acl_type [new file with mode: 0644]

index a7c791b98e87e598cf01ad7a67b7cbf1aea70f50..f1e8fca917b93dd2be2a6f9d3f70a7cdd4a46ad6 100644 (file)
@@ -301,13 +301,31 @@ parse_externalAclHelper(external_acl ** list)
             (*fmt)->data.header.header = (*fmt)->data.string;
         } else
 #endif
-        {
-            // we can use the Format::Token::parse() method since it
-            // only pulls off one token. Since we already checked
-            // for '%' prefix above this is guaranteed to be a token.
-            const size_t len = (*fmt)->parse(token, &quote);
-            assert(len == strlen(token));
-        }
+            if (strncmp(token,"%<{", 3) == 0) {
+                SBuf tmp("%<h");
+                tmp.append(token+2);
+                debugs(82, DBG_PARSE_NOTE(DBG_IMPORTANT), "WARNING: external_acl_type format %<{...} is deprecated. Use " << tmp);
+                const size_t parsedLen = (*fmt)->parse(tmp.c_str(), &quote);
+                assert(parsedLen == tmp.length());
+                assert((*fmt)->type == Format::LFT_REPLY_HEADER ||
+                       (*fmt)->type == Format::LFT_REPLY_HEADER_ELEM);
+
+            } else if (strncmp(token,"%>{", 3) == 0) {
+                SBuf tmp("%>ha");
+                tmp.append(token+2);
+                debugs(82, DBG_PARSE_NOTE(DBG_IMPORTANT), "WARNING: external_acl_type format %>{...} is deprecated. Use " << tmp);
+                const size_t parsedLen = (*fmt)->parse(tmp.c_str(), &quote);
+                assert(parsedLen == tmp.length());
+                assert((*fmt)->type == Format::LFT_ADAPTED_REQUEST_HEADER ||
+                       (*fmt)->type == Format::LFT_ADAPTED_REQUEST_HEADER_ELEM);
+
+            } else {
+                // we can use the Format::Token::parse() method since it
+                // only pulls off one token. Since we already checked
+                // for '%' prefix above this is guaranteed to be a token.
+                const size_t len = (*fmt)->parse(token, &quote);
+                assert(len == strlen(token));
+            }
 
         // process special token-specific actions (only if necessary)
 #if USE_AUTH
index e0c69d3499e9deff01a80f86f8ae135c5a9cdadb..222a5a52ec1791abccaa232194a70e9b26319fc8 100644 (file)
@@ -152,6 +152,7 @@ static TokenTableEntry TokenTableMisc[] = {
     TokenTableEntry("DATA", LFT_EXT_ACL_DATA),
     TokenTableEntry("DST", LFT_CLIENT_REQ_URLDOMAIN),
     TokenTableEntry("EXT_LOG", LFT_EXT_LOG),
+    TokenTableEntry("EXT_TAG", LFT_TAG),
     TokenTableEntry("EXT_USER", LFT_USER_EXTERNAL),
     TokenTableEntry("IDENT", LFT_USER_IDENT),
     TokenTableEntry("LOGIN", LFT_USER_LOGIN),
diff --git a/test-suite/squidconf/external_acl_type b/test-suite/squidconf/external_acl_type
new file mode 100644 (file)
index 0000000..b35b5c5
--- /dev/null
@@ -0,0 +1,46 @@
+## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+# Check Backward Compatibility with Squid-3 formats
+external_acl_type foo \
+       %LOGIN \
+       %un \
+       %EXT_USER \
+       %EXT_LOG \
+       %EXT_TAG \
+       %IDENT \
+       %SRC \
+       %SRCPORT \
+       %URI \
+       %DST \
+       %PROTO \
+       %PORT \
+       %PATH \
+       %METHOD \
+       %MYADDR \
+       %MYPORT \
+       %PATH \
+       %>{Header} \
+       %>{Hdr:member} \
+       %>{Hdr:;member} \
+       %>{Hdr:Xmember} \
+       %<{Header} \
+       %<{Hdr:member} \
+       %<{Hdr:;member} \
+       %<{Hdr:Xmember} \
+       %ACL \
+       %DATA \
+       %%  /bin/true
+
+# TODO: enable when these are no longer requiring OpenSSL
+#      %USER_CERT
+#      %USER_CERTCHAIN
+#      %USER_CERT_xx
+#      %USER_CA_CERT_xx
+#      %ssl::>sni
+#      %ssl::<cert_subject
+#      %ssl::<cert_issuer