From patchwork Mon Jan 29 02:25:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 1637 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 2AAB2601D1 for ; Sun, 28 Jan 2018 16:25:55 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 97782465A; Sun, 28 Jan 2018 16:25:54 +0100 (CET) Received: from localhost.localdomain (unknown [10.172.1.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 74CE445B3; Sun, 28 Jan 2018 16:25:52 +0100 (CET) From: Jonatan Schlag To: network@lists.ipfire.org Subject: [PATCH] Fix parsing of hids and ids Date: Sun, 28 Jan 2018 15:25:48 +0000 Message-Id: <1517153148-6844-1-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 X-BeenThere: network@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List for the network package List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: network-bounces@lists.ipfire.org Sender: "network" If we get an id insted of a hid we failed beacuse we passed the wrong variable. I also added some more comments. Fixes: #11453 Signed-off-by: Jonatan Schlag --- src/functions/functions.zone | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/functions/functions.zone b/src/functions/functions.zone index f724f50..2d3d2c7 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -527,7 +527,8 @@ zone_config() { zone_config_list "${zone}" "$@" ;; *) - # usually ${1} is a valid hid + # usually ${cmd} is valid hid + # We get ${hid} ${cmd} $@ from the cli local hid=${cmd} local cmd=${1} shift 1 @@ -538,11 +539,11 @@ zone_config() { if isset id && [[ ${cmd} == "edit" ]]; then zone_config_edit "${zone}" "${id}" "$@" - # If we didn't get a valid hid we check if we got a valid id + # If we didn't get a valid hid we check if we got a valid id (saved in ${hid}) else - if zone_config_id_is_valid ${zone} ${id} && [[ ${cmd} == "edit" ]]; then + if zone_config_id_is_valid ${zone} ${hid} && [[ ${cmd} == "edit" ]]; then shift 1 - zone_config_edit "${zone}" "${id}" "$@" + zone_config_edit "${zone}" "${hid}" "$@" else # in ${hid} is saved the command after network zone ${zone} config error "Unrecognized argument: ${hid}" @@ -1171,6 +1172,8 @@ zone_config_id_is_valid() { local zone=${1} local id=${2} + log DEBUG "Checking if id: ${id} is valid for zone: ${zone}" + local zone_path="${NETWORK_ZONES_DIR}/${zone}" [ -f ${zone_path}/configs/*.${id} ];