dhcpleases handles duplicate hostnames incorrectly
--- Problem ---
If the 'dhcpd.leases' file parsed by dhcpleases contains an expired lease and non-expired lease for the same hostname, it will not produce any output if the non-expired lease appears in the file before the expired lease.
For example if 'dhcpd.leases' contains:
1) Non-Expired Lease for host1
2) Expired Lease for host1
No output will be produced. However, swapping entries 1) and 2) will result in the correct output.
--- How to Reproduce ---
Using the attached 'dhcpd.leases' file, run:
dhcpleases -f -d home -l dhcpd.leases -u /dev/null -h /dev/null
Notice that it finds both the leases but does not produce an unbound entry.
If you switch the order of the leases in 'dhcp.leases' and re-run, the unbound entry is now produced.
--- Possible cause ---
This appears to be caused by the fact that as dhcpleases populates its list of leases, if another lease (B) with the same hostname as a previous lease (A) is found, instead of having a duplicate entry it will update the expiry date of lease A with the expiry date of lease B (without checking if lease A or B have expired). After populating the list, it then purges all expired leases (thus in this case leaving the list empty). A possible solution is to only add non-expired leases to the list as they are processed and avoid the purge at the end.
--- Workarounds ---
1) Manually purge expired leases in /var/dhcpd/var/db/dhcpd.leases
2) In the web interface: Status -> DHCP Leases -> Click 'Show all Expired Leases' at bottom of page -> manually remove all expired leases