From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 8Ot6Jl5Y+mZDugAA62LTzQ:P1 (envelope-from ) for ; Mon, 30 Sep 2024 07:50:54 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 8Ot6Jl5Y+mZDugAA62LTzQ (envelope-from ) for ; Mon, 30 Sep 2024 09:50:54 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=AhfkNbz4; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=X6Ls1o2u; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1727682654; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=bhBmXF/5ybyJMiTpzij9PrNx2q6SchOatI1eIHF0hiY=; b=W3qvcaGeFniH+jobhN1oFlgWMAFEXM9SC6te6Fn3u6HRGtQOVhkjQhtrtc7toihiUeJ6QA 0t5uceu90b+WyDN7xbTSbz4Cdswmd0hlkjfuzmD50+SkzwW+NeCHNdfJ9/rtIiy2LVbmTV IZBSxeAvHBo+iHqwSwgx19u9UwISSDMtSh8VarwAbjTe0LmkIMBqkoCEB3+zkkXKzl4Ori t0Aa9xgwQJmHm+7VgBn8Dby8qQhlkWsmHP774+y2AsTUukCgfBpwtBviEGOW5DP4pmce9k z3GK1ZHEacmxridKUNTwQcyVlZ/rSii7Iu3HgVxgifCfBZ056SqVXyhiJDgUCw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=AhfkNbz4; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=X6Ls1o2u; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1727682654; a=rsa-sha256; cv=none; b=HuG9vaaE8TVvDA/fhB3FveONYEU3SL09s6tJARQPHL7y9yiaLSAjdl1llb9xg00wXxHTn/ BuVoFnvdORCha83w/sWtsKZGEYEkxDPAMAsYgVPY3RH9GhpxAEg2cHaORL7hFxu4eivVhY 1jA1GruYYIT2xMTWcTmQFavsRa8FxHepoKHj/dQ75xrLdRSdZYPlU//rdo8AEHyodGv/KK En2sqXIswKJZ91Iln9TtVGtZ2AoTfNqsYfztPfJi0DaaQByl8i2zxQtQii5tPrRTu2ZJjy CT/jg5xBd3pUyMNZeq7mW83KIdiXPL3k2DhF8thpKQ8bgIhe+z8kRQF0m/KjoA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 61C5D1E604 for ; Mon, 30 Sep 2024 09:50:54 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svBAz-0008Kq-C4; Mon, 30 Sep 2024 03:50:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svBAj-0007oF-BN for guix-patches@gnu.org; Mon, 30 Sep 2024 03:50:22 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svBAi-00022F-M1 for guix-patches@gnu.org; Mon, 30 Sep 2024 03:50:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=bhBmXF/5ybyJMiTpzij9PrNx2q6SchOatI1eIHF0hiY=; b=AhfkNbz4zo9/9ZD7w9EZYGdY70P2ArhbSHrlTkEj13NLZQ42NiNWTDvHl44oigy70noA/r8eb2kp+SvquDsjb7XFfvsgg/un3IuyjF0zn3uV+mk/VO1uzLkdjXuMLQMeR2YFQCZecvASgDxTOL/QqqhlR/fmSPAz4I2D204z6iE0Avup7OZjVCcfieWEeD0Fm6Zl4BlEKZgHD6atxLlZOKe4n7HZJx5z5ZwMMWZorae9giz+i9amSUd23Bo7OKDRLwdrw9sIQ2n1dj3vyBdIABYMPW7PRsiE077bINX1EPuExFNzKiVgF9nfM2s81NpvodkmhCRAb/b9DkVECKJc7A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1svAq6-00067n-74 for guix-patches@gnu.org; Mon, 30 Sep 2024 03:29:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73465] Wireguard: Rename field private-key to private-key-file References: <87h6a4jsej.fsf@gmail.com> In-Reply-To: <87h6a4jsej.fsf@gmail.com> Resent-From: Apoorv Singh Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 30 Sep 2024 07:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73465 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73465@debbugs.gnu.org Received: via spool by 73465-submit@debbugs.gnu.org id=B73465.172768132823511 (code B ref 73465); Mon, 30 Sep 2024 07:29:02 +0000 Received: (at 73465) by debbugs.gnu.org; 30 Sep 2024 07:28:48 +0000 Received: from [127.0.0.1] (port=44566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svApj-00066s-Ik for submit@debbugs.gnu.org; Mon, 30 Sep 2024 03:28:46 -0400 Received: from [209.85.210.176] (port=50473 helo=mail-pf1-f176.google.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svAUb-0005GL-FY for 73465@debbugs.gnu.org; Mon, 30 Sep 2024 03:09:09 -0400 Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-71c702b2d50so671847b3a.1 for <73465@debbugs.gnu.org>; Mon, 30 Sep 2024 00:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727679902; x=1728284702; darn=debbugs.gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=bhBmXF/5ybyJMiTpzij9PrNx2q6SchOatI1eIHF0hiY=; b=X6Ls1o2uOlehXTHVu5XivK1r3yGkjAxMeiNWIzFcuJO+hau8y1T+aO3+jGEnKz9bnP 1HuU3X2IXW5F1vWczk3umVo/Q4zKYWgKjXUy+YseUZ/Iv81ia81QgTrqCsnJgjnOxMQg PySMXhbYZscrT8cEICVUnscoijdYsSYjxVXR+lmzgZQDZw29DsEyV9HVUUvNPiUfKMSu mA4k/NaOco80OqF8yPeRe0NP05ki3f6rV+EDzHHIN19YmUf4ec5czqUu4ozMz05H9sAX 3EogRw0e8X8I5HNsvanbeVqBS0/GVvuWWVvL1FmgsV7qHcxmDB8Xm8jCeHqtGZDFVX6O 7Yvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727679902; x=1728284702; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bhBmXF/5ybyJMiTpzij9PrNx2q6SchOatI1eIHF0hiY=; b=hz/cfmP/q0buNtI8MkL/8cUbE56g8v+5iBdxDBYoikKpQiI8q+lbr4Qr+upqvYlzVs NbQeYOX3OyX6bSu1eKeXqPQD/YZ4N+c1fD7mj6k7+iv/GKmrL3jAT3mSNRPmIWA28lCh V+afc1g4ldtH2TAuzD0HlQmWpIvC3fxuKTMib7lqBDBkKjYy6LHFn7wDohX01gH9gpjO mVd4Dz8Uw85W8pO4xtekFmbMMxiR8KgxZ/2oa+GoGcoELGdi6Sjl0qfptNHNQgEDKe6y /rBCTX6VAVHE/t3+Wu9ATH8qZkmepm0BS/RhAskP/GHOlnyf4FpyoxQNcus4pFKclJ4g vZOg== X-Gm-Message-State: AOJu0YxvoFvylqY9CnFkUSQwDtopNQp/F/9da2xqW1fbGql/x0wmVBS1 ao0I+5MDHSEZdbYwkGZgecFtS6+3pcBqpdq7zLekZ/eDCqF02fWrHwou X-Google-Smtp-Source: AGHT+IHo9m2r3FWZCWuykgRijHc0yYp/BUcxokrdqWtNn6jOtqcAm3l1bUy58UU+gzmq48p9KYh2og== X-Received: by 2002:a05:6a20:2799:b0:1d4:fae4:7543 with SMTP id adf61e73a8af0-1d4fae47560mr13230003637.0.1727679901464; Mon, 30 Sep 2024 00:05:01 -0700 (PDT) Received: from MachineY ([139.5.251.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b264bccc1sm5551971b3a.82.2024.09.30.00.04.59 for <73465@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 00:05:00 -0700 (PDT) From: Apoorv Singh Date: Mon, 30 Sep 2024 12:34:58 +0530 Message-ID: <87cyklzko5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Mailman-Approved-At: Mon, 30 Sep 2024 03:28:31 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -1.33 X-Spam-Score: -1.33 X-Migadu-Queue-Id: 61C5D1E604 X-TUID: 9jYb5brFE7ve I made some changes, here is the output of `git diff`, ``` diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index eee7e78c6d..ebac4ad943 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -67,7 +67,8 @@ (define-module (gnu services vpn) wireguard-peer-endpoint wireguard-peer-allowed-ips wireguard-peer-public-key - wireguard-peer-preshared-key + wireguard-peer-preshared-key ; deprecated + wireguard-peer-preshared-key-file wireguard-peer-keep-alive wireguard-configuration @@ -79,7 +80,8 @@ (define-module (gnu services vpn) wireguard-configuration-dns wireguard-configuration-monitor-ips? wireguard-configuration-monitor-ips-interval - wireguard-configuration-private-key + wireguard-configuration-private-key ; deprecated + wireguard-configuration-private-key-file wireguard-configuration-peers wireguard-configuration-pre-up wireguard-configuration-post-up @@ -721,15 +723,17 @@ (define strongswan-service-type (define-record-type* wireguard-peer make-wireguard-peer wireguard-peer? - (name wireguard-peer-name) - (endpoint wireguard-peer-endpoint - (default #f)) ;string - (public-key wireguard-peer-public-key) ;string - (preshared-key wireguard-peer-preshared-key - (default #f)) ;string - (allowed-ips wireguard-peer-allowed-ips) ;list of strings - (keep-alive wireguard-peer-keep-alive - (default #f))) ;integer + (name wireguard-peer-name) + (endpoint wireguard-peer-endpoint + (default #f)) ;string + (public-key wireguard-peer-public-key) ;string + (preshared-key wireguard-peer-preshared-key ;deprecated + (default #f)) ;string + (preshared-key-file wireguard-peer-preshared-key-file + (default #f)) ;string + (allowed-ips wireguard-peer-allowed-ips) ;list of strings + (keep-alive wireguard-peer-keep-alive + (default #f))) ;integer (define-record-type* wireguard-configuration make-wireguard-configuration @@ -742,6 +746,8 @@ (define-record-type* (default '("10.0.0.1/32"))) (port wireguard-configuration-port ;integer (default 51820)) + (private-key wireguard-configuration-private-key ;string ;deprecated + (default "/etc/wireguard/private.key")) (private-key-file wireguard-configuration-private-key-file ;string (default "/etc/wireguard/private.key")) (peers wireguard-configuration-peers ;list of @@ -778,18 +784,29 @@ (define (peer->config peer) (string-join (remove string-null? lines) "\n")))) (define (peers->preshared-keys peer keys) - (let ((public-key (wireguard-peer-public-key peer)) - (preshared-key (wireguard-peer-preshared-key peer))) - (if preshared-key - (cons* public-key preshared-key keys) + (let* ((public-key (wireguard-peer-public-key peer)) + (preshared-key (wireguard-peer-preshared-key peer)) + (preshared-key-file (wireguard-peer-preshared-key-file peer)) + (final-preshared-key (or preshared-key preshared-key-file))) + ;; XXX Warn about deprecated preshared-key field with newer replacement + (when preshared-key + (warn-about-deprecation 'preshared-key #f #:replacement 'preshared-key-file)) + (if final-preshared-key + (cons* public-key final-preshared-key keys) keys))) (match-record config - (wireguard interface addresses port private-key-file peers dns + (wireguard interface addresses port private-key-file private-key peers dns pre-up post-up pre-down post-down table) + + ;; XXX Warn about deprecated private-key field with newer replacement + (when private-key + (warn-about-deprecation 'private-key #f #:replacement 'private-key-file)) + (let* ((config-file (string-append interface ".conf")) (peer-keys (fold peers->preshared-keys (list) peers)) (peers (map peer->config peers)) + (final-private-key (or private-key private-key-file)) (config (computed-file "wireguard-config" @@ -810,7 +827,7 @@ (define lines (list (format #f "~{PreUp = ~a~%~}" pre-up))) (format #f "PostUp = ~a set %i private-key ~a\ ~{ peer ~a preshared-key ~a~}" #$(file-append wireguard "/bin/wg") -#$private-key-file '#$peer-keys) +#$final-private-key '#$peer-keys) #$@(if (null? post-up) '() (list (format #f "~{PostUp = ~a~%~}" post-up))) @@ -836,23 +853,29 @@ (define lines (define (wireguard-activation config) (match-record config - (private-key-file wireguard) - #~(begin - (use-modules (guix build utils) - (ice-9 popen) - (ice-9 rdelim)) - (mkdir-p (dirname #$private-key-file)) - (unless (file-exists? #$private-key-file) - (let* ((pipe - (open-input-pipe (string-append - #$(file-append wireguard "/bin/wg") - " genkey"))) - (key (read-line pipe))) - (call-with-output-file #$private-key-file - (lambda (port) - (display key port))) - (chmod #$private-key-file #o400) - (close-pipe pipe)))))) + (private-key private-key-file wireguard) + + ;; XXX Warn about deprecated private-key field with newer replacement + (when private-key + (warn-about-deprecation 'private-key #f #:replacement 'private-key-file)) + + (let ((final-private-key (or private-key private-key-file))) + #~(begin + (use-modules (guix build utils) + (ice-9 popen) + (ice-9 rdelim)) + (mkdir-p (dirname #$final-private-key)) + (unless (file-exists? #$final-private-key) + (let* ((pipe + (open-input-pipe (string-append + #$(file-append wireguard "/bin/wg") + " genkey"))) + (key (read-line pipe))) + (call-with-output-file #$final-private-key + (lambda (port) + (display key port))) + (chmod #$final-private-key #o400) + (close-pipe pipe))))))) ;;; XXX: Copied from (guix scripts pack), changing define to define*. (define-syntax-rule (define-with-source (variable args ...) body body* ...) ``` If this is desired way of doing this, I will share the formatted patch as an attachment. -- - Apoorv Singh - Sent from Emacs.