Re: PATCH: win32 hosts file location

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Sat, 18 Aug 2001 11:40:27 +0200

Guido Serassio wrote:.

> 1) Read from the registry value
> HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath the
> Hosts file location (but this step can be safely skipped, because i never
> seen this value changed from %SystemRoot%\System32\drivers\etc).
> 2) Resolve %SistemRoot%
> 3) Read Hosts file.
>
> Another thing: using static paths, on dual boot systems can happen everything.

Nobody is talking about "static" paths.

I did not know about '1'. This makes things a little different.

What about this: For win32, substitute /etc/ by the system networking database
path before opening the file. I.e. something like the attached diff + what is
missing (see the diff).

--
Henrik

Index: tools.c
===================================================================
RCS file: /cvsroot/squid/squid/src/tools.c,v
retrieving revision 1.15
diff -u -w -r1.15 tools.c
--- tools.c 2001/08/16 07:39:03 1.15
+++ tools.c 2001/08/18 09:38:07
@@ -976,6 +976,32 @@
     if (0 == strcmp(Config.etcHostsPath, "none"))
         return;
     fp = fopen(Config.etcHostsPath, "r");
+#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
+ if (fp == NULL && strncmp(Config.etcHostsPath, "/etc/") == 0) {
+ switch (WIN32_OS_version) {
+ case _WIN_OS_WINNT:
+ case _WIN_OS_WIN2K:
+ case _WIN_OS_WINXP:
+ /* XXX Bug: This should look into registry
+ * HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath
+ */
+ if ((systemroot = getenv("SYSTEMROOT")) != NULL) {
+ strcpy(buf, systemroot);
+ strcat(buf, "\\system32\\drivers\\etc");
+ }
+ break;
+ case _WIN_OS_WIN95:
+ case _WIN_OS_WIN98:
+ if ((systemroot=getenv("WINDIR")) != NULL) {
+ strcpy(buf,systemroot);
+ }
+ break;
+ }
+ strcat(buf, "\\");
+ strcat(buf, Config.etcHostsPath + strlen("/etc/"));
+ fp = fopen(buf, "r");
+ }
+#endif
     if (fp == NULL) {
         debug(1, 1) ("parseEtcHosts: %s: %s\n",
             Config.etcHostsPath, xstrerror());
Received on Sat Aug 18 2001 - 03:41:37 MDT

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