dhcp-lease-list fails to parse /var/lib/dhcpd.leases when db-time-format is set to locale
name: Bug Report
about: dhcp-lease-list script fails to parse leases file if db-time-format is set to locale
Describe the bug
dhcp-lease-list
script fails to parse /var/lib/dhcpd.leases
file if db-time-format
is set to locale
To Reproduce
- In
dhcpd.conf
, setdb-time-format locale
- Restart dhcp service
- On a dhcp client, run
dhclient -r
- On the server, run
dhcp-lease-list
: the lease does not appear
Expected behavior
Leases should appear in dhcp-lease-list
command's output, even if db-time-format
is set to locale
Environment
- ISC DHCP version: 4.4.1
- OS: Ubuntu Server 20.04 x64
Additional Information
After investigation, the problem occurs because of the following part in dhcp-lease-list
Perl script:
# skip invalid lines
next if not ($lease =~ /^\s+([\.\d]+)\s+{.*starts \d+ ([\/\d\ \:]+);.*ends \d+ ([\/\d\ \:]+);.*ethernet ([a-f0-9:]+);(.*client-hostname \"(\S+)\";)*/s);
Indeed, this regex does not match leases written with date format that respect the db-time-format locale
flag, that is (according to man dhcpd.leases
):
If the db-time-format was configured to local, then the date fields appear as follows:
epoch <seconds-since-epoch>; # <day-name> <month-name> <day-number> <hours>:<minutes>:<seconds> <year>