]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: hno
authoramosjeffries <>
Tue, 26 Feb 2008 06:41:50 +0000 (06:41 +0000)
committeramosjeffries <>
Tue, 26 Feb 2008 06:41:50 +0000 (06:41 +0000)
make include support wildcards, and document the directive (copied from squid-2)

src/cache_cf.cc
src/cf.data.pre

index 50ae1b898ad9196a02a975ef463d7a1e6e0945d7..16edc1750f4bb61767053b0bab1f431be138ad3d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.528.2.4 2008/02/25 23:40:55 amosjeffries Exp $
+ * $Id: cache_cf.cc,v 1.528.2.5 2008/02/25 23:41:50 amosjeffries Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -46,6 +46,7 @@
 #include "Parsing.h"
 #include "MemBuf.h"
 #include "wordlist.h"
+#include <glob.h>
 
 #if SQUID_SNMP
 #include "snmp.h"
@@ -210,11 +211,20 @@ parseManyConfigFiles(char* files, int depth)
 {
     int error_count = 0;
     char* saveptr = NULL;
-    char* file = strwordtok(files, &saveptr);
-    while (file != NULL) {
-        error_count += parseOneConfigFile(file, depth);
-        file = strwordtok(NULL, &saveptr);
-    }
+    char *path;
+    glob_t globbuf;
+    int i;
+    memset(&globbuf, 0, sizeof(globbuf));
+    for (path = strwordtok(files, &saveptr); path; path = strwordtok(NULL, &saveptr)) {
+       if (glob(path, globbuf.gl_pathc ? GLOB_APPEND : 0, NULL, &globbuf) != 0) {
+           fatalf("Unable to find configuration file: %s: %s",
+               path, xstrerror());
+       }
+     }
+    for (i = 0; i < (int)globbuf.gl_pathc; i++) {
+       error_count += parseOneConfigFile(globbuf.gl_pathv[i], depth);
+    }
+    globfree(&globbuf);
     return error_count;
 }
 
index 4daf82ece6413a6cb76710f3f7c143ebdb1bd941..2605ca122cb70cd36965badaf297c999735161d1 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.488.2.3 2008/02/25 03:01:00 amosjeffries Exp $
+# $Id: cf.data.pre,v 1.488.2.4 2008/02/25 23:41:50 amosjeffries Exp $
 #
 # SQUID Web Proxy Cache                http://www.squid-cache.org/
 # ----------------------------------------------------------
@@ -47,6 +47,21 @@ COMMENT_START
 
 COMMENT_END
 
+COMMENT_START
+  Configuration options can be included using the "include" directive.
+  Include takes a list of files to include. Quoting and wildcards is
+  supported.
+
+  For example,
+
+  include /path/to/included/file/squid.acl.config
+
+  Includes can be nested up to a hard-coded depth of 16 levels.
+  This arbitrary restriction is to prevent recursive include references
+  from causing Squid entering an infinite loop whilst trying to load
+  configuration files.
+COMMENT_END
+
 COMMENT_START
  OPTIONS FOR AUTHENTICATION
  -----------------------------------------------------------------------------