DNS/DHCP and updating lease file
-
Hello,
I just stumbled about Bug #4931, and am curious whether its solution addresses the whole story.
The bug description states that:
dhcpd changes the dhcpd.leases file as dhcp leases change, but once per hour it rewrites the file from scratch. When it rewrites it, the existing file is first moved out of the way and a new file created.
Usually, doing it this way calls for race conditions. The consumer (dhcpleases) might try to access a partially-filled file (or even a non-existing one!)
Wouldn't a better ordering be:
1. create a new (temporary) file
2. populate the new file with content
3. close the file to ensure all buffers are flushed
4. rename the new file, replacing the original file.This way, the replacement would be atomic. The consumer of the file would never have a chance to consume a partially populated file.