mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Finesse the check for /etc/hosts names which conflict with DHCP names.
This commit is contained in:
@@ -3,6 +3,13 @@ version 2.64
|
|||||||
--dhcp-client-update set. Thanks to Bernd Krumbroeck for
|
--dhcp-client-update set. Thanks to Bernd Krumbroeck for
|
||||||
spotting the problem.
|
spotting the problem.
|
||||||
|
|
||||||
|
Finesse the check for /etc/hosts names which conflict with
|
||||||
|
DHCP names. Previously a name/address pair in /etc/hosts
|
||||||
|
which didn't match the name/address of a DHCP lease would
|
||||||
|
generate a warning. Now that only happesn if there is not
|
||||||
|
also a match. This allows multiple addresses for a name in
|
||||||
|
/etc/hosts with one of them assigned via DHCP.
|
||||||
|
|
||||||
|
|
||||||
version 2.63
|
version 2.63
|
||||||
Do duplicate dhcp-host address check in --test mode.
|
Do duplicate dhcp-host address check in --test mode.
|
||||||
|
|||||||
34
src/cache.c
34
src/cache.c
@@ -1042,7 +1042,7 @@ static void add_dhcp_cname(struct crec *target, time_t ttd)
|
|||||||
void cache_add_dhcp_entry(char *host_name, int prot,
|
void cache_add_dhcp_entry(char *host_name, int prot,
|
||||||
struct all_addr *host_address, time_t ttd)
|
struct all_addr *host_address, time_t ttd)
|
||||||
{
|
{
|
||||||
struct crec *crec = NULL;
|
struct crec *crec = NULL, *fail_crec = NULL;
|
||||||
unsigned short flags = F_IPV4;
|
unsigned short flags = F_IPV4;
|
||||||
int in_hosts = 0;
|
int in_hosts = 0;
|
||||||
size_t addrlen = sizeof(struct in_addr);
|
size_t addrlen = sizeof(struct in_addr);
|
||||||
@@ -1055,28 +1055,21 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
|
||||||
while ((crec = cache_find_by_name(crec, host_name, 0, flags | F_CNAME)))
|
while ((crec = cache_find_by_name(crec, host_name, 0, flags | F_CNAME)))
|
||||||
{
|
{
|
||||||
/* check all addresses associated with name */
|
/* check all addresses associated with name */
|
||||||
if (crec->flags & F_HOSTS)
|
if (crec->flags & F_HOSTS)
|
||||||
{
|
{
|
||||||
/* if in hosts, don't need DHCP record */
|
|
||||||
in_hosts = 1;
|
|
||||||
|
|
||||||
inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
|
|
||||||
if (crec->flags & F_CNAME)
|
if (crec->flags & F_CNAME)
|
||||||
my_syslog(MS_DHCP | LOG_WARNING,
|
my_syslog(MS_DHCP | LOG_WARNING,
|
||||||
_("%s is a CNAME, not giving it to the DHCP lease of %s"),
|
_("%s is a CNAME, not giving it to the DHCP lease of %s"),
|
||||||
host_name, daemon->addrbuff);
|
host_name, daemon->addrbuff);
|
||||||
else if (memcmp(&crec->addr.addr, host_address, addrlen) != 0)
|
else if (memcmp(&crec->addr.addr, host_address, addrlen) == 0)
|
||||||
{
|
in_hosts = 1;
|
||||||
inet_ntop(prot, &crec->addr.addr, daemon->namebuff, MAXDNAME);
|
else
|
||||||
my_syslog(MS_DHCP | LOG_WARNING,
|
fail_crec = crec;
|
||||||
_("not giving name %s to the DHCP lease of %s because "
|
|
||||||
"the name exists in %s with address %s"),
|
|
||||||
host_name, daemon->addrbuff,
|
|
||||||
record_source(crec->uid), daemon->namebuff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!(crec->flags & F_DHCP))
|
else if (!(crec->flags & F_DHCP))
|
||||||
{
|
{
|
||||||
@@ -1086,9 +1079,22 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if in hosts, don't need DHCP record */
|
||||||
if (in_hosts)
|
if (in_hosts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Name in hosts, address doesn't match */
|
||||||
|
if (fail_crec)
|
||||||
|
{
|
||||||
|
inet_ntop(prot, &fail_crec->addr.addr, daemon->namebuff, MAXDNAME);
|
||||||
|
my_syslog(MS_DHCP | LOG_WARNING,
|
||||||
|
_("not giving name %s to the DHCP lease of %s because "
|
||||||
|
"the name exists in %s with address %s"),
|
||||||
|
host_name, daemon->addrbuff,
|
||||||
|
record_source(fail_crec->uid), daemon->namebuff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((crec = cache_find_by_addr(NULL, (struct all_addr *)host_address, 0, flags)))
|
if ((crec = cache_find_by_addr(NULL, (struct all_addr *)host_address, 0, flags)))
|
||||||
{
|
{
|
||||||
if (crec->flags & F_NEG)
|
if (crec->flags & F_NEG)
|
||||||
|
|||||||
Reference in New Issue
Block a user