Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH 0/1] wg syncconf not clearing PresharedKey/PersistentKeepalive
@ 2022-04-22 17:45 Andreas Weigel
  2022-04-22 17:45 ` [PATCH 1/1] wg syncconf: explicitly reset PresharedKey/PersistentKeepalive Andreas Weigel
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Weigel @ 2022-04-22 17:45 UTC (permalink / raw)
  To: wireguard; +Cc: Andreas Weigel

Hi,

I noticed that wg syncconf does not actually clear PresharedKey and
PersistentKeepalive values if those are not set in the file but set in
the running config. The proposed patch changes that to always
clear those if they are not set in the configuration file, which imho is
the correct behavior.

Andreas

Andreas Weigel (1):
  wg syncconf: explicitly reset PresharedKey/PersistentKeepalive

 src/setconf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] wg syncconf: explicitly reset PresharedKey/PersistentKeepalive
  2022-04-22 17:45 [PATCH 0/1] wg syncconf not clearing PresharedKey/PersistentKeepalive Andreas Weigel
@ 2022-04-22 17:45 ` Andreas Weigel
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Weigel @ 2022-04-22 17:45 UTC (permalink / raw)
  To: wireguard; +Cc: Andreas Weigel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-24 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 17:45 [PATCH 0/1] wg syncconf not clearing PresharedKey/PersistentKeepalive Andreas Weigel
2022-04-22 17:45 ` [PATCH 1/1] wg syncconf: explicitly reset PresharedKey/PersistentKeepalive Andreas Weigel

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).