From: Henrik Nordstrom Date: Wed, 16 Apr 2008 00:32:34 +0000 (+0200) Subject: Add support for the resolv.conf domain directive, and also automatically derived... X-Git-Tag: SQUID_3_1_0_1~49^2~286 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a083e75a002cf3acab30389343572f1d9c87c78e;p=thirdparty%2Fsquid.git 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 3aed082c30..ae2c50af09 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -290,7 +290,7 @@ idnsParseResolvConf(void) { FILE *fp; char buf[RESOLV_BUFSZ]; - char *t; + const char *t; fp = fopen(_PATH_RESCONF, "r"); if (fp == NULL) { @@ -317,7 +317,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); @@ -346,6 +357,11 @@ idnsParseResolvConf(void) } } } + if (npc == 0 && (t = getMyHostname())) { + t = strchr(t, '.'); + if (t) + idnsAddPathComponent(t+1); + } fclose(fp); }