- Henrik Stoerner: found out that C-ARES does not look at the /etc/host.conf
file to determine the sequence in which to search /etc/hosts and DNS. So on systems where this order is defined by /etc/host.conf instead of a "lookup" entry in /etc/resolv.conf, C-ARES will always default to looking in DNS first, and /etc/hosts second. c-ares now looks at 1) resolv.conf (for the "lookup" line); 2) nsswitch.fon (for the "hosts:" line); 3) host.conf (for the "order" line). First match wins.
This commit is contained in:
parent
12dc142a28
commit
3451e888b9
14
ares/CHANGES
14
ares/CHANGES
@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
* September 26
|
* September 26
|
||||||
|
|
||||||
|
- Henrik Stoerner: found out that C-ARES does not look at the /etc/host.conf
|
||||||
|
file to determine the sequence in which to search /etc/hosts and DNS. So on
|
||||||
|
systems where this order is defined by /etc/host.conf instead of a "lookup"
|
||||||
|
entry in /etc/resolv.conf, C-ARES will always default to looking in DNS
|
||||||
|
first, and /etc/hosts second.
|
||||||
|
|
||||||
|
c-ares now looks at
|
||||||
|
|
||||||
|
1) resolv.conf (for the "lookup" line);
|
||||||
|
2) nsswitch.fon (for the "hosts:" line);
|
||||||
|
3) host.conf (for the "order" line).
|
||||||
|
|
||||||
|
First match wins.
|
||||||
|
|
||||||
- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is
|
- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is
|
||||||
located in a static location. It assumed
|
located in a static location. It assumed
|
||||||
C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact,
|
C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact,
|
||||||
|
@ -55,7 +55,8 @@ static int init_by_environment(ares_channel channel);
|
|||||||
static int init_by_resolv_conf(ares_channel channel);
|
static int init_by_resolv_conf(ares_channel channel);
|
||||||
static int init_by_defaults(ares_channel channel);
|
static int init_by_defaults(ares_channel channel);
|
||||||
static int config_domain(ares_channel channel, char *str);
|
static int config_domain(ares_channel channel, char *str);
|
||||||
static int config_lookup(ares_channel channel, const char *str);
|
static int config_lookup(ares_channel channel, const char *str,
|
||||||
|
const char *bindch, const char *filech);
|
||||||
static int config_nameserver(struct server_state **servers, int *nservers,
|
static int config_nameserver(struct server_state **servers, int *nservers,
|
||||||
char *str);
|
char *str);
|
||||||
static int config_sortlist(struct apattern **sortlist, int *nsort,
|
static int config_sortlist(struct apattern **sortlist, int *nsort,
|
||||||
@ -549,7 +550,7 @@ DhcpNameServer
|
|||||||
if ((p = try_config(line, "domain")))
|
if ((p = try_config(line, "domain")))
|
||||||
status = config_domain(channel, p);
|
status = config_domain(channel, p);
|
||||||
else if ((p = try_config(line, "lookup")) && !channel->lookups)
|
else if ((p = try_config(line, "lookup")) && !channel->lookups)
|
||||||
status = config_lookup(channel, p);
|
status = config_lookup(channel, p, "bind", "file");
|
||||||
else if ((p = try_config(line, "search")))
|
else if ((p = try_config(line, "search")))
|
||||||
status = set_search(channel, p);
|
status = set_search(channel, p);
|
||||||
else if ((p = try_config(line, "nameserver")) && channel->nservers == -1)
|
else if ((p = try_config(line, "nameserver")) && channel->nservers == -1)
|
||||||
@ -563,9 +564,33 @@ DhcpNameServer
|
|||||||
if (status != ARES_SUCCESS)
|
if (status != ARES_SUCCESS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
if (!channel->lookups) {
|
||||||
|
fp = fopen("/etc/nsswitch.conf", "r");
|
||||||
|
if (fp) {
|
||||||
|
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((p = try_config(line, "hosts:")) && !channel->lookups)
|
||||||
|
status = config_lookup(channel, p, "dns", "files");
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!channel->lookups) {
|
||||||
|
fp = fopen("/etc/host.conf", "r");
|
||||||
|
if (fp) {
|
||||||
|
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((p = try_config(line, "order")) && !channel->lookups)
|
||||||
|
status = config_lookup(channel, p, "bind", "hosts");
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(line)
|
if(line)
|
||||||
free(line);
|
free(line);
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -679,7 +704,8 @@ static int config_domain(ares_channel channel, char *str)
|
|||||||
return set_search(channel, str);
|
return set_search(channel, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_lookup(ares_channel channel, const char *str)
|
static int config_lookup(ares_channel channel, const char *str,
|
||||||
|
const char *bindch, const char *filech)
|
||||||
{
|
{
|
||||||
char lookups[3], *l;
|
char lookups[3], *l;
|
||||||
const char *p;
|
const char *p;
|
||||||
@ -692,11 +718,13 @@ static int config_lookup(ares_channel channel, const char *str)
|
|||||||
p = str;
|
p = str;
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
if ((*p == 'b' || *p == 'f') && l < lookups + 2)
|
if ((*p == *bindch || *p == *filech) && l < lookups + 2) {
|
||||||
*l++ = *p;
|
if (*p == *bindch) *l++ = 'b';
|
||||||
while (*p && !isspace((unsigned char)*p))
|
else *l++ = 'f';
|
||||||
|
}
|
||||||
|
while (*p && !isspace((unsigned char)*p) && (*p != ','))
|
||||||
p++;
|
p++;
|
||||||
while (isspace((unsigned char)*p))
|
while (*p && (isspace((unsigned char)*p) || (*p == ',')))
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
*l = 0;
|
*l = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user