From: Amos Jeffries Date: Sat, 19 Apr 2008 02:09:36 +0000 (-0600) Subject: Author: Henrik Nordstrom X-Git-Tag: SQUID_3_0_STABLE5~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ae019f59e8940e04a8e480163359c711b92ca9e;p=thirdparty%2Fsquid.git Author: Henrik Nordstrom Add support for the resolv.conf domain directive, and also automatically derived default domain This patch adds the domain resolv.conf directive, similar to search but only accepting a single domain. In addition it adds support for automatically deriving the domain from the fully qualified hostname. --- diff --git a/src/dns_internal.cc b/src/dns_internal.cc index a04aa6f394..a561f280b3 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -288,7 +288,7 @@ idnsParseResolvConf(void) { FILE *fp; char buf[RESOLV_BUFSZ]; - char *t; + const char *t; fp = fopen(_PATH_RESCONF, "r"); if (fp == NULL) { @@ -315,7 +315,18 @@ idnsParseResolvConf(void) debugs(78, 1, "Adding nameserver " << t << " from " << _PATH_RESCONF); idnsAddNameserver(t); + } else if (strcasecmp(t, "domain") == 0) { + idnsFreeSearchpath(); + t = strtok(NULL, w_space); + + if (NULL == t) + continue; + + debugs(78, 1, "Adding domain " << t << " from " << _PATH_RESCONF); + + idnsAddPathComponent(t); } else if (strcasecmp(t, "search") == 0) { + idnsFreeSearchpath(); while (NULL != t) { t = strtok(NULL, w_space); @@ -344,6 +355,11 @@ idnsParseResolvConf(void) } } } + if (npc == 0 && (t = getMyHostname())) { + t = strchr(t, '.'); + if (t) + idnsAddPathComponent(t+1); + } fclose(fp); }