From patchwork Wed May 15 13:20:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 7783 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VfYk272Wlz3wtx for ; Wed, 15 May 2024 13:20:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VfYk02kWJzc0; Wed, 15 May 2024 13:20:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VfYk011t3z335Q; Wed, 15 May 2024 13:20:08 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VfYjx5GXsz2xkw for ; Wed, 15 May 2024 13:20:05 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "michael.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VfYjw6LLYzXY; Wed, 15 May 2024 13:20:04 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4VfYjw57BqzThtn; Wed, 15 May 2024 13:20:04 +0000 (UTC) From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] header.pl: Fix parsing BOOTP leases Date: Wed, 15 May 2024 13:20:03 +0000 Message-Id: <20240515132003.1788345-1-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Message-ID-Hash: CIGLY6F5AHL2HQFGXVCLUDI7VAFVDZPG X-Message-ID-Hash: CIGLY6F5AHL2HQFGXVCLUDI7VAFVDZPG X-MailFrom: root@michael.haj.ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Michael Tremer X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Reviewed-by: Bernhard Bitsch --- 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/) {