From patchwork Sun Jun 16 16:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7878 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) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4W2Hqq5mrPz3wy2 for ; Sun, 16 Jun 2024 16:03:35 +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) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4W2Hqq17wlz5p0; Sun, 16 Jun 2024 16:03:35 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4W2Hqq0d7Bz33Fy; Sun, 16 Jun 2024 16:03:35 +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) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4W2Hqh6z0Zz33Ft for ; Sun, 16 Jun 2024 16:03:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4W2Hqh5rkTz2V5; Sun, 16 Jun 2024 16:03:28 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1718553808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+XlJYYECdVNEFAqhLHxfOldgj31stWgR4QRpImuc4Uk=; b=BHL9YSU8eOTgeI5c5wwJOqkTmha5bsugfRHdhDMFM+vdMA5PZ9Iu09qqmGiMKlubu77pdQ XiTpN68LnzQb/tCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1718553808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+XlJYYECdVNEFAqhLHxfOldgj31stWgR4QRpImuc4Uk=; b=lu3mtSPHBqE+cZAjnTlg2TTnhf8vb8zv2bAlvdjzle4jQlfZ+mt7ebFSNpKpuy3prux46h tFpgtTHz6E2tw0AFbkZlCordarukxk3TVDnz1x9FuII0refNE5uFE6mnMET/d3kiVhEIdJ +QGRIoMcmwTVzCLaq6LzbBSLOGrziAF/oVIGzfgOgOZRzXR+vJn2xkWNK1f33aMvf4ajZ9 L62PHwo9NazAr880KBuY/5ViVMKCJOzQTfB7pSTpoBmeVeEtpFQ+frkkvCT0eBFc4OHmht 81p2RtPhpWH/sKWXbHSYxEOqgGlIDUXUxNtyUDw/JgZoM9M3OBZMa3tVIVaCVg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH v2 16/18] initscripts fkt: keep readhash compatible with older implementation Date: Sun, 16 Jun 2024 18:02:43 +0200 Message-Id: <20240616160245.18865-17-jonatan.schlag@ipfire.org> In-Reply-To: <20240616160245.18865-1-jonatan.schlag@ipfire.org> References: <20240616160245.18865-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VJBMV5ULC72UAK5RH3YYF2JIVUE436BJ X-Message-ID-Hash: VJBMV5ULC72UAK5RH3YYF2JIVUE436BJ X-MailFrom: jonatan.schlag@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 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: With the use of eval BLUE_DEV='blue0 net0' stored "blue0 net0" in the variable BLUE_DEV not "'blue0 net0'" Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 4 ++++ tests/src/initscripts/system/functions/test.sh | 1 + 2 files changed, 5 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index c9c4c0675..6d72e4119 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -932,6 +932,10 @@ readhash() { continue fi + # strip leading and trailing single quotes + val="${val#\'}" + val="${val%\'}" + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index a2d6535a5..e7f695f55 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -14,6 +14,7 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" # test if we read the correct data test_value_in_array "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_value_in_array "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" +test_value_in_array "CONFIG" "BLUE_DEV" "blue0 net0" # Test that comments are skipped # apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either