From 6477c83a3be562967a734679f75e9ec7b4a6e48f Mon Sep 17 00:00:00 2001 From: Andreas Weigel Date: Tue, 12 Apr 2022 08:30:32 -0400 Subject: [PATCH] wg syncconf: explicitly reset PresharedKey/PersistentKeepalive 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;