Révision d2628919
Ajouté par Ermal il y a presque 10 ans
pfPorts/dhcpleases/files/dhcpleases.c | ||
---|---|---|
669 | 669 |
if (!foreground) { |
670 | 670 |
/* Initialise kevent structure */ |
671 | 671 |
EV_SET(&chlist, leasefd, EVFILT_VNODE, EV_ADD | EV_CLEAR | EV_ENABLE | EV_ONESHOT, |
672 |
NOTE_WRITE | NOTE_ATTRIB | NOTE_DELETE | NOTE_RENAME, 0, NULL); |
|
672 |
NOTE_WRITE | NOTE_ATTRIB | NOTE_DELETE | NOTE_RENAME | NOTE_LINK, 0, NULL);
|
|
673 | 673 |
/* Loop forever */ |
674 | 674 |
for (;;) { |
675 | 675 |
nev = kevent(kq, &chlist, 1, &evlist, 1, NULL); |
Formats disponibles : Unified diff
Merge manually from https://github.com/packetwerk/pfsense-tools/commit/47c007f4ab532ba3be2a13b88052e19cf5596973
When backuping its dhcpd.leases file, isc-dhcp first create a new file
dhcpd.leases.TIMESTAMP (with new entries), then it link() dhcpd.leases
to dhcpd.leases~, then it rename() the dhcpd.leases.TIMESTAMP to
dhcpd.leases.
In this case, the freshly added entries do not appear in the
/var/etc/hosts file until the next modification of the leases.
Before backup:
[2.1.2-RELEASE][admin@etoile.mobigard.com]/root(21): date ; ls
lai /var/etc/hosts /var/dhcpd/var/db/dhcpd.leases*1 root _dhcp 51652 May 2 17:24 /var/dhcpd/var/db/dhcpd.leasesFri May 2 17:24:41 CEST 2014
2449606 -rw-r--r-
2449575
rw-r--r-1 dhcpd _dhcp 652 Apr 11 02:08 /var/dhcpd/var/db/dhcpd.leases.old2449607
rw-r--r-1 dhcpd _dhcp 101660 May 2 16:46 /var/dhcpd/var/db/dhcpd.leases~2449498
rw-r--r-1 root wheel 6067 May 2 17:24 /var/etc/hostsAfter backup:
[2.1.2-RELEASE][admin@etoile.mobigard.com]/root(22): date ; ls
lai /var/etc/hosts /var/dhcpd/var/db/dhcpd.leases*1 dhcpd _dhcp 50393 May 2 18:29 /var/dhcpd/var/db/dhcpd.leasesFri May 2 18:30:31 CEST 2014
2449608 -rw-r--r-
2449575
rw-r--r-1 dhcpd _dhcp 652 Apr 11 02:08 /var/dhcpd/var/db/dhcpd.leases.old2449606
rw-r--r-1 root _dhcp 59866 May 2 17:50 /var/dhcpd/var/db/dhcpd.leases~2449498
rw-r--r-1 root wheel 6067 May 2 17:50 /var/etc/hosts/var/etc/hosts is not updated even though dhcpd.leases contents
changed, just because dhcpd.leases is a new file, the old is still
here link()ed as dhcpd.leases~, but not rename()d :)
So add NOTE_LINK event to watch the dhcpd.leases changes in this case,
as the NOTE_RENAME is not appropriate here, and NOTE_DELETE neither.
Perhaps a small (empirical) usleep() should be added before reopening?
Just to avoid the race condition of being called between the:
link(dhcpd.leases, dhcpd.leases~)
and the:
rename(dhcpd.leases.TIMESTAMP, dhcpd.leases)
calls of isc-dhcp...