From patchwork Fri Jan 8 01:24:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Leonardo_M=C3=B6rlein?= X-Patchwork-Id: 1423598 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=irrelefant.net 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=hFJx7sYF; dkim-atps=neutral X-Greylist: delayed 87074 seconds by postgrey-1.36 at bilbo; Fri, 08 Jan 2021 12:29:45 AEDT Received: from merlin.infradead.org (unknown [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 4DBlrn12YYz9sSC for ; Fri, 8 Jan 2021 12:29:44 +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: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:In-Reply-To:References:List-Owner; bh=KkIemJ4RcRUFVicesY1O/3z4GSZRCWjfDhp/BtK0ekg=; b=hFJx7sYFiApYFz1+58ifknP+ev SrxDmYdripyJIMskBPBW0d726MKsYhmfpmIyNNHtjZ+nWPEuhf4Z9S3OAsm8QUs49BllQKG/Yk7HG RBQLwKZAtjse4/dsKIV3y2Vn2VjEgYU67wO3rM6yL5kQ86rTy8bmONxLD1/IbdQUyk7etno6HngWy ONkVGYgjW8gx33YooSxwb5zahFjWDbrp1N0njFmg3UtYXbHHGY5jjHuyj7eCYuIeft5hZN2o/emaF 3metrvDwjFlfiaFAxj+pVyuDi5QnglZNk8OZ5abN8R9OuqWeNLwTDuE5ajvY43ex9PY/4PgfyqT17 lObJv6Nw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxgWy-0001HA-U9; Fri, 08 Jan 2021 01:25:32 +0000 Received: from smtprelay04.ispgateway.de ([80.67.31.27]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxgWF-0001Gi-DM for openwrt-devel@lists.openwrt.org; Fri, 08 Jan 2021 01:24:49 +0000 Received: from [82.207.218.24] (helo=orange.fritz.box) by smtprelay04.ispgateway.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) (envelope-from ) id 1kxgUs-0004Es-Ta; Fri, 08 Jan 2021 02:23:22 +0100 From: =?utf-8?q?Leonardo_M=C3=B6rlein?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH] wireguard-tools: allow generating private_key Date: Fri, 8 Jan 2021 02:24:35 +0100 Message-Id: <20210108012435.175345-1-me@irrelefant.net> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Df-Sender: bWVAaXJyZWxlZmFudC5uZXQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210107_202447_472358_5F4742A7 X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [80.67.31.27 listed in wl.mailspike.net] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches 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: =?utf-8?q?Leonardo_M=C3=B6rlein?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org When the uci configuration is created automatically during a very early stage, where no entropy daemon is set up, generating the key directly is not an option. Therefore we allow to set the private_key to "generate" and generate the private key directly before the interface is taken up. Signed-off-by: Leonardo Mörlein --- package/network/utils/wireguard-tools/files/wireguard.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/network/utils/wireguard-tools/files/wireguard.sh b/package/network/utils/wireguard-tools/files/wireguard.sh index 63261aea71..d874c4b5e6 100644 --- a/package/network/utils/wireguard-tools/files/wireguard.sh +++ b/package/network/utils/wireguard-tools/files/wireguard.sh @@ -121,6 +121,11 @@ proto_wireguard_setup() { ip link set mtu "${mtu}" dev "${config}" fi + if [ "$private_key" == "generate" ]; then + private_key=`"${WG}" genkey` + uci -q set network."$config".private_key="$private_key" && uci -q commit network + fi + proto_init_update "${config}" 1 umask 077