Re: includes inside squid.conf

Date: Tue, 2 Apr 2002 16:32:39 +0200

Just my tiny (and rather trivial) grain of salt on this include

We could add a patch to make the configure file optionally
preprocessed by an external command. A solution could be that if the
configure path (usually /etc/squid.conf) starts with a '!' then it is
a command to be piped. The patch is really trivial:

--- src/cache_cf.c Mon Mar 11 13:13:03 2002
+++ ../../tmp/ Tue Apr 2 16:23:47 2002
@@ -237,9 +237,15 @@
     char *token = NULL;
     char *tmp_line;
     int err_count = 0;
+ int ispipe=0;
- if ((fp = fopen(file_name, "r")) == NULL)
+ if (file_name[0]=='!') {
+ ispipe=1;
+ fp = popen(file_name+1, "r");
+ } else
+ fp = fopen(file_name, "r");
+ if (fp == NULL)
        fatalf("Unable to open configuration file: %s: %s",
            file_name, xstrerror());
 #if defined(_SQUID_CYGWIN_)
@@ -268,7 +274,10 @@
- fclose(fp);
+ if (ispipe)
+ pclose(fp);
+ else
+ fclose(fp);

what is missing in the above patch is the reporting of error (by
taking into account any #line comments produced by the pipe)

To use my untested patch with m4, just run squid with
-f '! m4 squid.conf.m4'

To use it with cpp, try
-f '/ cpp squid.conf.cpp'

regarding the hot debate about inclusion, I rather agree with Henrik
Nordstrom (so disagree with Andres Kroonmaa) - inclusion should only
take into account the file path names, not the inode....

Another possibility would be to adopt some XML syntax for Squid
configuration file. (This might make its generation cleaner).

regards to all

N.B. Any opinions expressed here are only mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.

Basile STARYNKEVITCH ---- Commissariat l Energie Atomique * France
DRT/LIST/DTSI/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX
phone:+33 1,6908.6055; fax: 1,6908.8395 home: 1,4665.4553; mobile: 6,8501.2359
work email: Basile point Starynkevitch at cea point fr
home email: Basile at Starynkevitch point net
Received on Tue Apr 02 2002 - 17:38:59 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:56 MST