--------------------- PatchSet 4505 Date: 2002/07/16 10:04:19 Author: serassio Branch: cygwin Tag: (none) Log: Experimental hosts file location handling Members: configure.in:1.8.2.37->1.8.2.38 src/Makefile.am:1.2.6.15->1.2.6.16 src/cf.data.pre:1.10.2.31->1.10.2.32 src/tools.c:1.7.2.26->1.7.2.27 src/win32.c:1.1.50.18->1.1.50.19 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.8.2.37 retrieving revision 1.8.2.38 diff -u -r1.8.2.37 -r1.8.2.38 --- squid/configure.in 16 Jul 2002 09:57:54 -0000 1.8.2.37 +++ squid/configure.in 16 Jul 2002 10:04:19 -0000 1.8.2.38 @@ -3,7 +3,7 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.8.2.37 2002/07/16 09:57:54 serassio Exp $ +dnl $Id: configure.in,v 1.8.2.38 2002/07/16 10:04:19 serassio Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE(squid, 2.6-DEVEL) AM_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.8.2.37 $)dnl +AC_REVISION($Revision: 1.8.2.38 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -880,6 +880,26 @@ fi ]) +dnl Select Default hosts file location +AC_ARG_ENABLE(default-hostsfile, +[ --enable-default-hostsfile=path + Select default location for hosts file. + See hosts_file directive in squid.conf for details], +[ + if test "$enableval" != "none" ; then + if test -f $enableval; then + OPT_DEFAULT_HOSTS=$enableval + else + echo "ERROR! Unable to find $enableval" + exit 1 + fi + else + OPT_DEFAULT_HOSTS="none" + fi + echo "Default hosts file set to: $enableval" +],[OPT_DEFAULT_HOSTS="/etc/hosts"]) +AC_SUBST(OPT_DEFAULT_HOSTS) + dnl Select auth schemes modules to build AC_ARG_ENABLE(auth, Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.2.6.15 retrieving revision 1.2.6.16 diff -u -r1.2.6.15 -r1.2.6.16 --- squid/src/Makefile.am 15 Jul 2002 09:09:05 -0000 1.2.6.15 +++ squid/src/Makefile.am 16 Jul 2002 10:04:19 -0000 1.2.6.16 @@ -283,6 +283,7 @@ DEFAULT_ICON_DIR = $(datadir)/icons DEFAULT_ERROR_DIR = $(datadir)/errors/@ERR_DEFAULT_LANGUAGE@ DEFAULT_MIB_PATH = $(datadir)/mib.txt +DEFAULT_HOSTS = @OPT_DEFAULT_HOSTS@ DEFS = @DEFS@ -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" @@ -332,7 +333,8 @@ s%@DEFAULT_ICON_DIR@%$(DEFAULT_ICON_DIR)%g;\ s%@DEFAULT_MIB_PATH@%$(DEFAULT_MIB_PATH)%g;\ s%@DEFAULT_ERROR_DIR@%$(DEFAULT_ERROR_DIR)%g;\ - s%@DEFAULT_PREFIX@%$(DEFAULT_PREFIX)%g;"\ + s%@DEFAULT_PREFIX@%$(DEFAULT_PREFIX)%g;\ + s%@DEFAULT_HOSTS@%$(DEFAULT_HOSTS)%g;"\ < $(srcdir)/cf.data.pre >$@ store_modules.c: store_modules.sh Makefile Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf.data.pre,v retrieving revision 1.10.2.31 retrieving revision 1.10.2.32 diff -u -r1.10.2.31 -r1.10.2.32 --- squid/src/cf.data.pre 15 Jul 2002 09:09:05 -0000 1.10.2.31 +++ squid/src/cf.data.pre 16 Jul 2002 10:04:19 -0000 1.10.2.32 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.10.2.31 2002/07/15 09:09:05 serassio Exp $ +# $Id: cf.data.pre,v 1.10.2.32 2002/07/16 10:04:19 serassio Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1170,15 +1170,17 @@ NAME: hosts_file TYPE: string -DEFAULT: $SYSNETDBHOSTS +DEFAULT: @DEFAULT_HOSTS@ LOC: Config.etcHostsPath DOC_START Location of the host-local IP name-address associations database. Most Operating Systems have such a file on different default locations: - - Un*X: /etc/hosts + - Un*X & Linux: /etc/hosts - Windows NT/2000: %SystemRoot%\system32\drivers\etc\hosts (%SystemRoot% value install default is c:\winnt) + - Windows XP: %SystemRoot%\system32\drivers\etc\hosts + (%SystemRoot% value install default is c:\windows) - Windows 9x/Me: %windir%\hosts (%windir% value is usually c:\windows) - Cygwin: /etc/hosts and, if not found here, Windows default @@ -1189,9 +1191,7 @@ character are comments. The file is checked at startup and upon configuration. - If set to 'none', it won't be checked. If set to special value - "$SYSNETDBHOSTS", it will be searched in the default Operating - System location specified above. + If set to 'none', it won't be checked. If append_domain is used, that domain will be added to domain-local (i.e. not containing any dot character) host definitions. Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.7.2.26 retrieving revision 1.7.2.27 diff -u -r1.7.2.26 -r1.7.2.27 --- squid/src/tools.c 21 May 2002 09:26:30 -0000 1.7.2.26 +++ squid/src/tools.c 16 Jul 2002 10:04:20 -0000 1.7.2.27 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.7.2.26 2002/05/21 09:26:30 serassio Exp $ + * $Id: tools.c,v 1.7.2.27 2002/07/16 10:04:20 serassio Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -938,31 +938,17 @@ FILE *fp; char buf[1024]; char buf2[512]; - char *hosts_file = NULL; char *nt = buf; char *lt = buf; - char *addr = buf; - char *host = NULL; - safe_free(hosts_file); if (NULL == Config.etcHostsPath) return; if (0 == strcmp(Config.etcHostsPath, "none")) return; - if (0 == strcmp(Config.etcHostsPath, "$SYSNETDBHOSTS")) { - if (sys_network_db_hosts == NULL) - sys_network_db_hosts = xstrdup(DEFAULT_SYS_NETWORK_DB_HOSTS); - hosts_file = xstrdup(sys_network_db_hosts); - } - else - hosts_file = xstrdup(Config.etcHostsPath); - debug(1, 5) ("etc_hosts: host files is configured as '%s', resolved to '%s'\n", - Config.etcHostsPath, hosts_file); - fp = fopen(hosts_file, "r"); + fp = fopen(Config.etcHostsPath, "r"); if (fp == NULL) { debug(1, 1) ("parseEtcHosts: %s: %s\n", - hosts_file, xstrerror()); - safe_free(hosts_file); + Config.etcHostsPath, xstrerror()); return; } #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) @@ -1008,7 +994,6 @@ skip: wordlistDestroy(&hosts); } - safe_free(hosts_file); } int Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.1.50.18 retrieving revision 1.1.50.19 diff -u -r1.1.50.18 -r1.1.50.19 --- squid/src/win32.c 29 Jun 2002 21:14:52 -0000 1.1.50.18 +++ squid/src/win32.c 16 Jul 2002 10:04:20 -0000 1.1.50.19 @@ -32,58 +32,11 @@ #include static unsigned int GetOSVersion(); -static void Set_sys_network_db_hosts(); - -#define DATABASEPATH "DataBasePath" - -static char TCP_REGKEY[256] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"; /* ====================================================================== */ /* LOCAL FUNCTIONS */ /* ====================================================================== */ -static void -Set_sys_network_db_hosts() -{ - HKEY hndKey; - char *RegValue = NULL; - DWORD Size = 0; -#ifdef _SQUID_CYGWIN_ - FILE * fp; - /* Checks if exist /etc/hosts on Cygwin */ - if ((fp = fopen(DEFAULT_SYS_NETWORK_DB_HOSTS, "r")) != NULL) { - fclose (fp); - return; - } -#endif - safe_free(RegValue); - switch (WIN32_OS_version) { - case _WIN_OS_WINNT: - case _WIN_OS_WIN2K: - case _WIN_OS_WINXP: - /* get hosts file location from Windows Registry */ - if (RegOpenKey(HKEY_LOCAL_MACHINE, TCP_REGKEY, &hndKey) == ERROR_SUCCESS) { - DWORD Type = 0; - RegQueryValueEx(hndKey, DATABASEPATH, NULL, &Type, NULL, &Size); - RegValue = xmalloc(Size + sizeof(_WIN_HOSTS_FILENAME) + 1); - RegQueryValueEx(hndKey, DATABASEPATH, NULL, &Type, RegValue, &Size); - RegCloseKey(hndKey); - } - break; - case _WIN_OS_WIN95: - case _WIN_OS_WIN98: - case _WIN_OS_WINME: - RegValue = xmalloc(sizeof(_WIN95_NETWORK_DB_HOSTS) + sizeof(_WIN_HOSTS_FILENAME) + 1); - strcpy(RegValue, _WIN95_NETWORK_DB_HOSTS); - break; - } - strcat(RegValue, _WIN_HOSTS_FILENAME); - Size = ExpandEnvironmentStrings(RegValue, NULL, 1) + 1; - safe_free(sys_network_db_hosts); - sys_network_db_hosts = xmalloc(Size); - ExpandEnvironmentStrings(RegValue, sys_network_db_hosts, Size); - safe_free(RegValue); -} static unsigned int GetOSVersion() @@ -156,7 +109,6 @@ return 1; if (atexit(WIN32_Exit) != 0) return 1; - Set_sys_network_db_hosts(); return 0; } #endif