mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Fix deletion of dhcp-options from inotify dynamic files.
These were not deleted except in the case that a dhcp-optsfile option was coincidentally provided.
This commit is contained in:
@@ -46,6 +46,10 @@ version 2.79
|
|||||||
http://cs.northwestern.edu/~ychen/Papers/DNS_ToN15.pdf
|
http://cs.northwestern.edu/~ychen/Papers/DNS_ToN15.pdf
|
||||||
Thanks to Mattias Hellström for the initial patch.
|
Thanks to Mattias Hellström for the initial patch.
|
||||||
|
|
||||||
|
Fix failure to delete dynamically created dhcp options
|
||||||
|
from files in -dhcp-optsdir directories. Thanks to
|
||||||
|
Lindgren Fredrik for the bug report.
|
||||||
|
|
||||||
|
|
||||||
version 2.78
|
version 2.78
|
||||||
Fix logic of appending ".<layer>" to PXE basename. Thanks to Chris
|
Fix logic of appending ".<layer>" to PXE basename. Thanks to Chris
|
||||||
|
|||||||
@@ -1511,9 +1511,6 @@ void clear_cache_and_reload(time_t now)
|
|||||||
if (option_bool(OPT_ETHERS))
|
if (option_bool(OPT_ETHERS))
|
||||||
dhcp_read_ethers();
|
dhcp_read_ethers();
|
||||||
reread_dhcp();
|
reread_dhcp();
|
||||||
#ifdef HAVE_INOTIFY
|
|
||||||
set_dynamic_inotify(AH_DHCP_HST | AH_DHCP_OPT, 0, NULL, 0);
|
|
||||||
#endif
|
|
||||||
dhcp_update_configs(daemon->dhcp_conf);
|
dhcp_update_configs(daemon->dhcp_conf);
|
||||||
lease_update_from_configs();
|
lease_update_from_configs();
|
||||||
lease_update_file(now);
|
lease_update_file(now);
|
||||||
|
|||||||
160
src/option.c
160
src/option.c
@@ -4328,7 +4328,7 @@ static void read_file(char *file, FILE *f, int hard_opt)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
#if defined(HAVE_DHCP) && defined(HAVE_INOTIFY)
|
||||||
int option_read_dynfile(char *file, int flags)
|
int option_read_dynfile(char *file, int flags)
|
||||||
{
|
{
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), file);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), file);
|
||||||
@@ -4529,86 +4529,99 @@ void read_servers_file(void)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
|
static void clear_dynamic_conf(void)
|
||||||
|
{
|
||||||
|
struct dhcp_config *configs, *cp, **up;
|
||||||
|
|
||||||
|
/* remove existing... */
|
||||||
|
for (up = &daemon->dhcp_conf, configs = daemon->dhcp_conf; configs; configs = cp)
|
||||||
|
{
|
||||||
|
cp = configs->next;
|
||||||
|
|
||||||
|
if (configs->flags & CONFIG_BANK)
|
||||||
|
{
|
||||||
|
struct hwaddr_config *mac, *tmp;
|
||||||
|
struct dhcp_netid_list *list, *tmplist;
|
||||||
|
|
||||||
|
for (mac = configs->hwaddr; mac; mac = tmp)
|
||||||
|
{
|
||||||
|
tmp = mac->next;
|
||||||
|
free(mac);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configs->flags & CONFIG_CLID)
|
||||||
|
free(configs->clid);
|
||||||
|
|
||||||
|
for (list = configs->netid; list; list = tmplist)
|
||||||
|
{
|
||||||
|
free(list->list);
|
||||||
|
tmplist = list->next;
|
||||||
|
free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configs->flags & CONFIG_NAME)
|
||||||
|
free(configs->hostname);
|
||||||
|
|
||||||
|
*up = configs->next;
|
||||||
|
free(configs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
up = &configs->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_dynamic_opt(void)
|
||||||
|
{
|
||||||
|
struct dhcp_opt *opts, *cp, **up;
|
||||||
|
struct dhcp_netid *id, *next;
|
||||||
|
|
||||||
|
for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp)
|
||||||
|
{
|
||||||
|
cp = opts->next;
|
||||||
|
|
||||||
|
if (opts->flags & DHOPT_BANK)
|
||||||
|
{
|
||||||
|
if ((opts->flags & DHOPT_VENDOR))
|
||||||
|
free(opts->u.vendor_class);
|
||||||
|
free(opts->val);
|
||||||
|
for (id = opts->netid; id; id = next)
|
||||||
|
{
|
||||||
|
next = id->next;
|
||||||
|
free(id->net);
|
||||||
|
free(id);
|
||||||
|
}
|
||||||
|
*up = opts->next;
|
||||||
|
free(opts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
up = &opts->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reread_dhcp(void)
|
void reread_dhcp(void)
|
||||||
{
|
{
|
||||||
struct hostsfile *hf;
|
struct hostsfile *hf;
|
||||||
|
|
||||||
if (daemon->dhcp_hosts_file)
|
/* Do these even if there is no daemon->dhcp_hosts_file or
|
||||||
|
daemon->dhcp_opts_file since entries may have been created by the
|
||||||
|
inotify dynamic file reading system. */
|
||||||
|
|
||||||
|
clear_dynamic_conf();
|
||||||
|
clear_dynamic_opt();
|
||||||
|
|
||||||
|
if (daemon->dhcp_hosts_file)
|
||||||
{
|
{
|
||||||
struct dhcp_config *configs, *cp, **up;
|
|
||||||
|
|
||||||
/* remove existing... */
|
|
||||||
for (up = &daemon->dhcp_conf, configs = daemon->dhcp_conf; configs; configs = cp)
|
|
||||||
{
|
|
||||||
cp = configs->next;
|
|
||||||
|
|
||||||
if (configs->flags & CONFIG_BANK)
|
|
||||||
{
|
|
||||||
struct hwaddr_config *mac, *tmp;
|
|
||||||
struct dhcp_netid_list *list, *tmplist;
|
|
||||||
|
|
||||||
for (mac = configs->hwaddr; mac; mac = tmp)
|
|
||||||
{
|
|
||||||
tmp = mac->next;
|
|
||||||
free(mac);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configs->flags & CONFIG_CLID)
|
|
||||||
free(configs->clid);
|
|
||||||
|
|
||||||
for (list = configs->netid; list; list = tmplist)
|
|
||||||
{
|
|
||||||
free(list->list);
|
|
||||||
tmplist = list->next;
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configs->flags & CONFIG_NAME)
|
|
||||||
free(configs->hostname);
|
|
||||||
|
|
||||||
*up = configs->next;
|
|
||||||
free(configs);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
up = &configs->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
daemon->dhcp_hosts_file = expand_filelist(daemon->dhcp_hosts_file);
|
daemon->dhcp_hosts_file = expand_filelist(daemon->dhcp_hosts_file);
|
||||||
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next)
|
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next)
|
||||||
if (!(hf->flags & AH_INACTIVE))
|
if (!(hf->flags & AH_INACTIVE))
|
||||||
{
|
{
|
||||||
if (one_file(hf->fname, LOPT_BANK))
|
if (one_file(hf->fname, LOPT_BANK))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daemon->dhcp_opts_file)
|
if (daemon->dhcp_opts_file)
|
||||||
{
|
{
|
||||||
struct dhcp_opt *opts, *cp, **up;
|
|
||||||
struct dhcp_netid *id, *next;
|
|
||||||
|
|
||||||
for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp)
|
|
||||||
{
|
|
||||||
cp = opts->next;
|
|
||||||
|
|
||||||
if (opts->flags & DHOPT_BANK)
|
|
||||||
{
|
|
||||||
if ((opts->flags & DHOPT_VENDOR))
|
|
||||||
free(opts->u.vendor_class);
|
|
||||||
free(opts->val);
|
|
||||||
for (id = opts->netid; id; id = next)
|
|
||||||
{
|
|
||||||
next = id->next;
|
|
||||||
free(id->net);
|
|
||||||
free(id);
|
|
||||||
}
|
|
||||||
*up = opts->next;
|
|
||||||
free(opts);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
up = &opts->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
daemon->dhcp_opts_file = expand_filelist(daemon->dhcp_opts_file);
|
daemon->dhcp_opts_file = expand_filelist(daemon->dhcp_opts_file);
|
||||||
for (hf = daemon->dhcp_opts_file; hf; hf = hf->next)
|
for (hf = daemon->dhcp_opts_file; hf; hf = hf->next)
|
||||||
if (!(hf->flags & AH_INACTIVE))
|
if (!(hf->flags & AH_INACTIVE))
|
||||||
@@ -4617,6 +4630,11 @@ void reread_dhcp(void)
|
|||||||
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef HAVE_INOTIFY
|
||||||
|
/* Setup notify and read pre-existing files. */
|
||||||
|
set_dynamic_inotify(AH_DHCP_HST | AH_DHCP_OPT, 0, NULL, 0);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user