header.pl: Fix parsing BOOTP leases
Commit Message
If the lease has been handed out over BOOTP, it will never expire.
However, the parser did not account for this case at all which is fixed
in this patch.
Fixes: #13689 - BOOTP breaks the list of DHCP leases due to erroneous parsing
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
config/cfgroot/header.pl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Am 15.05.2024 um 15:20 schrieb Michael Tremer:
> If the lease has been handed out over BOOTP, it will never expire.
> However, the parser did not account for this case at all which is fixed
> in this patch.
>
> Fixes: #13689 - BOOTP breaks the list of DHCP leases due to erroneous parsing
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
> config/cfgroot/header.pl | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl
> index 5164e9731..a67ff92ee 100644
> --- a/config/cfgroot/header.pl
> +++ b/config/cfgroot/header.pl
> @@ -454,12 +454,16 @@ END
> $hostname = "";
> }
>
> - if ($line =~ /^\s*ends/) {
> - $line =~ /(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/;
> + if ($line =~ /^\s*ends \d (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/) {
> $endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900);
> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime($endtime);
> $endtime_print = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
> $expired = $endtime < time();
> +
> + } elsif ($line =~ /^\s*ends never/) {
> + $endtime = 0;
> + $endtime_print = $Lang::tr{'never'};
> + $expired = 0;
> }
>
> if ($line =~ /^\s*hardware ethernet/) {
@@ -454,12 +454,16 @@ END
$hostname = "";
}
- if ($line =~ /^\s*ends/) {
- $line =~ /(\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/;
+ if ($line =~ /^\s*ends \d (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)/) {
$endtime = timegm($6, $5, $4, $3, $2 - 1, $1 - 1900);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst) = localtime($endtime);
$endtime_print = sprintf ("%02d/%02d/%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
$expired = $endtime < time();
+
+ } elsif ($line =~ /^\s*ends never/) {
+ $endtime = 0;
+ $endtime_print = $Lang::tr{'never'};
+ $expired = 0;
}
if ($line =~ /^\s*hardware ethernet/) {