Commit 4f7bb57e authored by Simon Kelley's avatar Simon Kelley

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.
parent 56f06239
...@@ -46,6 +46,10 @@ version 2.79 ...@@ -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) ...@@ -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);
......
...@@ -4328,7 +4328,7 @@ static void read_file(char *file, FILE *f, int hard_opt) ...@@ -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,12 +4529,8 @@ void read_servers_file(void) ...@@ -4529,12 +4529,8 @@ void read_servers_file(void)
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
void reread_dhcp(void) static void clear_dynamic_conf(void)
{ {
struct hostsfile *hf;
if (daemon->dhcp_hosts_file)
{
struct dhcp_config *configs, *cp, **up; struct dhcp_config *configs, *cp, **up;
/* remove existing... */ /* remove existing... */
...@@ -4572,18 +4568,10 @@ void reread_dhcp(void) ...@@ -4572,18 +4568,10 @@ void reread_dhcp(void)
else else
up = &configs->next; up = &configs->next;
} }
}
daemon->dhcp_hosts_file = expand_filelist(daemon->dhcp_hosts_file); static void clear_dynamic_opt(void)
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next) {
if (!(hf->flags & AH_INACTIVE))
{
if (one_file(hf->fname, LOPT_BANK))
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
}
}
if (daemon->dhcp_opts_file)
{
struct dhcp_opt *opts, *cp, **up; struct dhcp_opt *opts, *cp, **up;
struct dhcp_netid *id, *next; struct dhcp_netid *id, *next;
...@@ -4608,7 +4596,32 @@ void reread_dhcp(void) ...@@ -4608,7 +4596,32 @@ void reread_dhcp(void)
else else
up = &opts->next; up = &opts->next;
} }
}
void reread_dhcp(void)
{
struct hostsfile *hf;
/* 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)
{
daemon->dhcp_hosts_file = expand_filelist(daemon->dhcp_hosts_file);
for (hf = daemon->dhcp_hosts_file; hf; hf = hf->next)
if (!(hf->flags & AH_INACTIVE))
{
if (one_file(hf->fname, LOPT_BANK))
my_syslog(MS_DHCP | LOG_INFO, _("read %s"), hf->fname);
}
}
if (daemon->dhcp_opts_file)
{
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) ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment