public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH] header.pl: Fix parsing BOOTP leases
Date: Wed, 15 May 2024 13:20:03 +0000	[thread overview]
Message-ID: <20240515132003.1788345-1-michael.tremer@ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

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(a)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/) {
-- 
2.39.2


             reply	other threads:[~2024-05-15 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 13:20 Michael Tremer [this message]
2024-05-20 10:00 ` Bernhard Bitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240515132003.1788345-1-michael.tremer@ipfire.org \
    --to=michael.tremer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox