--- embedaddon/dnsmasq/src/inotify.c 2016/11/02 09:57:01 1.1.1.1 +++ embedaddon/dnsmasq/src/inotify.c 2021/03/17 00:56:46 1.1.1.2 @@ -1,4 +1,4 @@ -/* 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 it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include #include /* 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 or moved into the directory. @@ -104,7 +104,7 @@ void inotify_dnsmasq_init() 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))) { if (links-- == 0) @@ -227,19 +227,21 @@ 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) { + size_t namelen; + 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 */ - if (in->len == 0 || - in->name[in->len - 1] == '~' || - (in->name[0] == '#' && in->name[in->len - 1] == '#') || + if (in->len == 0 || (namelen = strlen(in->name)) == 0 || + in->name[namelen - 1] == '~' || + (in->name[0] == '#' && in->name[namelen - 1] == '#') || in->name[0] == '.') 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) if (ah->wd == in->wd) { @@ -260,7 +262,7 @@ int inotify_check(time_t now) #ifdef HAVE_DHCP 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); lease_update_from_configs(); lease_update_file(now); @@ -273,7 +275,7 @@ int inotify_check(time_t now) { 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); lease_update_from_configs(); lease_update_file(now);