mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Fix dhcp-name-match to function when name supplied in --dhcp-host.
This commit is contained in:
@@ -54,6 +54,10 @@ version 2.81
|
|||||||
identifier option (option 61), so clients are only identified by
|
identifier option (option 61), so clients are only identified by
|
||||||
MAC addresses.
|
MAC addresses.
|
||||||
|
|
||||||
|
Fix a bug which stopped --dhcp-name-match from working when a hostname
|
||||||
|
is supplied in --dhcp-host. Thanks to James Feeney for spotting this.
|
||||||
|
|
||||||
|
|
||||||
version 2.80
|
version 2.80
|
||||||
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
||||||
for the initial patch and motivation.
|
for the initial patch and motivation.
|
||||||
|
|||||||
@@ -740,12 +740,9 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
}
|
}
|
||||||
else if (client_hostname)
|
else if (client_hostname)
|
||||||
{
|
{
|
||||||
struct dhcp_match_name *m;
|
|
||||||
size_t nl;
|
|
||||||
|
|
||||||
domain = strip_hostname(client_hostname);
|
domain = strip_hostname(client_hostname);
|
||||||
|
|
||||||
if ((nl = strlen(client_hostname)) != 0)
|
if (strlen(client_hostname) != 0)
|
||||||
{
|
{
|
||||||
hostname = client_hostname;
|
hostname = client_hostname;
|
||||||
|
|
||||||
@@ -766,30 +763,36 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
netid = &known_id;
|
netid = &known_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (m = daemon->dhcp_name_match; m; m = m->next)
|
if (hostname)
|
||||||
|
{
|
||||||
|
struct dhcp_match_name *m;
|
||||||
|
size_t nl = strlen(hostname);
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
size_t ml = strlen(m->name);
|
save = hostname[ml];
|
||||||
char save = 0;
|
hostname[ml] = 0;
|
||||||
|
|
||||||
if (nl < ml)
|
|
||||||
continue;
|
|
||||||
if (nl > ml)
|
|
||||||
{
|
|
||||||
save = client_hostname[ml];
|
|
||||||
client_hostname[ml] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostname_isequal(client_hostname, m->name) &&
|
|
||||||
(save == 0 || m->wildcard))
|
|
||||||
{
|
|
||||||
m->netid->next = netid;
|
|
||||||
netid = m->netid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save != 0)
|
if (hostname_isequal(hostname, m->name) &&
|
||||||
client_hostname[ml] = save;
|
(save == 0 || m->wildcard))
|
||||||
|
{
|
||||||
|
m->netid->next = netid;
|
||||||
|
netid = m->netid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (save != 0)
|
||||||
|
hostname[ml] = save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,65 +508,64 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->clid)
|
if (state->clid &&
|
||||||
|
(config = find_config(daemon->dhcp_conf, state->context, state->clid, state->clid_len, state->mac, state->mac_len, state->mac_type, NULL)) &&
|
||||||
|
have_config(config, CONFIG_NAME))
|
||||||
{
|
{
|
||||||
config = find_config(daemon->dhcp_conf, state->context, state->clid, state->clid_len, state->mac, state->mac_len, state->mac_type, NULL);
|
state->hostname = config->hostname;
|
||||||
|
state->domain = config->domain;
|
||||||
|
state->hostname_auth = 1;
|
||||||
|
}
|
||||||
|
else if (state->client_hostname)
|
||||||
|
{
|
||||||
|
state->domain = strip_hostname(state->client_hostname);
|
||||||
|
|
||||||
if (have_config(config, CONFIG_NAME))
|
if (strlen(state->client_hostname) != 0)
|
||||||
{
|
{
|
||||||
state->hostname = config->hostname;
|
state->hostname = state->client_hostname;
|
||||||
state->domain = config->domain;
|
|
||||||
state->hostname_auth = 1;
|
|
||||||
}
|
|
||||||
else if (state->client_hostname)
|
|
||||||
{
|
|
||||||
struct dhcp_match_name *m;
|
|
||||||
size_t nl;
|
|
||||||
|
|
||||||
state->domain = strip_hostname(state->client_hostname);
|
if (!config)
|
||||||
nl = strlen(state->client_hostname);
|
|
||||||
|
|
||||||
if (strlen(state->client_hostname) != 0)
|
|
||||||
{
|
{
|
||||||
state->hostname = state->client_hostname;
|
/* Search again now we have a hostname.
|
||||||
|
Only accept configs without CLID here, (it won't match)
|
||||||
if (!config)
|
to avoid impersonation by name. */
|
||||||
{
|
struct dhcp_config *new = find_config(daemon->dhcp_conf, state->context, NULL, 0, NULL, 0, 0, state->hostname);
|
||||||
/* Search again now we have a hostname.
|
if (new && !have_config(new, CONFIG_CLID) && !new->hwaddr)
|
||||||
Only accept configs without CLID here, (it won't match)
|
config = new;
|
||||||
to avoid impersonation by name. */
|
|
||||||
struct dhcp_config *new = find_config(daemon->dhcp_conf, state->context, NULL, 0, NULL, 0, 0, state->hostname);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state->hostname)
|
||||||
|
{
|
||||||
|
struct dhcp_match_name *m;
|
||||||
|
size_t nl = strlen(state->hostname);
|
||||||
|
|
||||||
|
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->hostname[ml];
|
||||||
|
state->hostname[ml] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostname_isequal(state->hostname, m->name) &&
|
||||||
|
(save == 0 || m->wildcard))
|
||||||
|
{
|
||||||
|
m->netid->next = state->tags;
|
||||||
|
state->tags = m->netid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (save != 0)
|
||||||
|
state->hostname[ml] = save;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config)
|
if (config)
|
||||||
{
|
{
|
||||||
struct dhcp_netid_list *list;
|
struct dhcp_netid_list *list;
|
||||||
|
|||||||
Reference in New Issue
Block a user