]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cygwin: re-enable /etc/resolv.conf parsing
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 15 Sep 2014 01:21:36 +0000 (18:21 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 15 Sep 2014 01:21:36 +0000 (18:21 -0700)
idnsParseResolvConf() had been disabled for all windows builds. Cygwin
does provide this system config file.

Also, instead of seeding #if/#endif wrappers around always call the
function and just wrap its internals away from Windows builds that do
not supply the necessary config file.

src/dns_internal.cc

index 21b832b3af9c73acda9ac8090449a64305abb52f..8650537dc8928902bcf618c5d4b8acdb611786f1 100644 (file)
@@ -212,9 +212,7 @@ static void idnsAddPathComponent(const char *buf);
 static void idnsFreeNameservers(void);
 static void idnsFreeSearchpath(void);
 static bool idnsParseNameservers(void);
-#if _SQUID_WINDOWS_
 static bool idnsParseResolvConf(void);
-#endif
 #if _SQUID_WINDOWS_
 static bool idnsParseWIN32Registry(void);
 static void idnsParseWIN32SearchList(const char *);
@@ -379,15 +377,12 @@ idnsParseNameservers(void)
     return result;
 }
 
-#if !_SQUID_WINDOWS_
 static bool
 idnsParseResolvConf(void)
 {
-    FILE *fp;
-    char buf[RESOLV_BUFSZ];
-    const char *t;
     bool result = false;
-    fp = fopen(_PATH_RESCONF, "r");
+#if !_SQUID_WINDOWS_ || _SQUID_CYGWIN_
+    FILE *fp = fopen(_PATH_RESCONF, "r");
 
     if (fp == NULL) {
         debugs(78, DBG_IMPORTANT, "" << _PATH_RESCONF << ": " << xstrerror());
@@ -398,6 +393,8 @@ idnsParseResolvConf(void)
     setmode(fileno(fp), O_TEXT);
 #endif
 
+    char buf[RESOLV_BUFSZ];
+    const char *t = NULL;
     while (fgets(buf, RESOLV_BUFSZ, fp)) {
         t = strtok(buf, w_space);
 
@@ -460,11 +457,10 @@ idnsParseResolvConf(void)
     }
 
     fclose(fp);
+#endif
     return result;
 }
 
-#endif
-
 #if _SQUID_WINDOWS_
 static void
 idnsParseWIN32SearchList(const char * Separator)
@@ -1568,12 +1564,10 @@ dnsInit(void)
     assert(0 == nns);
     idnsAddMDNSNameservers();
     bool nsFound = idnsParseNameservers();
-#if !_SQUID_WINDOWS_
 
     if (!nsFound)
         nsFound = idnsParseResolvConf();
 
-#endif
 #if _SQUID_WINDOWS_
     if (!nsFound)
         nsFound = idnsParseWIN32Registry();