From patchwork Sat Mar 2 11:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7580 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 4Tn2Kt1HnPz3wv4 for ; Sat, 2 Mar 2024 11:09:54 +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 4Tn2Ks0Msvz29w; Sat, 2 Mar 2024 11:09:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tn2Kr6wsyz32Sw; Sat, 2 Mar 2024 11:09:52 +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 4Tn2Kp4jQkz32gT for ; Sat, 2 Mar 2024 11:09:50 +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 4Tn2Kp3jgGz1XD; Sat, 2 Mar 2024 11:09:50 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1709377790; 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=oOT8ipUViee2cC8sjdgXokcZMp9t2dDIp0LKm3/gqD8=; b=pTBbf64c/Lywp/iITvsYB/8fgMb/YPlR/XjezOaAA8Q25YK9fG8+bxgJxhqFct1wRDkaUE wr9CX9zPTIx0d3AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1709377790; 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=oOT8ipUViee2cC8sjdgXokcZMp9t2dDIp0LKm3/gqD8=; b=EwqhSW4KL/GcA3m18u07ultWnas4xkmLzwP0sgK/I+xzG+uuJ4o/GLSKw8jlpWaSl6Y/bu GBV1zYHIMR/h0mw5qkRnOQclVY4Cp2PYhWwMqOeVdb7yBoX9l84RmBIUt7SNsQkadIYmTR K4juXVM/9NMyZu+Zx8AW2YpXptuccTb2Sx84brM3mnqeKWruqyYLyuSA3e02ktME6xQHB5 0QtH5w/I4kJAVX0w7ltQs81y9V266YhmqpdDrGpUIKEzRUSsaqMowpreEGvIcGToxyWvHY SEsVu45MvUOSLPKXCrwnWPSXGqFwoGRDbk1kScDBTPedxBeWcwiyq7EEMO0sFQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 4/5] network initscript: Avoid an infinite loop Date: Sat, 2 Mar 2024 12:09:27 +0100 Message-Id: <20240302110928.10377-4-jonatan.schlag@ipfire.org> In-Reply-To: <20240302110928.10377-1-jonatan.schlag@ipfire.org> References: <20240302110928.10377-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: IJ6F2R63EGDTDIN7BSJDM4SSSETUN4F4 X-Message-ID-Hash: IJ6F2R63EGDTDIN7BSJDM4SSSETUN4F4 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: If we only shift if $1 is red, green, blue or orange, $# never gets zero when the input is: /etc/init.d/network green stop When we get an invalid zone we stop the script, as this happening should not be masked. Signed-off-by: Jonatan Schlag --- src/initscripts/system/network | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/initscripts/system/network b/src/initscripts/system/network index f334561de..a78473110 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -41,12 +41,15 @@ else fi while [ ! $# = 0 ]; do - for i in green red blue orange; do - if [ "${i}" == "${1}" ]; then - eval "${i}=1" - shift - fi - done + if network_zone_exists "${1}"; then + printf -v "${1}" '%s' '1' + else + boot_mesg "'${1}' is not a valid zone" ${FAILURE} + echo_failure + # Set ${DO} to something silly that we get an usage message + DO="error" + fi + shift done case "${DO}" in