From patchwork Sun Aug 12 05:21:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 1881 Return-Path: Received: from mail01.ipfire.org (mail01.ipfire.org [IPv6:2001:470:7183:25::1]) by web02.i.ipfire.org (Postfix) with ESMTP id ACF7F61847 for ; Sat, 11 Aug 2018 21:21:35 +0200 (CEST) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 7966E10A5565; Sat, 11 Aug 2018 20:21:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1534015295; 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:in-reply-to: references:references:list-id:list-unsubscribe:list-subscribe:list-post; bh=yUW9rD8Lyoxnm33Cv1wNXFHmATcLkQaaRw9fQ15NI/Y=; b=ww7YtI2ImX9CbfKRXjqzRl48CpNh2xu4/auQcpzg2UsXA8LInklEOsFJGMCAMCX0EcKxYV Cof9ppUPJq9kY0+WTygYZCbqm8vl01sZBMZbOi86zv3O9kBbDIoroShwvUVcc9T2iJRJZe kooaM+He+/OvjQ+Ch2uZVKwyxdbLz02bE1jmCZk6mi+ynftGxib+D4UeeK4JsQXhIz34ee xvnHlPj2BfFgg0e9LAwy4D+Q8axXnrE7QqoNZOz8CweuPnQAoYDssJSDWo3OvkC4ImJH7S exPKTtesiRb2CH7OP9Q+h5PaWaJ+qf398tZGXjLHm/eVbxzYDh49AX1xQWNmXg== Received: from tuxedo.stevee (078132092241.public.t-mobile.at [78.132.92.241]) (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 19051109370A; Sat, 11 Aug 2018 20:21:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1534015291; 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:in-reply-to: references:references; bh=yUW9rD8Lyoxnm33Cv1wNXFHmATcLkQaaRw9fQ15NI/Y=; b=tS4mBnMdSzQRH1dLK0XX/UqAUyq8zyofWYCJLxzuZ0lwlQk89KJmzUUeMcBOkZvxSY49h2 YyokNgvXahi25N4hhWIrA34jU9eFHZUFQYzaiqIc27d1Vr2Liwi+EV+8GCGOr5OLZeXccq Yeh31+s7ZaZBF57cMKUMCkHzUxD/RsAHkQ+Qb85J3BAnRrZAiB78c5x6+DnOqniyNNAvhe mu0RlLRwA6ZTWDRCzo3wrrdr5S7L8NrDv01S5xiN+NddgSAsTJqrxbCuZM6COojajGmYO0 D5bERiEZxWXhmNquGZyzHmzTahduzIj5XkiSJOttmvVzFvTQcwSMsz7rYYWePw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCHv2] Fix hook for static address configuration. Date: Sat, 11 Aug 2018 21:21:27 +0200 Message-Id: <20180811192127.14322-1-stefan.schantl@ipfire.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[]; MID_CONTAINS_FROM(1.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:8412, ipnet:78.132.0.0/17, country:AT]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] 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 Tested-by: Jonatan Schlag --- src/hooks/configs/static | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/hooks/configs/static b/src/hooks/configs/static index 91bba8a..23ae2d8 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,29 @@ 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 + + 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}"