mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-24 20:55:30 +00:00
Fix dhcp-match-name to match hostname, not complete FQDN.
Also do name matching for DHCPv6.
This commit is contained in:
@@ -496,11 +496,16 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
}
|
||||
else if (state->client_hostname)
|
||||
{
|
||||
struct dhcp_match_name *m;
|
||||
size_t nl;
|
||||
|
||||
state->domain = strip_hostname(state->client_hostname);
|
||||
nl = strlen(state->client_hostname);
|
||||
|
||||
if (strlen(state->client_hostname) != 0)
|
||||
{
|
||||
state->hostname = state->client_hostname;
|
||||
|
||||
if (!config)
|
||||
{
|
||||
/* Search again now we have a hostname.
|
||||
@@ -510,6 +515,30 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
if (new && !have_config(new, CONFIG_CLID) && !new->hwaddr)
|
||||
config = new;
|
||||
}
|
||||
|
||||
for (m = daemon->dhcp_name_match; m; m = m->next)
|
||||
{
|
||||
size_t ml = strlen(m->name);
|
||||
char save = 0;
|
||||
|
||||
if (nl < ml)
|
||||
continue;
|
||||
if (nl > ml)
|
||||
{
|
||||
save = state->client_hostname[ml];
|
||||
state->client_hostname[ml] = 0;
|
||||
}
|
||||
|
||||
if (hostname_isequal(state->client_hostname, m->name) &&
|
||||
(save == 0 || m->wildcard))
|
||||
{
|
||||
m->netid->next = state->tags;
|
||||
state->tags = m->netid;
|
||||
}
|
||||
|
||||
if (save != 0)
|
||||
state->client_hostname[ml] = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user