Compare commits

...
2 Commits
3 changed files with 44 additions and 21 deletions

No files matched your search

+7
View File
@@ -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.
+20 -14
View File
@@ -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)
+17 -7
View File
@@ -510,17 +510,27 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
char *pq = daemon->dhcp_buff; char *pq = daemon->dhcp_buff;
unsigned char *pp, *op = option_ptr(opt, 0); unsigned char *pp, *op = option_ptr(opt, 0);
/* Set an MBZ bit to indicate receipt of FQDN option - cleared later */ fqdn_flags = *op;
fqdn_flags = *op | 0x10;
len -= 3; len -= 3;
op += 3; op += 3;
pp = op; pp = op;
/* Always force update, since the client has no way to do it itself. */ /* NB, the following always sets at least one bit */
if (!option_bool(OPT_FQDN_UPDATE) && !(fqdn_flags & 0x01)) if (option_bool(OPT_FQDN_UPDATE))
fqdn_flags |= 0x03; {
if (fqdn_flags & 0x01)
fqdn_flags &= ~0x08; {
fqdn_flags |= 0x02; /* set O */
fqdn_flags &= ~0x01; /* clear S */
}
fqdn_flags |= 0x08; /* set N */
}
else
{
if (!(fqdn_flags & 0x01))
fqdn_flags |= 0x03; /* set S and O */
fqdn_flags &= ~0x08; /* clear N */
}
if (fqdn_flags & 0x04) if (fqdn_flags & 0x04)
while (*op != 0 && ((op + (*op) + 1) - pp) < len) while (*op != 0 && ((op + (*op) + 1) - pp) < len)