version 1.1.1.1, 2016/11/02 09:57:01
|
version 1.1.1.2, 2021/03/17 00:56:46
|
Line 1
|
Line 1
|
/* dnsmasq is Copyright (c) 2000-2016 Simon Kelley | /* dnsmasq is Copyright (c) 2000-2021 Simon Kelley |
|
|
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
Line 20
|
Line 20
|
#include <sys/inotify.h> |
#include <sys/inotify.h> |
#include <sys/param.h> /* For MAXSYMLINKS */ |
#include <sys/param.h> /* For MAXSYMLINKS */ |
|
|
/* the strategy is to set a inotify on the directories containing | /* the strategy is to set an inotify on the directories containing |
resolv files, for any files in the directory which are close-write |
resolv files, for any files in the directory which are close-write |
or moved into the directory. |
or moved into the directory. |
|
|
Line 104 void inotify_dnsmasq_init()
|
Line 104 void inotify_dnsmasq_init()
|
|
|
strcpy(path, res->name); |
strcpy(path, res->name); |
|
|
/* Follow symlinks until we reach a non-symlink, or a non-existant file. */ | /* Follow symlinks until we reach a non-symlink, or a non-existent file. */ |
while ((new_path = my_readlink(path))) |
while ((new_path = my_readlink(path))) |
{ |
{ |
if (links-- == 0) |
if (links-- == 0) |
Line 227 int inotify_check(time_t now)
|
Line 227 int inotify_check(time_t now)
|
|
|
for (p = inotify_buffer; rc - (p - inotify_buffer) >= (int)sizeof(struct inotify_event); p += sizeof(struct inotify_event) + in->len) |
for (p = inotify_buffer; rc - (p - inotify_buffer) >= (int)sizeof(struct inotify_event); p += sizeof(struct inotify_event) + in->len) |
{ |
{ |
|
size_t namelen; |
|
|
in = (struct inotify_event*)p; |
in = (struct inotify_event*)p; |
|
|
for (res = daemon->resolv_files; res; res = res->next) |
|
if (res->wd == in->wd && in->len != 0 && strcmp(res->file, in->name) == 0) |
|
hit = 1; |
|
|
|
/* ignore emacs backups and dotfiles */ |
/* ignore emacs backups and dotfiles */ |
if (in->len == 0 || | if (in->len == 0 || (namelen = strlen(in->name)) == 0 || |
in->name[in->len - 1] == '~' || | in->name[namelen - 1] == '~' || |
(in->name[0] == '#' && in->name[in->len - 1] == '#') || | (in->name[0] == '#' && in->name[namelen - 1] == '#') || |
in->name[0] == '.') |
in->name[0] == '.') |
continue; |
continue; |
| |
| for (res = daemon->resolv_files; res; res = res->next) |
| if (res->wd == in->wd && strcmp(res->file, in->name) == 0) |
| hit = 1; |
| |
for (ah = daemon->dynamic_dirs; ah; ah = ah->next) |
for (ah = daemon->dynamic_dirs; ah; ah = ah->next) |
if (ah->wd == in->wd) |
if (ah->wd == in->wd) |
{ |
{ |
Line 260 int inotify_check(time_t now)
|
Line 262 int inotify_check(time_t now)
|
#ifdef HAVE_DHCP |
#ifdef HAVE_DHCP |
if (daemon->dhcp || daemon->doing_dhcp6) |
if (daemon->dhcp || daemon->doing_dhcp6) |
{ |
{ |
/* Propogate the consequences of loading a new dhcp-host */ | /* Propagate the consequences of loading a new dhcp-host */ |
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); |
Line 273 int inotify_check(time_t now)
|
Line 275 int inotify_check(time_t now)
|
{ |
{ |
if (option_read_dynfile(path, AH_DHCP_HST)) |
if (option_read_dynfile(path, AH_DHCP_HST)) |
{ |
{ |
/* Propogate the consequences of loading a new dhcp-host */ | /* Propagate the consequences of loading a new dhcp-host */ |
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); |