From patchwork Wed Jul 11 04:04:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 1864 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.i.ipfire.org (Postfix) with ESMTP id 217D96071F for ; Tue, 10 Jul 2018 20:04:57 +0200 (CEST) Received: from mail01.i.ipfire.org (localhost [127.0.0.1]) by mail01.ipfire.org (Postfix) with ESMTP id CA63410AC47D; Tue, 10 Jul 2018 19:04:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1531245896; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:list-id: list-unsubscribe:list-subscribe:list-post; bh=GNgVyi4G0e+kAN6X6JhCy3Oo0WHAtNcBFScBZwTqo10=; b=patYqKy20KciimY/hKXKg0si240Fzo/d7ZRZVtDs4k28xRlGHYFjt6dEQQKa/PbeY8gheI WctBqpgk4VuORWapwkiF58YOC92y55AkixR3u63Eg9myz/tPo198vDTkKaPOMjC6lwbVn7 hOctFK5gC7KegwLD3W69W2ssXIyF5mMhlMj+ItyahQwx4e3wiAM48Q+iR7a+mznZQojIu9 wdmzjQdNNSBlbjE6dFPOG6MgL03ALYe8GYjDubtYsv7Rn+HBYdOCd7gNZDz80HR5NdvLQU vmZTV1C5FGLPP7+EyQm5wqOv83NhfhI9lt9XMTGjv7TXVkZtZxhyzWoBi44ZtQ== Received: from tuxedo.stevee (213162073120.public.t-mobile.at [213.162.73.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 74E39108B88F; Tue, 10 Jul 2018 19:04:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1531245895; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=GNgVyi4G0e+kAN6X6JhCy3Oo0WHAtNcBFScBZwTqo10=; b=d/BcQMJ3RgQ7UD+28vEeUY+x3Oq4VK5izwiFdTze8gvwcRpo3+G3Ygp3xGl8W2ojtvo+Xv TizbZtbHE4hLJB4xKOJAqiCBxFsmYUJ5Dv9EWsivWDRH9qWv8jAxXkejO1u6f0dkElVIcV NnsHeB84wNH5sqC5Y7jJbfUdssVzaKlqKmeIX+7wH21pyx8TqZgxeJ5kKqAmOcY36PQ/sC iCRXuVT+NQmBecisGNdcCicq+pitk0nMzoDCD2PR7TlWn+jiyTuFRK7fp+867oamWomfK/ N1th3HMPe6YZlzEzBDKtIQE6b4QK+Ho8/u9weEr51Ki59zbg2xMgywROOuQ8+g== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] Fix hook for static address configuration. Date: Tue, 10 Jul 2018 20:04:51 +0200 Message-Id: <20180710180451.4001-1-stefan.schantl@ipfire.org> X-Mailer: git-send-email 2.17.1 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-Spamd-Result: default: False [-2.10 / 11.00]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MID_CONTAINS_FROM(1.00)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; ASN(0.00)[asn:8412, ipnet:213.162.64.0/19, country:AT]; DKIM_SIGNED(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3] X-Spam-Status: No, score=-2.10 X-Rspamd-Server: mail01.i.ipfire.org Cc: network@lists.ipfire.org X-BeenThere: network@lists.ipfire.org X-Mailman-Version: 2.1.15 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" Add the required hook_new function and "id" information which have been introduced in earlier commits to make this hook work again. Signed-off-by: Stefan Schantl --- src/hooks/configs/static | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/hooks/configs/static b/src/hooks/configs/static index 91bba8a..37f3d32 100644 --- a/src/hooks/configs/static +++ b/src/hooks/configs/static @@ -52,6 +52,8 @@ hook_check_config_settings() { hook_parse_cmdline() { local protocol + local id="${1}" + shift while [ $# -gt 0 ]; do case "${1}" in @@ -153,12 +155,34 @@ hook_parse_cmdline() { fi # Check any conflicts - if zone_config_check_same_setting "${zone}" "static" "ADDRESS" "${ADDRESS}"; then + if zone_config_check_same_setting "${zone}" "static" "${id}" "ADDRESS" "${ADDRESS}"; then error "A static configuration with the same address is already configured" return ${EXIT_CONF_ERROR} fi } +hook_new() { + local zone="${1}" + shift + + if zone_config_hook_is_configured ${zone} "static"; then + log ERROR "You can configure the static hook only once for a zone" + return ${EXIT_ERROR} + fi + + local id=$(zone_config_get_new_id ${zone}) + log DEBUG "ID for the config is: ${id}" + + if ! hook_parse_cmdline "${id}" "$@"; then + # Return an error if the parsing of the cmd line fails + return ${EXIT_ERROR} + fi + + zone_config_settings_write "${zone}" "${HOOK}" "${id}" + + exit ${EXIT_OK} +} + hook_up() { local zone="${1}" local config="${2}"