From patchwork Thu Dec 17 09:35:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417562 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=CMcYE+w7; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRlw4qZMz9sW0 for ; Thu, 17 Dec 2020 20:39:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=q+MkRwUfJrdSnckskYUnoKnkU0DOWvLYuvj2X/MjAAY=; b=CMcYE+w7aA00dA+ktM+j/Onhm gDE259xkO3UL5W59qcBKuZixpvRjon84n3Xo7vevOUPXWexgBpG8VkAaUCO85yIPvSnYL5wCnJVkP Xwbl8V06JA3R9oB5d1nWNhyMFcdmRTp8RHC4/3G3kC069GcwPUzqsG1WL+8NP78pONbk7ngzGGCLy dEYQddNiJ4Tj9Q1o0juj3o6sGCxlLtgSQH3XJcm4rLWdL8oDtgoVOCUYSvy/h1R0Ml3bCT0gl3TgF JNLeCiBSLjZ2AT9DQVXDjjUGc4oU2uJk9JZ0cRX20iPKrNvigXUUHM4JFOPPpppRwruE5xE5j3vMz JUcQnuKNg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kppha-0002AG-LJ; Thu, 17 Dec 2020 09:36:02 +0000 Received: from mxout70.expurgate.net ([91.198.224.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphM-00024P-AP for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:49 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1kpphK-000Fly-9V; Thu, 17 Dec 2020 10:35:46 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kpphJ-000Ino-Iw; Thu, 17 Dec 2020 10:35:45 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id B93E8240043; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 5EAF4240040; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 89C6F22906; Thu, 17 Dec 2020 10:35:43 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 1/5] procd: add restart ubus call Date: Thu, 17 Dec 2020 10:35:33 +0100 Message-ID: <20201217093537.22653-2-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201217093537.22653-1-fe@dev.tdt.de> References: <20201217093537.22653-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-ID: 151534::1608197746-000110D7-DF5215A6/0/0 X-purgate-type: clean X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043548_503416_5BB7EFE2 X-CRM114-Status: GOOD ( 14.84 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.198.224.70 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org, Aaron Goodman Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org To allow other services to respsond to a restart event from a procd initialised service, a new ubus method "restart" in the ubus "service" path is needed to trigger a ubus notify and also execute the installed service triggers. Cc: Aaron Goodman Signed-off-by: Florian Eckert The original implementation is by Aaron Goodman. --- .../patches/0010-add-restart-event.patch | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 package/system/procd/patches/0010-add-restart-event.patch diff --git a/package/system/procd/patches/0010-add-restart-event.patch b/package/system/procd/patches/0010-add-restart-event.patch new file mode 100644 index 0000000000..86ec3d38e1 --- /dev/null +++ b/package/system/procd/patches/0010-add-restart-event.patch @@ -0,0 +1,64 @@ +--- a/service/service.c ++++ b/service/service.c +@@ -204,6 +204,17 @@ static const struct blobmsg_policy servi + }; + + enum { ++ SERVICE_RESTART_ATTR_NAME, ++ SERVICE_RESTART_ATTR_INSTANCE, ++ __SERVICE_RESTART_ATTR_MAX, ++}; ++ ++static const struct blobmsg_policy service_restart_attrs[__SERVICE_RESTART_ATTR_MAX] = { ++ [SERVICE_RESTART_ATTR_NAME] = { "name", BLOBMSG_TYPE_STRING }, ++ [SERVICE_RESTART_ATTR_INSTANCE] = { "instance", BLOBMSG_TYPE_STRING }, ++}; ++ ++enum { + SERVICE_DEL_ATTR_NAME, + SERVICE_DEL_ATTR_INSTANCE, + __SERVICE_DEL_ATTR_MAX, +@@ -681,6 +692,35 @@ service_handle_update(struct ubus_contex + return 0; + } + ++static int ++service_handle_restart(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct blob_attr *tb[__SERVICE_RESTART_ATTR_MAX], *cur; ++ struct service *s = NULL; ++ const char *name; ++ ++ blobmsg_parse(service_set_attrs, __SERVICE_RESTART_ATTR_MAX, tb, blobmsg_data(msg), blobmsg_data_len(msg)); ++ cur = tb[SERVICE_RESTART_ATTR_NAME]; ++ if (!cur) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ name = blobmsg_data(cur); ++ ++ s = avl_find_element(&services, name, s, avl); ++ if (!s) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ blob_buf_init(&b, 0); ++ blobmsg_add_string(&b, "service", s->name); ++ trigger_event("service.restart", b.head); ++ ++ service_event("service.restart", s->name, NULL); ++ ++ return UBUS_STATUS_OK; ++} ++ + static void ubus_event_bcast(const char *type, const char *param1, const char *val1, + const char *param2, const char *val2) + { +@@ -951,6 +991,7 @@ static struct ubus_method main_object_me + UBUS_METHOD("add", service_handle_set, service_set_attrs), + UBUS_METHOD("list", service_handle_list, service_list_attrs), + UBUS_METHOD("delete", service_handle_delete, service_del_attrs), ++ UBUS_METHOD("restart", service_handle_restart, service_restart_attrs), + UBUS_METHOD("signal", service_handle_signal, service_signal_attrs), + UBUS_METHOD("update_start", service_handle_update, service_attrs), + UBUS_METHOD("update_complete", service_handle_update, service_attrs), From patchwork Thu Dec 17 09:35:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417558 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=PTVBHzpe; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRkG5qqjz9sW0 for ; Thu, 17 Dec 2020 20:37:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qnGXp4cTboRnl384nyaM5e3/JPYRkUNY/CEw0+y24AA=; b=PTVBHzpeAAOpkRGk2zo1TrWoy QgJf4n3nAIiqlTiBIn4tAL2DhGHAGN3ekYXscYFn9pJFEJcZY9IPBl/xLnoyTGPSfNm6s9+2rKeBZ oPbn0tCGVyinI3yN+rr1dYbbA7AYso7814xtokT3O0MtpIcqdEZbEJPhGcTzUCieTO7etp2uIiklH iA9WUBaA4Ocf1BN3twvVo+nZSwYz51TkmdNNHge0ffGCu28E0fSAg5pcAwteC1kcAcGadWfTXXXxF w2IQXgDfabDJIuH2MALXYXdUQoBLrgFBXwOr8ZLEdyou8/lsPc5jgXuU/hKD6ofjCwZpgwpuwR9eT 8bPCn2IeA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphX-00028g-0u; Thu, 17 Dec 2020 09:35:59 +0000 Received: from mxout70.expurgate.net ([91.198.224.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphM-00024O-7k for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:49 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1kpphK-000Q8m-BR; Thu, 17 Dec 2020 10:35:46 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kpphJ-000GAm-Ns; Thu, 17 Dec 2020 10:35:45 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id DEBD4240045; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 8BB5F240041; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 63366207F4; Thu, 17 Dec 2020 10:35:44 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 2/5] base-files: add restart function wrapper Date: Thu, 17 Dec 2020 10:35:34 +0100 Message-ID: <20201217093537.22653-3-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201217093537.22653-1-fe@dev.tdt.de> References: <20201217093537.22653-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate: clean X-purgate-ID: 151534::1608197746-0001D036-1548DF16/0/0 X-purgate-type: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043548_388206_5B08A708 X-CRM114-Status: GOOD ( 10.75 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.198.224.70 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Thies commit add the new wrapper function to rc.common to execute the new ubus service method "restart" on a service restart. Signed-off-by: Florian Eckert --- package/base-files/files/etc/rc.common | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index f39b69464e..ad5af4b7a1 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -139,6 +139,19 @@ extra_command "enabled" "Check if service is started on boot" fi } + restart() { + if eval "type restart_service" 2>/dev/null >/dev/null; then + restart_service "$@" + else + trap '' TERM + stop "$@" + trap - TERM + start "$@" + fi + procd_open_service "$(basename ${basescript:-$initscript})" "$initscript" + procd_close_service "restart" + } + trace() { TRACE_SYSCALLS=1 start "$@" From patchwork Thu Dec 17 09:35:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417559 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=CiPbSABi; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRlp0yTTz9sW0 for ; Thu, 17 Dec 2020 20:39:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AKYEtyWQwJeA4Ydj/CM5UAUI4c5feQ9tKXjaygCGO/A=; b=CiPbSABincuH0rEl0UqlSQl06 gbKOTmzCUG5bXNdNpeIUaFvutAMzIyV5FV8xx3dghuuUG7NtAuPHJUzuOn2fUC4q8Bf31GK9eDn4N BVlfkq0upY0og960Wzf1DD7vea8m2OdQzF9cT1OnFQudX2Y/9pNlXwVpoc2dv8hz+tcdhrUm71x4n OJSMcxTsbFtj6r8jB6U5IwlpEJZQjxjErAJrDdP4riSSw1lr0k9Lq3aGwkMsaf8rfzyVl+VmNVN75 PGSGWAZMG1hmKfWLiAcZGHXI2At50SS2GESmFYpvXYzfCYvpsBqhNzBFP7g3BFXmtwzH1N3tTRH3v DNIBEUf9A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphO-000262-Tv; Thu, 17 Dec 2020 09:35:51 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphL-00024D-2Y for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:48 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kpphK-0001or-58; Thu, 17 Dec 2020 10:35:46 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90) (envelope-from ) id 1kpphJ-000235-Dd; Thu, 17 Dec 2020 10:35:45 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 1470E240041; Thu, 17 Dec 2020 10:35:45 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id B1B1E240042; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 9018D22906; Thu, 17 Dec 2020 10:35:44 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 3/5] firewall: fix whitespace Date: Thu, 17 Dec 2020 10:35:35 +0100 Message-ID: <20201217093537.22653-4-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201217093537.22653-1-fe@dev.tdt.de> References: <20201217093537.22653-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-type: clean X-purgate: clean X-purgate-ID: 151534::1608197745-00005C17-A3BF0668/0/0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043547_791995_8DCFF9BB X-CRM114-Status: GOOD ( 11.39 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [194.37.255.70 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [194.37.255.70 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Remove trailing whitespace. Signed-off-by: Florian Eckert --- package/network/config/firewall/files/firewall.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/config/firewall/files/firewall.init b/package/network/config/firewall/files/firewall.init index ee3ed1a283..4c2fb7b617 100755 --- a/package/network/config/firewall/files/firewall.init +++ b/package/network/config/firewall/files/firewall.init @@ -29,7 +29,7 @@ validate_firewall_rule() } service_triggers() { - procd_add_reload_trigger firewall + procd_add_reload_trigger firewall procd_open_validate validate_firewall_redirect From patchwork Thu Dec 17 09:35:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417561 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=QmhsGQmq; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRlw0JVkz9sW0 for ; Thu, 17 Dec 2020 20:39:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wrqyOMJEEDIFyscgQoI4DMTHvXOxWiT7PGYCaqyjvnY=; b=QmhsGQmqRL0GaXaCEoSE60icm VXFp0YhInWYRkiLzYKi4QcvhbVlHS6h3BlpP9qakzctrQhGCtSMGZKIVJtpXzM8Y18sTD1iTcM+Ss wy36qu+dXJ7+QnFUacs5cHANdTheM39HI11Zg/7ohv6Jne4PbZesFF1558UFZprlAWFxQU6Sxj1UA tYdkesEf1mZfMcR9TCCxs376Bq//8FZibBsLIRIuOfGxeU63DsokRBpBYQXldO+gOmJzGuBdKq9KB qw4RRAz2SUs+ypjAlwk4Gi/pUXh2soEKgVVLf5wwFUcssKk7GGPtLFdUGiXecRv5ML4HO/9xhxbyn kB+LMBcuQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphU-00027r-8m; Thu, 17 Dec 2020 09:35:56 +0000 Received: from mxout70.expurgate.net ([194.37.255.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphM-00024M-2A for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:49 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kpphK-0004bw-3Q; Thu, 17 Dec 2020 10:35:46 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90) (envelope-from ) id 1kpphJ-0006Pu-Iy; Thu, 17 Dec 2020 10:35:45 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 3726D240042; Thu, 17 Dec 2020 10:35:45 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id D8B4B240040; Thu, 17 Dec 2020 10:35:44 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id B69A6207F4; Thu, 17 Dec 2020 10:35:44 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 4/5] firewall: use new restart_service callback Date: Thu, 17 Dec 2020 10:35:36 +0100 Message-ID: <20201217093537.22653-5-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201217093537.22653-1-fe@dev.tdt.de> References: <20201217093537.22653-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-ID: 151534::1608197746-000028F1-F80819D7/0/0 X-purgate-type: clean X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043548_249529_9076341F X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [194.37.255.70 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [194.37.255.70 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org In order that the prcod restart service can also be triggered during a firewall restart, this call function must be changed. Signed-off-by: Florian Eckert --- package/network/config/firewall/files/firewall.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/config/firewall/files/firewall.init b/package/network/config/firewall/files/firewall.init index 4c2fb7b617..089b02bb4c 100755 --- a/package/network/config/firewall/files/firewall.init +++ b/package/network/config/firewall/files/firewall.init @@ -37,7 +37,7 @@ service_triggers() { procd_close_validate } -restart() { +restart_service() { fw3 restart } From patchwork Thu Dec 17 09:35:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1417560 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=iT15PuXN; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CxRlr0JJpz9sW0 for ; Thu, 17 Dec 2020 20:39:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=efebaM9+Tnoi40zmpaOcF0j0z4+ChRIQfqqjsPnhv2E=; b=iT15PuXNdEwrWcLBqcaF09t/d FuvnW8A7lRtkasGUqpghZxnLmbaXhdmYd3UqkqdWRPi1xqevYO/FPvFN0VExlbmKusmcRVDi4/EOJ VSesiTYEAQZItzu7hs6eP4YZmJuQf/ToODT40NDoJcZ3NoKi8gx4uiU4DnCNBXdSpUX+k6gW03GB/ 5hbfwyC4T56r7lVtEKUz4qlpsy/B7873cX4u6Sld2kMDkJDwTdth2oKVmCIvcAmZv+tqCrsip167f V8wquuESmluxXzHr89210ihHPjKRVgy2zbqKnIR0PhnmNTCQgQvbAHfRWiRrTlHEZnqGZ+Mob7Nm4 3kWInX+tQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphR-00026m-Af; Thu, 17 Dec 2020 09:35:53 +0000 Received: from mxout70.expurgate.net ([91.198.224.70]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpphL-00024J-I5 for openwrt-devel@lists.openwrt.org; Thu, 17 Dec 2020 09:35:48 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1kpphK-000GFX-Mw; Thu, 17 Dec 2020 10:35:46 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kpphK-000Q8Y-6F; Thu, 17 Dec 2020 10:35:46 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 66D63240040; Thu, 17 Dec 2020 10:35:45 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 16D48240046; Thu, 17 Dec 2020 10:35:45 +0100 (CET) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id DD8E722906; Thu, 17 Dec 2020 10:35:44 +0100 (CET) From: Florian Eckert To: daniel@makrotopia.org, john@phrozen.org Subject: [PATCH v2 5/5] procd: add api wrapper Date: Thu, 17 Dec 2020 10:35:37 +0100 Message-ID: <20201217093537.22653-6-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201217093537.22653-1-fe@dev.tdt.de> References: <20201217093537.22653-1-fe@dev.tdt.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate-type: clean X-purgate-ID: 151534::1608197746-000039F9-BB30AEB2/0/0 X-purgate: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_043547_845688_E692D574 X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.198.224.70 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This commit adds the functions `procd_add_service_trigger` and `procd_add_restart_service_trigger`. In order for the service to be triggered by another service during a restart, only the function procd_add_restart_service_trigger is needed. Example: service_trigger() { procd add_restart_service_trigger 'firewall' } If the firewall is restarted, the specified will be executed. Signed-off-by: Florian Eckert --- package/system/procd/files/procd.sh | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index d86b7219da..007c99fca0 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -329,6 +329,37 @@ _procd_add_config_trigger() { json_close_array } +_procd_add_service_trigger() { + json_add_array + _procd_add_array_data "$1" + shift + + json_add_array + _procd_add_array_data "if" + + json_add_array + _procd_add_array_data "eq" "service" "$1" + shift + json_close_array + + json_add_array + _procd_add_array_data "run_script" "$@" + json_close_array + + json_close_array + _procd_add_timeout + json_close_array +} + +_procd_add_restart_service_trigger() { + local service=$1 + shift + + _procd_open_trigger + _procd_add_service_trigger "service.restart" "$service" "$@" + _procd_close_trigger +} + _procd_add_raw_trigger() { json_add_array _procd_add_array_data "$1" @@ -559,6 +590,8 @@ _procd_wrapper \ procd_add_instance \ procd_add_raw_trigger \ procd_add_config_trigger \ + procd_add_service_trigger \ + procd_add_restart_service_trigger \ procd_add_interface_trigger \ procd_add_reload_trigger \ procd_add_reload_interface_trigger \