From patchwork Fri Oct 29 08:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= X-Patchwork-Id: 1547894 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Ey3HiHy5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mind.be header.i=@mind.be header.a=rsa-sha256 header.s=google header.b=gcbS+Lin; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hgbk20JjQz9sRK for ; Fri, 29 Oct 2021 19:50:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=fvAKEWAPLQ1z3riz/9NkoP5DEWvPMOyrbLqZknKn7/g=; b=Ey3HiHy54USegh UiFhwVGjtFOxhhOkeP5XhJauhJWyZaFV/fERjryq5gFLavdVzS82KRW4xHfrPuXHKpTkx9fTxTWOp mvCQyqxvUApcWAjELTngsBzNXkqkkAFeWyFWPH2ZGd9OM7EVTTdW11JakAlCR/979JKxyO0wpc5vp p6qs62s09hGEE/USzInq1NTHfWzIaDTQWukIA6zRR3goZxYuv1WNZSUe4piHS3xW3rvXHu3ICumkc aq/9D56AX4hEo+h1N48EQKOexHouMwaa/0TvomPHJ0jmDqPrAUrNrnVcL1+Ft1xraH3UR9YlAr18N eNPLM8fJ7bD2nPj0f3ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgNVv-00AKex-4w; Fri, 29 Oct 2021 08:45:27 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgNVl-00AKdR-5s for openwrt-devel@lists.openwrt.org; Fri, 29 Oct 2021 08:45:19 +0000 Received: by mail-ed1-x530.google.com with SMTP id w15so36256989edc.9 for ; Fri, 29 Oct 2021 01:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rOsvSL2Q6EBO/5NedYHdD+5/3dK2Z7DLcv1D/xzOB1Y=; b=gcbS+Linfj8IQ+m5tax85G8TfccSr7+2fcRlUAcJveCW+pFZAx2SyQERR5luB4VZ78 3rpPEgi10a05ATeKc+bj60LxCvpTSOUcl3aeRN0NJEWLVbleL+oGe5QYbUOqC8YGb1mr N9O79cldlvapTodw//JMK7aOpsD8DFpH79OMacyIBrlBu+AOsdAbjAmmRXHvFoM4lXiU AK8O4w+AwbUtEfD4CXLsNpms3maOCEatEInQpN4zVjGKjwqxqmYcI5kVAp7fCwQuorr/ yuOpKF6cxs2edOHc1LTw66bV9/3pDzmh76yxqqBrcfaR2LMnYvK19Fk2FnxNh2LqpyoS etrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rOsvSL2Q6EBO/5NedYHdD+5/3dK2Z7DLcv1D/xzOB1Y=; b=e02Epv6QR9x3ZcrZZbu9stTY9IsxEVwR61fh1BrGEaPV+vgfuGzSXYoI7fRaclPM4R s6gLSMJiYhXL7rOfUbBKzZDVKtYXy1NDugzGBa01aGy/MDKQ2bgDvXQDtKsjEn2115qv cqTKvzGl331dwXDANeb8TabfmDRGIhh7WuhEXks4+vHCModtmeHsoMeY8PU9GE6raxJY 3Wtei7EFcAK8yO/jit4Vt1j2STJ2bBV2nzcYHcoEvYC2UNfNZ77JBlfOL7IqipRnOWpH XL0uP/9pmpWbdvvjovvIsQk0tB44IZ7BWqLixy0n1P+K8L/FLriE/QQcNhVV0seThgak t5tg== X-Gm-Message-State: AOAM530PH4Jnh+RpIWoH3Y1YI2UyX1sqWXQk/hy93mFknD/JQ9qb2iLY R/ViIJvtXNaP6p/y6ApRLy0w3KKq3bODmA== X-Google-Smtp-Source: ABdhPJy/9NNFLkTJ5V2AB4BXAtM0s9cSwSV2GYkLKinQnSzbdOaM+L/gOrOMGdH779ohE+f0HjMhWQ== X-Received: by 2002:a17:907:1c81:: with SMTP id nb1mr12644006ejc.153.1635497114922; Fri, 29 Oct 2021 01:45:14 -0700 (PDT) Received: from localhost.localdomain (5.26-130-109.adsl-dyn.isp.belgacom.be. [109.130.26.5]) by smtp.gmail.com with ESMTPSA id i6sm2530663ejw.65.2021.10.29.01.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 01:45:14 -0700 (PDT) From: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= Subject: [PATCH v2] hostapd: add fallback for WPS on stations Date: Fri, 29 Oct 2021 10:45:06 +0200 Message-Id: <20211029084506.2951779-1-raphael.melotte@mind.be> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211022140828.1199224-1-raphael.melotte@mind.be> References: <20211022140828.1199224-1-raphael.melotte@mind.be> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211029_014517_398452_95870416 X-CRM114-Status: GOOD ( 18.85 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.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: Up to now the WPS script triggered WPS on the stations only if it could not trigger it successfully on any hostapd instance. In a Multi-AP context, there can be a need (to establish a new wireless backhaul link) to trigger WPS on the stations, regardless of whether there is already a hostapd instance configured or not. The [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:530 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Up to now the WPS script triggered WPS on the stations only if it could not trigger it successfully on any hostapd instance. In a Multi-AP context, there can be a need (to establish a new wireless backhaul link) to trigger WPS on the stations, regardless of whether there is already a hostapd instance configured or not. The current script makes it impossible, as if hostapd is running and configured, WPS would always be triggered on hostapd only. To allow both possibilities, the following changes are made: - Change the "pressed" action to "release", so that we can make use of the "$SEEN" variables (to know for how long the button was pressed). - If the button is pressed for less than 3 seconds, keep the original behavior. - If the button is pressed for 3 seconds or more, trigger WPS on the stations, regardless of the status of any running hostapd instance. - Add comments explaining both behaviors. - While at it, replace the usage of '-a' with a '[] && []' construct (see [1]). This gives users a "fallback" mechanism to onboard a device to a Multi-AP network, even if the device already has a configured hostapd instance running. [1]: https://github.com/koalaman/shellcheck/wiki/SC2166 Signed-off-by: Raphaël Mélotte --- Changes v1 -> v2: - minor comment update. .../services/hostapd/files/wps-hotplug.sh | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/package/network/services/hostapd/files/wps-hotplug.sh b/package/network/services/hostapd/files/wps-hotplug.sh index d00939d769..073bdd1868 100644 --- a/package/network/services/hostapd/files/wps-hotplug.sh +++ b/package/network/services/hostapd/files/wps-hotplug.sh @@ -38,13 +38,20 @@ wps_catch_credentials() { done } -if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then - wps_done=0 - ubusobjs="$( ubus -S list hostapd.* )" - for ubusobj in $ubusobjs; do - ubus -S call $ubusobj wps_start && wps_done=1 - done - [ $wps_done = 0 ] || return 0 +if [ "$ACTION" = "released" ] && [ "$BUTTON" = "wps" ]; then + # If the button was pressed for 3 seconds or more, trigger WPS on + # wpa_supplicant only, no matter if hostapd is running or not. If + # was pressed for less than 3 seconds, try triggering on + # hostapd. If there is no hostapd instance to trigger it on or WPS + # is not enabled on them, trigger it on wpa_supplicant. + if [ "$SEEN" -lt 3 ] ; then + wps_done=0 + ubusobjs="$( ubus -S list hostapd.* )" + for ubusobj in $ubusobjs; do + ubus -S call $ubusobj wps_start && wps_done=1 + done + [ $wps_done = 0 ] || return 0 + fi wps_done=0 ubusobjs="$( ubus -S list wpa_supplicant.* )" for ubusobj in $ubusobjs; do