From patchwork Sat Mar 20 12:32:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1456099 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=desiato.20200630 header.b=TLII5l54; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=hauke-m.de header.i=@hauke-m.de header.a=rsa-sha256 header.s=MBO0001 header.b=EAeVv7ol; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4F2gG160hdz9sW4 for ; Sat, 20 Mar 2021 23:35:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=clocoYm9Zico02RUFU2URErTGm+W3hBrQAwR2QxkJ44=; b=TLII5l5475t8pWbXfZfyox/SHU HNiuDZaK/3mzHpvrBQg3o7aEM6WRJMo8SpQYZNR97y19Dqz8X8C085sm+3ZQGoXuAqeXYi9anrvpz p6cckQWUG4TeRAzAjC99HMyg6/WNgL4MRE/UacApYHFXI29MpOE/h9LYDjT8I8jpMa+B+pv0P3oVu GGrrrotQfcQ1QqlUomjyBepw6iLrkOJGLUvPBDLL1N66xlfuEoZ845BZeQon2NzPKFqZ4zBaT/hA6 sYMVA2R5wFczatMG6t2+YZtYclvm9nSHzBmhn1iQsXhH5lulKsEUxoST8TuM8RmNqPTrESi5OeBZe nIynUubA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNanE-008oog-6f; Sat, 20 Mar 2021 12:33:24 +0000 Received: from mout-p-102.mailbox.org ([2001:67c:2050::465:102]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNan8-008oo1-UQ for openwrt-devel@lists.openwrt.org; Sat, 20 Mar 2021 12:33:21 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4F2gCY5TQvzQjmR; Sat, 20 Mar 2021 13:33:13 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hauke-m.de; s=MBO0001; t=1616243591; 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; bh=2P8kOgmTfhcpl80ispMDOYA33OIj8IYQZg3WiZaMTMY=; b=EAeVv7olDj9+adfMdcgi3/YIH0E4LVXZO08ii5bOvYoXmNZ4k5Vn5xSRFiPdf79RBtE2r/ E/9pFfix8TOb+FhT92R1Q+H8t8Q6Wk2+eadAWYntKuYaLCasOi3RAYNaV6IPRQVExkWF/5 0pk9V8kSIqmCs9utUtDoGHPxmEVVRkIJ2B3GcoSwVUnA3XMwOvRPjPrdvLubyfEiSorEK/ muFcpG7WF5a8ZnEvlQ9p2m/bMvPPDpzTxAhGYPlG5RnpBrsgVPcJFSDTHTriz9C9+xgUt8 alXxDh3bvQMoIKZ17fj4Aov8fuYlG/fSckBN4gkeJRX2LfEHCOQ12pPme++0Cg== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id EN-Rkwhaoj_5; Sat, 20 Mar 2021 13:33:07 +0100 (CET) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Cc: jo@mein.io, Hauke Mehrtens Subject: [PATCH 1/2] uhttpd: Reload config after uhttpd-mod-ubus was added Date: Sat, 20 Mar 2021 13:32:27 +0100 Message-Id: <20210320123228.3697143-1-hauke@hauke-m.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -5.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: A6DF817CE X-Rspamd-UID: a823e3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210320_123319_464083_7216C2F7 X-CRM114-Status: GOOD ( 10.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Without this change the config is only committed, but the uhttpd daemon is not reloaded. This reload is needed to apply the config. Without the reload of uhttpd, the ubus server is not available over [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:67c:2050:0:0:0:465:102 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Without this change the config is only committed, but the uhttpd daemon is not reloaded. This reload is needed to apply the config. Without the reload of uhttpd, the ubus server is not available over http and returns a Error 404. This caused problems when installing luci on the snapshots and accessing it without reloading uhttpd. There is another bug in uhttpd that it does not discard the request data when it returned a http error 404 for a post request and interpret it as part of the next request on the same TCP connection. Signed-off-by: Hauke Mehrtens --- package/network/services/uhttpd/files/ubus.default | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default index ca9e72a3150a..35724ba57e03 100644 --- a/package/network/services/uhttpd/files/ubus.default +++ b/package/network/services/uhttpd/files/ubus.default @@ -3,11 +3,13 @@ if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then uci set uhttpd.main.ubus_prefix=/ubus uci commit uhttpd + reload_config fi [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && { uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock' uci commit uhttpd + reload_config } exit 0 From patchwork Sat Mar 20 12:32:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1456098 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=desiato.20200630 header.b=TYkU8QDs; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=hauke-m.de header.i=@hauke-m.de header.a=rsa-sha256 header.s=MBO0001 header.b=UeMCyMyP; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4F2gG1555vz9sVS for ; Sat, 20 Mar 2021 23:35:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B3uG6LzSsU5opg++D/lnqazs0ltmhg8tpi9j/ofNPK0=; b=TYkU8QDspBfjn6WNBwFKrGJwI IfK4UZiCGJYCvFU9aC7rI8c+UyQIW1y+P5LYqjvOpq//A1+grS/eZ5nFcLhuS1guE94Cab0Oth9s/ qJIcMkXgBp7RZL1LyBEZbBUidVRn/a42RuV7Sk6zeaX7FSsQkRlts5lnvRQnzBgoLwJ6WdtbIkxZz C+73U7g8jHDDbwhlICStUxATYhmXSNGQodw6LPybAovQeSKqs5u8xjO0y+u0o7zaGuwJqzPRD9rXU j989DHxALUkGBLEPOuFSD4Td5yTOJXB4VJ3km3xOa6y6E4tKQBt2RSlJ+qwQyv8LEE2+yqp5vI6SE DnvZFytJA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNanK-008opH-Md; Sat, 20 Mar 2021 12:33:30 +0000 Received: from mout-p-201.mailbox.org ([2001:67c:2050::465:201]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNan8-008oo3-V9 for openwrt-devel@lists.openwrt.org; Sat, 20 Mar 2021 12:33:21 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4F2gCY6tMczQjmX; Sat, 20 Mar 2021 13:33:13 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hauke-m.de; s=MBO0001; t=1616243592; 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=OxIvMBtVKodt85ztkioVn04zDcdwZ5a/Tn16YGTHAik=; b=UeMCyMyPjz23kvfQd6jyN5gNeW4jgFv6fX7soQk1QB6qhZ5MtIiqnil+qKBjGH++b52htN PseljQMFEZLRHe7Ol83yrRjCsv4kCd2gZBPv+LYKatpV0cZxrfBmOCeDVxfEeHRhLmOsp+ qG4iGeg2bnhfd8KK0DOOPuJu77zSsYTwanAg5BeLCCEcQjS57SV/+BnMfdqnZ8ZDv5eOAh lciTudz5epFz+1zIM7dSOHif3mkmys3cEx2yV8Lu9x1zxESgr9q0NKPTu198RBRziZ+9U9 wHx/NUvE01NKhEt9nnNp895XOqJPW7/mt0L5szb+1RnlAQKe3ImVRnkKlU3UHA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id BLBRAOLeEK8Y; Sat, 20 Mar 2021 13:33:07 +0100 (CET) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Cc: jo@mein.io, Hauke Mehrtens Subject: [PATCH 2/2] uhttpd: Execute uci commit and reload_config once Date: Sat, 20 Mar 2021 13:32:28 +0100 Message-Id: <20210320123228.3697143-2-hauke@hauke-m.de> In-Reply-To: <20210320123228.3697143-1-hauke@hauke-m.de> References: <20210320123228.3697143-1-hauke@hauke-m.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -5.14 / 15.00 / 15.00 X-Rspamd-Queue-Id: F0BBE17CF X-Rspamd-UID: 98e135 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210320_123319_449362_A01C27EF X-CRM114-Status: UNSURE ( 8.19 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Instead of doing uci commit and reload_config for each setting do it only once when one of these options was changed. This should make it a little faster when both conditions are taken. Signed-off-by: Hauke Mehrtens --- package/network/services/uhttpd/files/ubus.default | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:67c:2050:0:0:0:465:201 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Instead of doing uci commit and reload_config for each setting do it only once when one of these options was changed. This should make it a little faster when both conditions are taken. Signed-off-by: Hauke Mehrtens --- package/network/services/uhttpd/files/ubus.default | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default index 35724ba57e03..019f25ae6288 100644 --- a/package/network/services/uhttpd/files/ubus.default +++ b/package/network/services/uhttpd/files/ubus.default @@ -1,15 +1,17 @@ #!/bin/sh +commit=0 + if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then uci set uhttpd.main.ubus_prefix=/ubus - uci commit uhttpd - reload_config + commit=1 fi [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && { uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock' - uci commit uhttpd - reload_config + commit=1 } +[ "$commit" = 1 ] && uci commit uhttpd && reload_config + exit 0