From: Amos Jeffries Date: Tue, 22 May 2018 12:55:35 +0000 (+0000) Subject: Bug 4707: purge tool does not obey --sysconfdir= build option (#210) X-Git-Tag: SQUID_4_0_25~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eeefe741c7401a1943b034bf6bf31ccdb0ecd54e;p=thirdparty%2Fsquid.git Bug 4707: purge tool does not obey --sysconfdir= build option (#210) The purge tool was still using DEFAULT_SQUID_CONF macro from before it was bundled with Squid, which had no connection to our ./configure script. Update it to the DEFAULT_CONFIG_FILE macro used by other Squid binaries and fix some existing issues with that macro's use by binaries outside 'squid'. --- diff --git a/src/Common.am b/src/Common.am index 1ff831d6c5..3ec9ccc79e 100644 --- a/src/Common.am +++ b/src/Common.am @@ -36,6 +36,11 @@ AM_CFLAGS = $(SQUID_CFLAGS) AM_CXXFLAGS = $(SQUID_CXXFLAGS) DEFS = @DEFS@ +# Make ./configure location settings above available to the code +DEFS += -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" \ + -DDEFAULT_SQUID_DATA_DIR=\"$(datadir)\" \ + -DDEFAULT_SQUID_CONFIG_DIR=\"$(sysconfdir)\" + ## so that others can always use += for these variables CLEANFILES = check_PROGRAMS = diff --git a/src/Makefile.am b/src/Makefile.am index acc0520089..5467f5a713 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -728,9 +728,6 @@ EXTRA_DIST = \ mib.txt \ mime.conf.default -# Make location configure settings available to the code -DEFS += -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" -DDEFAULT_SQUID_DATA_DIR=\"$(datadir)\" -DDEFAULT_SQUID_CONFIG_DIR=\"$(sysconfdir)\" - snmp_core.o snmp_agent.o: ../lib/snmplib/libsnmplib.la $(top_srcdir)/include/cache_snmp.h globals.cc: globals.h mk-globals-c.awk diff --git a/src/WinSvc.cc b/src/WinSvc.cc index 685fef196f..60432434f8 100644 --- a/src/WinSvc.cc +++ b/src/WinSvc.cc @@ -517,7 +517,7 @@ int WIN32_Subsystem_Init(int * argc, char *** argv) ConfigFile = static_cast(xmalloc(Size)); RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, (unsigned char *)ConfigFile, &Size); } else - ConfigFile = xstrdup(DefaultConfigFile); + ConfigFile = xstrdup(DEFAULT_CONFIG_FILE); Size = 0; @@ -533,7 +533,7 @@ int WIN32_Subsystem_Init(int * argc, char *** argv) RegCloseKey(hndKey); } else { - ConfigFile = xstrdup(DefaultConfigFile); + ConfigFile = xstrdup(DEFAULT_CONFIG_FILE); WIN32_Service_Command_Line = xstrdup(""); } @@ -778,7 +778,7 @@ WIN32_InstallService() /* Now store the config file location in the registry */ if (!ConfigFile) - ConfigFile = xstrdup(DefaultConfigFile); + ConfigFile = xstrdup(DEFAULT_CONFIG_FILE); WIN32_StoreKey(CONFIGFILE, REG_SZ, (unsigned char *) ConfigFile, strlen(ConfigFile) + 1); diff --git a/src/globals.h b/src/globals.h index 588c8a0d5f..b8b4ef0d4e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -24,7 +24,6 @@ extern char ThisCache2[RFC2181_MAXHOSTNAMELEN << 1]; extern char config_input_line[BUFSIZ]; /// During parsing, the name of the current squid.conf directive being parsed. extern const char *cfg_directive; /* NULL */ -extern const char *DefaultConfigFile; /* DEFAULT_CONFIG_FILE */ extern const char *cfg_filename; /* NULL */ extern const char *dash_str; /* "-" */ extern const char *null_string; /* "" */ diff --git a/src/icmp/Makefile.am b/src/icmp/Makefile.am index d8f61d30d5..98b4f0137a 100644 --- a/src/icmp/Makefile.am +++ b/src/icmp/Makefile.am @@ -8,11 +8,6 @@ include $(top_srcdir)/src/Common.am include $(top_srcdir)/src/TestHeaders.am -# TODO: get rid of this when config filename is no longer a global constant. -# its only here so the pinger globals.cc will link. -DEFS += -DDEFAULT_CONFIG_FILE=NULL - - # ICMP Specific Configurations if ENABLE_PINGER diff --git a/src/main.cc b/src/main.cc index 0e17be587c..19f096fe44 100644 --- a/src/main.cc +++ b/src/main.cc @@ -406,7 +406,7 @@ usage(void) " -S Double-check swap during rebuild.\n" " -X Force full debugging.\n" " -Y Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.\n", - APP_SHORTNAME, CACHE_HTTP_PORT, DefaultConfigFile, CACHE_ICP_PORT); + APP_SHORTNAME, CACHE_HTTP_PORT, DEFAULT_CONFIG_FILE, CACHE_ICP_PORT); exit(EXIT_FAILURE); } @@ -1540,7 +1540,7 @@ SquidMain(int argc, char **argv) int parse_err; if (!ConfigFile) - ConfigFile = xstrdup(DefaultConfigFile); + ConfigFile = xstrdup(DEFAULT_CONFIG_FILE); assert(!configured_once); diff --git a/tools/purge/conffile.hh b/tools/purge/conffile.hh index 055730b34a..7edfdb1ad2 100644 --- a/tools/purge/conffile.hh +++ b/tools/purge/conffile.hh @@ -55,11 +55,6 @@ typedef int bool; #endif #endif /* __cplusplus */ - -#if !defined(DEFAULT_SQUID_CONF) -#define DEFAULT_SQUID_CONF "/usr/local/squid/etc/squid.conf" -#endif - #include struct CacheDir { @@ -75,7 +70,7 @@ typedef std::vector CacheDirVector; int readConfigFile( CacheDirVector& cachedir, - const char* fn = DEFAULT_SQUID_CONF, + const char* fn, FILE* debug = 0 ); // purpose: read squid.conf file and extract cache_dir entries // paramtr: cachedir (OUT): vector with an entry for each cache_dir found diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc index b2339b4ce6..321ff74bae 100644 --- a/tools/purge/purge.cc +++ b/tools/purge/purge.cc @@ -615,7 +615,7 @@ helpMe( void ) "\t0 and 1 are recommended - slow rebuild your cache with other modes.\n" " -s\tshow all options after option parsing, but before really starting.\n" " -v\tshow more information about the file, e.g. MD5, timestamps and flags.\n" - "\n", DEFAULT_SQUID_CONF, DEFAULTHOST, DEFAULTPORT ); + "\n", DEFAULT_CONFIG_FILE, DEFAULTHOST, DEFAULTPORT ); } @@ -890,7 +890,7 @@ main( int argc, char* argv[] ) { // setup variables REList* list = 0; - char* conffile = xstrdup( DEFAULT_SQUID_CONF ); + char* conffile = xstrdup(DEFAULT_CONFIG_FILE); serverPort = htons(DEFAULTPORT); if ( convertHostname(DEFAULTHOST,serverHost) == -1 ) { fprintf( stderr, "unable to resolve host %s!\n", DEFAULTHOST );