]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: use addconf instead of setconf master
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 19 Jun 2025 14:58:39 +0000 (16:58 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 19 Jun 2025 15:08:50 +0000 (17:08 +0200)
The example in the man page at some point changed:

-    \fBPostUp = wg set %i private-key <(pass WireGuard/private-keys/%i)\fP
+    \fBPreUp = wg set %i private-key <(pass WireGuard/private-keys/%i)\fP

This is actually wrong because PreUp is followed by set_config(), which
calls `wg setconf`, which in turn deletes the private key from the
interface because it is missing from the configuration. Replacing this
with `wg addconf` is safe to do because the interface is newly created.

Suggested-by: Matthias Dressel <code@deadcode.eu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/wg-quick/android.c
src/wg-quick/darwin.bash
src/wg-quick/freebsd.bash
src/wg-quick/linux.bash
src/wg-quick/openbsd.bash

index 1263ee416ada9d5dc1fe7e5dcf97b82300ed4c4d..3ed05e52cefe0b0b5bdf1f25526be39528b6f588 100644 (file)
@@ -1047,7 +1047,7 @@ static void set_routes(const char *iface, unsigned int netid)
 static void set_config(const char *iface, const char *config)
 {
        FILE *config_writer;
-       _cleanup_free_ char *cmd = concat("wg setconf ", iface, " /proc/self/fd/0", NULL);
+       _cleanup_free_ char *cmd = concat("wg addconf ", iface, " /proc/self/fd/0", NULL);
        int ret;
 
        printf("[#] %s\n", cmd);
index ed6aadaccf19fe634783a38aa4722be8782e2231..1b7fe5e1a1640c9d919335d37a1aa4eb1bdd2f14 100755 (executable)
@@ -370,7 +370,7 @@ add_route() {
 }
 
 set_config() {
-       cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
+       cmd wg addconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
 }
 
 save_config() {
index af5b174546fc59f9a6dbb90c8170e3bc0b25fe7f..aeae18d9950af6c8b4cc42aabfa5e5042568d823 100755 (executable)
@@ -338,7 +338,7 @@ add_route() {
 }
 
 set_config() {
-       echo "$WG_CONFIG" | cmd wg setconf "$INTERFACE" /dev/stdin
+       echo "$WG_CONFIG" | cmd wg addconf "$INTERFACE" /dev/stdin
 }
 
 save_config() {
index af255af928d21f61fc1bd03db9c3484630da2e02..34fa5f9da8b5f9784a9d2b95bb307c2f75cf4435 100755 (executable)
@@ -249,7 +249,7 @@ add_default() {
 }
 
 set_config() {
-       cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG")
+       cmd wg addconf "$INTERFACE" <(echo "$WG_CONFIG")
 }
 
 save_config() {
index d12f70e1c222aa95c9de21ce2f7214cb6cf51532..19b9909b2e7dd01b17e7664f99f6b5ad7d0a1865 100755 (executable)
@@ -338,7 +338,7 @@ add_route() {
 }
 
 set_config() {
-       cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
+       cmd wg addconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
 }
 
 save_config() {