]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
header.pl: Fix parsing BOOTP leases
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 May 2024 13:20:03 +0000 (13:20 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 19 May 2024 13:11:34 +0000 (15:11 +0200)
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>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
config/cfgroot/header.pl

index 5164e9731b4057bceb30cc8f9ba93409cae33e34..a67ff92ee101e44934023da3f86036459b2065df 100644 (file)
@@ -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/) {