]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Regression Bug 3891: squid.conf parser errors in 3.4.0.1
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 28 Sep 2013 15:38:33 +0000 (09:38 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 28 Sep 2013 15:38:33 +0000 (09:38 -0600)
Alternative implementation for configuration_includes_quoted_values and
quoted string support in squid.conf that avoids the extensions attempted
in 3.4.0.1 leading to parse errors from overly strict parsing of all
directives parameters.

Documentation updated by Amos Jeffries, Treehouse Networks Ltd.

1  2 
src/ConfigParser.cc
src/ConfigParser.h
src/acl/Acl.cc
src/acl/Acl.h
src/cache_cf.cc
src/cf.data.pre

index 453ca76f6fdaba8b2964a726b59ee47d4308fb5c,dfe393542cdf47593d92a3170fd910259984f720..58ac392fcd4be928bf82f88e7b5745fda5455ba3
@@@ -77,9 -92,13 +92,12 @@@ ConfigParser::strtokFile(void
          strncpy(undoToken, undo.front().c_str(), sizeof(undoToken));
          undoToken[sizeof(undoToken) - 1] = '\0';
          undo.pop();
-         return undoToken;
+         return lastToken = undoToken;
      }
  
 -    // XXX: add file:name support to the quoted string-aware parser
+     if (RecognizeQuotedValues)
+         return lastToken = ConfigParser::NextToken();
      lastToken = NULL;
      do {
  
@@@ -184,11 -236,23 +235,18 @@@ ConfigParser::NextElement(bool *wasQuot
      strtok(s-1, "\""); /*Reset the strtok to point after the "  */
      *s = '\0';
  
-     var->reset(token+1);
+     return (token+1);
  }
  
 -    // TODO: support file:name syntax to auto-include files, but think how
 -    // admins will be able to disable that interpretation w/o disabling
 -    // macros and other special value processing. The "file:" prefix or
 -    // any similar key construct would probably have to go outside the
 -    // optionally quoted string for that to work: file:"name with $macros".
+ char *
+ ConfigParser::NextToken()
+ {
+     return NextElement(NULL);
+ }
  const char *
 -ConfigParser::QuoteString(String &var)
 +ConfigParser::QuoteString(const String &var)
  {
      static String quotedStr;
      const char *s = var.termedBuf();
index f313a5a6c2db306e1fda9153f23ea82158735fd6,8564c34dd0f98b7153a39683b553aaf3fcbb247a..8d2e728d2ec0be39371f9bfb0ab64a5547cce3e7
@@@ -89,4 -105,9 +105,9 @@@ private
  
  int parseConfigFile(const char *file_name);
  
 -/// XXX: Used for temporary hacks to allow old code to handle quoted values
++/// Used for temporary hacks to allow old code to handle quoted values
+ /// without replacing every strtok() call.
+ extern char *xstrtok(char *str, const char *delimiters);
  #endif /* SQUID_CONFIGPARSER_H */
diff --cc src/acl/Acl.cc
index b5e1c31fd346494f8959d62b7fb44c273a05fb12,f550cdac7d46344f7d96a7510dc4225a1191fb55..bc090277a6d91421649c9ae64443f505d48947df
@@@ -398,9 -410,35 +398,17 @@@ ACL::~ACL(
  {
      debugs(28, 3, "ACL::~ACL: '" << cfgline << "'");
      safe_free(cfgline);
 +    AclMatchedName = NULL; // in case it was pointing to our name
  }
  
 -/* to be split into separate files in the future */
 -
 -CBDATA_CLASS_INIT(acl_access);
 -
 -void *
 -acl_access::operator new (size_t)
 -{
 -    CBDATA_INIT_TYPE(acl_access);
 -    acl_access *result = cbdataAlloc(acl_access);
 -    return result;
 -}
 -
 -void
 -acl_access::operator delete (void *address)
 -{
 -    acl_access *t = static_cast<acl_access *>(address);
 -    cbdataFree(t);
 -}
 -
 -/// XXX: Temporary hack to allow old ACL code to handle quoted values without
++/// Temporary hack to allow old ACL code to handle quoted values without
+ /// replacing every strtok() call.
+ char *
+ ACL::strtok(char *str, const char *delimiters)
+ {
+     return xstrtok(str, delimiters);
+ }
  ACL::Prototype::Prototype() : prototype (NULL), typeString (NULL) {}
  
  ACL::Prototype::Prototype (ACL const *aPrototype, char const *aType) : prototype (aPrototype), typeString (aType)
diff --cc src/acl/Acl.h
index 6b82937f44afe2631f5190e952eb94896174f1fc,168293ba5b739d2fb3538eb121d86987927ec769..a4f4bee0000bdfb397388a500c7b63b1c418480c
@@@ -163,14 -152,8 +163,17 @@@ public
          void registerMe();
      };
  
 +private:
 +    /// Matches the actual data in checklist against this ACL.
 +    virtual int match(ACLChecklist *checklist) = 0; // XXX: missing const
 +
 +    /// whether our (i.e. shallow) match() requires checklist to have a request
 +    virtual bool requiresRequest() const;
 +    /// whether our (i.e. shallow) match() requires checklist to have a reply
 +    virtual bool requiresReply() const;
++
+ protected:
+     static char *strtok(char *str, const char *delimiters);
  };
  
  /// \ingroup ACLAPI
diff --cc src/cache_cf.cc
index 2661a82105cdbeb38f92fe920717520d7b1989ea,fcd2701efc8e0b96a2730a25115681e2f959da91..66839abdbe671e0481ade291a8b566fa37b84036
@@@ -1290,15 -1286,11 +1290,16 @@@ parseBytesUnits(const char *unit
   *****************************************************************************/
  
  static void
 -dump_acl(StoreEntry * entry, const char *name, ACL * ae)
 +dump_wordlist(StoreEntry * entry, wordlist *words)
  {
 -    wordlist *w;
 -    wordlist *v;
 +    for (wordlist *word = words; word; word = word->next)
++        // XXX: use something like ConfigParser::QuoteString() here
 +        storeAppendPrintf(entry, "%s ", word->key);
 +}
  
 +static void
 +dump_acl(StoreEntry * entry, const char *name, ACL * ae)
 +{
      while (ae != NULL) {
          debugs(3, 3, "dump_acl: " << name << " " << ae->name);
          storeAppendPrintf(entry, "%s %s %s %s ",
diff --cc src/cf.data.pre
index b2a7b010a5acbf2360583b7b842cad59d9fa22cc,7d642a3aa706c3f56c7550e75937b0975e0bdc8e..e3a30f263a3e81da66b3397d19a0bf603b6d4082
@@@ -65,6 -65,19 +65,20 @@@ COMMENT_STAR
    configuration files.
  
  
 -      XXX: Document escaping and macro substitution rules inside quoted
 -      strings.
+   Values with spaces, quotes, and other special characters
+       Squid supports directive parameters with spaces, quotes, and other
+       special characters. Surround such parameters with "double quotes". Use
+       the configuration_includes_quoted_values directive to enable or
+       disable that support.
 -      XXX: Support single-quoted strings that prevent macro substitution.
++      For example;
++              configuration_includes_quoted_values on
++              acl group external groupCheck Administrators "Internet Users" Guest
++              configuration_includes_quoted_values off
    Conditional configuration
  
        If-statements can be used to make configuration directives
@@@ -8464,6 -8155,17 +8478,35 @@@ COMMENT_STAR
   -----------------------------------------------------------------------------
  COMMENT_END
  
 -DEFAULT: on
+ NAME: configuration_includes_quoted_values
+ COMMENT: on|off
+ TYPE: onoff
 -      If set, Squid will recognize each "quoted string" as a single
 -      configuration directive parameter. The quotes are stripped before the
 -      parameter value is interpreted or used. XXX: Give more details.
++DEFAULT: off
+ LOC: ConfigParser::RecognizeQuotedValues
+ DOC_START
++      Previous Squid versions have defined "quoted/string" as syntax for
++      ACL to signifiy the value is an included file containing values and
++      has treated the " characters in other places of the configuration file
++      as part of the parameter value it was used for.
++
++      For compatibility with existing installations that behaviour
++      remains the default.
++
++      If this directive is set to 'on', Squid will start parsing each
++      "quoted string" as a single configuration directive parameter. The
++      quotes are stripped before the parameter value is interpreted or use.
++
++      That will continue for all lines until this directive is set to 'off',
++      where Squid will return to the default configuration parsing.
++
++      For example;
++
++              configuration_includes_quoted_values on
++              acl group external groupCheck Administrators "Internet Users" Guest
++              configuration_includes_quoted_values off
++
+ DOC_END
  NAME: memory_pools
  COMMENT: on|off
  TYPE: onoff