Message ID | 20230523172314.7826-10-jonatan.schlag@ipfire.org |
---|---|
State | Changes Requested |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QQh4d4jbHz3wls for <patchwork@web04.haj.ipfire.org>; Tue, 23 May 2023 17:24:01 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QQh4c5ZPYz1bD; Tue, 23 May 2023 17:24:00 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QQh4c4nbgz2ypP; Tue, 23 May 2023 17:24:00 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QQh4Y6tkJz2ySG for <development@lists.ipfire.org>; Tue, 23 May 2023 17:23:57 +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 (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QQh4Y5hkvzfB; Tue, 23 May 2023 17:23:57 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1684862637; 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=G0yFDW5kRyy3sg3bwM0t6wCsrMo6eodShJuBigH7wTQ=; b=Dn6OfRMRXNEw8UTTc2DkifcZF7LyQJrCOIsse2BSlwrVMxd3hZDmjgOUZa7jPLfiSuHoBk 1JigpV8i88NhjSDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1684862637; 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=G0yFDW5kRyy3sg3bwM0t6wCsrMo6eodShJuBigH7wTQ=; b=jY1wCoKmlrlxcaUFMs8lq+jdrk/m+Kq0Wk8O+pPAAP79NDs4iEPdptjFj4NBv7PKV2trEe tEzsHUXlhJSFD9Lj2u6JOVedZeBXC7I3AXP7VpfxKH6SDdy157Gar2Ns0L/JNZFTlPLlIp O/voZstv08oKDOE3wAlvBbb+mQs4n8wuA17GwOCE3NR8B2cY+YMr/xFfYjFFYi4T55b/KL 1POxQPlBUKCQZYZ6IgPQYn7n/XoLL6Olpo9uuLdyWhpNpYhYO1I0c4txugC4vp5aXZCUri nJIgCCfzPUV+UWnoI2SBSWXdiJFT1VIvKhChc50miXyEVC58/0r2BaC1Hq34iA== From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: development@lists.ipfire.org Subject: [Patch RFC 09/15] network startup: check for correct action at start Date: Tue, 23 May 2023 19:23:09 +0200 Message-Id: <20230523172314.7826-10-jonatan.schlag@ipfire.org> In-Reply-To: <20230523172314.7826-1-jonatan.schlag@ipfire.org> References: <20230523172314.7826-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <https://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <https://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Series |
[RFC,01/15] Remove ipsec interface creation from network startup
|
|
Commit Message
Jonatan Schlag
May 23, 2023, 5:23 p.m. UTC
If we check this at the end, we already do some calculation in the next
line. For example checking if the devices are correct. This is not
necessary as we can already stop when we get an "stoop" or something
like:
/etc/init.d/network green stop
This currently ends in an infinite loop, which gets fixed by this
change.
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/initscripts/system/network | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Comments
How can calling “exit 1” result in an infinite loop? That rather suggests that we are never getting to that part of the code. Should we not rather fix this? Having a catchall at the end of a script is a standard pattern and keeps the script easier to extend if new options are being added because you cannot forget to add them to the top? -Michael > On 23 May 2023, at 18:23, Jonatan Schlag <jonatan.schlag@ipfire.org> wrote: > > If we check this at the end, we already do some calculation in the next > line. For example checking if the devices are correct. This is not > necessary as we can already stop when we get an "stoop" or something > like: > > /etc/init.d/network green stop > > This currently ends in an infinite loop, which gets fixed by this > change. > > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > src/initscripts/system/network | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/src/initscripts/system/network b/src/initscripts/system/network > index 9694165f2..06240f53c 100644 > --- a/src/initscripts/system/network > +++ b/src/initscripts/system/network > @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) > DO="${1}" > shift > > +if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then > + echo "Usage: ${0} {start|stop|restart} [device(s)]" > + exit 1 > +fi > + > if [ -n "${1}" ]; then > ALL=0 > for i in green red blue orange; do > @@ -100,9 +105,4 @@ case "${DO}" in > sleep 1 > ${0} start ${ARGS} > ;; > - > - *) > - echo "Usage: ${0} {start|stop|restart} [device(s)]" > - exit 1 > - ;; > esac > -- > 2.30.2 >
Hi, yes, we never get to this piece of code: while [ ! $# = 0 ]; do for i in green red blue orange; do if [ "${i}" == "${1}" ]; then eval "${i}=1" shift fi done done This loop never ends, as ["${i}" == "${1}" ]; never evaluates to true for $1="stop". So we would actually want to do check here if $1 is a valid zone. So this has to wait until we have something like "network_zone_exists()". Greetings Jonatan Am Mittwoch, dem 24.05.2023 um 10:00 +0100 schrieb Michael Tremer: > How can calling “exit 1” result in an infinite loop? > > That rather suggests that we are never getting to that part of the > code. Should we not rather fix this? > > Having a catchall at the end of a script is a standard pattern and > keeps the script easier to extend if new options are being added > because you cannot forget to add them to the top? > > -Michael > > > On 23 May 2023, at 18:23, Jonatan Schlag > > <jonatan.schlag@ipfire.org> wrote: > > > > If we check this at the end, we already do some calculation in the > > next > > line. For example checking if the devices are correct. This is not > > necessary as we can already stop when we get an "stoop" or > > something > > like: > > > > /etc/init.d/network green stop > > > > This currently ends in an infinite loop, which gets fixed by this > > change. > > > > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > > --- > > src/initscripts/system/network | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/src/initscripts/system/network > > b/src/initscripts/system/network > > index 9694165f2..06240f53c 100644 > > --- a/src/initscripts/system/network > > +++ b/src/initscripts/system/network > > @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash > > /var/ipfire/ethernet/settings) > > DO="${1}" > > shift > > > > +if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == > > "stop" ]]; then > > + echo "Usage: ${0} {start|stop|restart} [device(s)]" > > + exit 1 > > +fi > > + > > if [ -n "${1}" ]; then > > ALL=0 > > for i in green red blue orange; do > > @@ -100,9 +105,4 @@ case "${DO}" in > > sleep 1 > > ${0} start ${ARGS} > > ;; > > - > > - *) > > - echo "Usage: ${0} {start|stop|restart} [device(s)]" > > - exit 1 > > - ;; > > esac > > -- > > 2.30.2 > > >
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9694165f2..06240f53c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" shift +if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then + echo "Usage: ${0} {start|stop|restart} [device(s)]" + exit 1 +fi + if [ -n "${1}" ]; then ALL=0 for i in green red blue orange; do @@ -100,9 +105,4 @@ case "${DO}" in sleep 1 ${0} start ${ARGS} ;; - - *) - echo "Usage: ${0} {start|stop|restart} [device(s)]" - exit 1 - ;; esac