Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Andreas Weigel <andreas.weigel@posteo.de>
To: wireguard@lists.zx2c4.com
Cc: Andreas Weigel <andreas.weigel@posteo.de>
Subject: [PATCH 1/1] wg syncconf: explicitly reset PresharedKey/PersistentKeepalive
Date: Fri, 22 Apr 2022 17:45:06 +0000	[thread overview]
Message-ID: <20220422174506.22299-2-andreas.weigel@posteo.de> (raw)
In-Reply-To: <20220422174506.22299-1-andreas.weigel@posteo.de>

make wg syncconf correctly clear a preshared key or keepalive in case
the file config does not define those; currently syncconf does not
change these settings at all if runtime has them set but file does not
---
 src/setconf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/setconf.c b/src/setconf.c
index bfd0a3a..8661a92 100644
--- a/src/setconf.c
+++ b/src/setconf.c
@@ -63,6 +63,14 @@ static bool sync_conf(struct wgdevice *file)
 	}
 
 	for_each_wgpeer(file, peer) {
+		if (!(peer->flags & WGPEER_HAS_PRESHARED_KEY)) {
+			memset(peer->preshared_key, 0, WG_KEY_LEN);
+			peer->flags |= WGPEER_HAS_PRESHARED_KEY;
+		}
+		if (!(peer->flags & WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL)) {
+			peer->persistent_keepalive_interval = 0;
+			peer->flags |= WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL;
+		}
 		pubkeys[i].pubkey = peer->public_key;
 		pubkeys[i].from_file = true;
 		++i;
-- 
2.25.1


      reply	other threads:[~2022-04-24 20:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 17:45 [PATCH 0/1] wg syncconf not clearing PresharedKey/PersistentKeepalive Andreas Weigel
2022-04-22 17:45 ` Andreas Weigel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220422174506.22299-2-andreas.weigel@posteo.de \
    --to=andreas.weigel@posteo.de \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).