From patchwork Sat Mar 2 11:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7577 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 4Tn2Kp4H28z3wmD for ; Sat, 2 Mar 2024 11:09:50 +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 4Tn2Kh4TzbzyP; Sat, 2 Mar 2024 11:09:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tn2Kh2tcQz32gT; Sat, 2 Mar 2024 11:09:44 +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 4Tn2Kg0h6nz301M for ; Sat, 2 Mar 2024 11:09:43 +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 4Tn2Kd6HPzzq1; Sat, 2 Mar 2024 11:09:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1709377781; 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; bh=36Bt7uLrsDiLeGPThik67R3QMIywi0S3A/AYTvz+lCE=; b=PD2t/ERM0cpG3HmvJIu7coSvEheXVGFJ+uqzI2qfZJxFSxEPeFX7NFFs27HS6Zv8TvzXWC W45dIAUn85sY1IBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1709377781; 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; bh=36Bt7uLrsDiLeGPThik67R3QMIywi0S3A/AYTvz+lCE=; b=cJeU9p37W55d1zpoLZJwP0IhOE3rUxP0Z0xx88E/4iqXFC3Oxj9I7TyH0ZPsSGKX1SwBTq dRpizcM6HGhJxneoYzVvhAdKDEfjcjfxOJerkL1qWmGxbi1XGO7cavcfjLcs8u9N7oMLOT 45vOuXavU+fo/XEZHZwGSosDY01hzJ6ft93Y5KvhpaEj2EvikW1PSKkQoVmdWa5GN2v8D0 g91H3dY+Dtxw9l1GdnRdwHHX9j05IelVGAiGZp0KD8/ONeUiu9pZDchKcuxEMX/Df8uNWt 7XoyNllskMJ9JcKg9tvtXwh16sgqQt6FZ3ybFLby89VieejecVcNTEuAEISzTQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 1/5] functions.network: Add proper Exit Codes Date: Sat, 2 Mar 2024 12:09:24 +0100 Message-Id: <20240302110928.10377-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 4L3UEE3UNE4U5BK6VJMWHAD5BQI5NPHZ X-Message-ID-Hash: 4L3UEE3UNE4U5BK6VJMWHAD5BQI5NPHZ 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: This ist borrowed from here: https://git.ipfire.org/?p=network.git;a=blob_plain;f=src/functions/functions.constants;h=0d6cdd2fba47fa4db933b054496ed95cd3d905f3;hb=HEAD and can be extended later on. Signed-off-by: Jonatan Schlag --- src/initscripts/networking/functions.network | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 4c7ad51d4..dedbb6f7f 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -22,6 +22,10 @@ . /etc/sysconfig/rc . $rc_functions +# Proper error codes +EXIT_TRUE=0 +EXIT_FALSE=1 + eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) eval $(/usr/local/bin/readhash /var/ipfire/dns/settings) From patchwork Sat Mar 2 11:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7578 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 4Tn2Kr0ntZz3wmD for ; Sat, 2 Mar 2024 11:09:52 +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 4Tn2Kp4gWQz1qX; Sat, 2 Mar 2024 11:09:50 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tn2Kp470sz32gy; Sat, 2 Mar 2024 11:09:50 +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 4Tn2Km4ymcz301M for ; Sat, 2 Mar 2024 11:09:48 +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 4Tn2Km1drDz1XD; Sat, 2 Mar 2024 11:09:48 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1709377788; 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=kDaL0blAiVkstDSi+UxYv7DH/AyJRqgDVjVbaniDZeA=; b=0oDYSCHIvhayGJlkpwGYIj+8x/hBPPz0xFpjAKf6hUyLhySURyOK08O0RsGA3WMsjfznIB BXc2GYyiogHt93DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1709377788; 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=kDaL0blAiVkstDSi+UxYv7DH/AyJRqgDVjVbaniDZeA=; b=WLr8oVOlqk9J6LT60xJWGDupkvWxqOsv6+yGpK+3OKwMm2GjBc7KHrmv+PVkTScvkjDD7m A2Ay0iKqV49g0xi9mTw/6tXhzYVVQKYWQIrdvgqMF05F7ldY6C52oi4P7JTU3llVdn0qS0 uuexceJrlDka+i8SYcCMF0xCaBCHLP9hGbCgxFFpkrce33t+iqp3t6IPPXJYSlv7U5zA8h kbc6KGB9zEhyMZjK02wlZPJok9fxQOMmt7RMaTB/srvYP/qPtnJGW8J0+JBSCdHB88/bMT O6hEBIXgEAu+Q5PZNUqLlLe7358pJnFs5kc98reoYq7k7YjKSSkab785MbMYdg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 2/5] functions.network: Add network_zone_exists Date: Sat, 2 Mar 2024 12:09:25 +0100 Message-Id: <20240302110928.10377-2-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: 722BNFYSCGD3SM6QUZZWDXMUFIRYNK6G X-Message-ID-Hash: 722BNFYSCGD3SM6QUZZWDXMUFIRYNK6G 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: As our Network is quite static a case does the trick Signed-off-by: Jonatan Schlag --- src/initscripts/networking/functions.network | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index dedbb6f7f..ad0d3f36a 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -289,3 +289,25 @@ qmi_assign_address() { # Change the MAC address ip link set "${intf}" address "${address}" } + +network_zone_exists(){ + local zone="${1}" + + case "${zone}" in + "blue") + [ "${CONFIG_TYPE}" = "3" ] || [ "${CONFIG_TYPE}" = "4" ] + ;; + "green") + [ -n "${GREEN_DEV}" ] && [ -v "GREEN_DEV" ] + ;; + "orange") + [ "${CONFIG_TYPE}" = "2" ] || [ "${CONFIG_TYPE}" = "4" ] + ;; + "red") + return ${EXIT_TRUE} + ;; + *) + return ${EXIT_FALSE} + ;; + esac +} From patchwork Sat Mar 2 11:09:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7579 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 4Tn2Ks2KBcz3wmD for ; Sat, 2 Mar 2024 11:09:53 +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 4Tn2Kq5vDfz2Jv; Sat, 2 Mar 2024 11:09:51 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tn2Kq5Mxgz32gT; Sat, 2 Mar 2024 11:09:51 +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 4Tn2Kn6097z32Q8 for ; Sat, 2 Mar 2024 11:09:49 +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 4Tn2Kn4x0rz1XD; Sat, 2 Mar 2024 11:09:49 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1709377789; 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=XkvyQLBmEZYz6Q9nNrVpxLPBzqWRnA7pl7HYSTcPH+A=; b=E/6eQlhbxAsTKrfAOghp71CAN2ud44gGsmFEvAni3kq9n9e8oyHEvjT8PFV9fWLW8OLLIu pZdNmCC1YLRpVRAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1709377789; 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=XkvyQLBmEZYz6Q9nNrVpxLPBzqWRnA7pl7HYSTcPH+A=; b=QS/0iogvDk7AI3DNBkrO2hbceHvZrkbPQOCOkY8e1X304thS3xuUowcS0m02hVFRuej7UL I2znAl8trNOv5zQIhnCKT+qlyTnyvBiW7ZCtqbkk+CRKVB46wwN3hfO/pppGXb3CwMIUqx TXgimTdf3fMILNByuZDfs9F5v5pWKTEID4gE/y6pdrGOzcR+k5xtOBdNAnI9FkIMM/RPzr /i3NgezSJqKFn8CwcuKB12pzt8cRsbTx+I0T2MMSHCcZstgzBKPpFKpZYZGoOBybuGYfos aGlFsW3HvP+JulI/QUtVvabJ2//H2CHWOYMBnUhumE0A6kdbpu2k8sVBDfHCFQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 3/5] network initscript: Use network_zone_exists Date: Sat, 2 Mar 2024 12:09:26 +0100 Message-Id: <20240302110928.10377-3-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: O5PJV4WW6SIC36XLT6ECL6G6GWH63DM6 X-Message-ID-Hash: O5PJV4WW6SIC36XLT6ECL6G6GWH63DM6 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: This only a cosmetic change but should making the code easier changeable later on. Signed-off-by: Jonatan Schlag --- src/initscripts/system/network | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0dcce060f..f334561de 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -21,6 +21,8 @@ . /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network + eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" @@ -54,11 +56,11 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start # BLUE - [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ + [ "$blue" == "1" ] && network_zone_exists "blue" && \ /etc/rc.d/init.d/networking/blue start # ORANGE - [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ + [ "$orange" == "1" ] && network_zone_exists "orange" && \ /etc/rc.d/init.d/networking/orange start # RED @@ -84,16 +86,16 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop # BLUE - [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ + [ "$blue" == "1" ] && network_zone_exists "blue" && \ /etc/rc.d/init.d/networking/blue stop # ORANGE - [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ + [ "$orange" == "1" ] && network_zone_exists "orange" && \ /etc/rc.d/init.d/networking/orange stop # RED if [ "$red" == "1" ]; then - if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then + if network_zone_exists "red"; then /etc/rc.d/init.d/networking/red stop fi fi 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 From patchwork Sat Mar 2 11:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7581 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 4Tn2Kx4SCKz3wmD for ; Sat, 2 Mar 2024 11:09:57 +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 4Tn2Kx1TSYz2SS; Sat, 2 Mar 2024 11:09:57 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tn2Kx124jz32Q8; Sat, 2 Mar 2024 11:09:57 +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 4Tn2Kq46LPz32Q8 for ; Sat, 2 Mar 2024 11:09:51 +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 4Tn2Kq0g4Jz2yX; Sat, 2 Mar 2024 11:09:51 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1709377791; 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=+iOdkwFpJM0ZSboZgGTzkRhiC8wkGj8MHFHhp4R+30U=; b=eb7fzEDKN2tmvZsA2M91vTONYb0UIO+z/FpcSyEkFX00/GI5jxJETfui/RgKmXoHa2mXZ1 gvq1ginCzP6La5Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1709377791; 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=+iOdkwFpJM0ZSboZgGTzkRhiC8wkGj8MHFHhp4R+30U=; b=kdCA9FuCTFuQd2Ul3i8CasDOJ2QPeL8btP36rsH1IXcizX+SrWP+9GKo+PB6qX1suN+Pt/ ADL1DnoLW+27VdiqAFL3XfXD6Z3fi431YkBOhYiMZNV+iH9hY8eiDDFIDAssblSPiFoBoA 2ymgI+QbRmiWYA7geyUWApQ7dF4RrQiSrwg1R8JgPQiOskidMRezCrCnXM60q5LaxtqAQ8 EUhWkTtZE0LVa0HIlNyHb9ujnZaWhwZVZxFzOrGyI3ehx8LHECiCdvuqCrR5bXUCgyd1wk uvDCY5Ywb46XnGozSERVOSbDeRM5PInlNlElPsSlrcYBPFiwuOb7jpZVPJbJ6A== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 5/5] network initscript: drop unused variable Date: Sat, 2 Mar 2024 12:09:28 +0100 Message-Id: <20240302110928.10377-5-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: DSI6V2CXJQEJYIJPOVKNDEFYC2MITSC3 X-Message-ID-Hash: DSI6V2CXJQEJYIJPOVKNDEFYC2MITSC3 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: Signed-off-by: Jonatan Schlag --- src/initscripts/system/network | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/initscripts/system/network b/src/initscripts/system/network index a78473110..ce1ddf01f 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -29,12 +29,10 @@ DO="${1}" shift if [ -n "${1}" ]; then - ALL=0 for i in green red blue orange; do eval "${i}=0" done else - ALL=1 for i in green red blue orange; do eval "${i}=1" done