Don't override explicitly specified search domains

Only set search domains from /etc/resolv.conf if there isn't a value
already present in the channel.
pull/17/head
David Drysdale 11 years ago committed by Jakub Hrozek
parent ee22246507
commit 7df69c0f79
  1. 8
      ares_init.c

@ -1153,20 +1153,24 @@ static int init_by_resolv_conf(ares_channel channel)
FILE *fp;
size_t linesize;
int error;
int update_domains;
/* Don't read resolv.conf and friends if we don't have to */
if (ARES_CONFIG_CHECK(channel))
return ARES_SUCCESS;
/* Only update search domains if they're not already specified */
update_domains = (channel->ndomains == -1);
fp = fopen(PATH_RESOLV_CONF, "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "domain", ';')))
if ((p = try_config(line, "domain", ';')) && update_domains)
status = config_domain(channel, p);
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups)
status = config_lookup(channel, p, "bind", "file");
else if ((p = try_config(line, "search", ';')))
else if ((p = try_config(line, "search", ';')) && update_domains)
status = set_search(channel, p);
else if ((p = try_config(line, "nameserver", ';')) &&
channel->nservers == -1)

Loading…
Cancel
Save