Skip to content

Commit 0b7d982

Browse files
committed
wg-quick: use addconf instead of setconf
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>
1 parent d3b40af commit 0b7d982

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/wg-quick/android.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ static void set_routes(const char *iface, unsigned int netid)
10471047
static void set_config(const char *iface, const char *config)
10481048
{
10491049
FILE *config_writer;
1050-
_cleanup_free_ char *cmd = concat("wg setconf ", iface, " /proc/self/fd/0", NULL);
1050+
_cleanup_free_ char *cmd = concat("wg addconf ", iface, " /proc/self/fd/0", NULL);
10511051
int ret;
10521052

10531053
printf("[#] %s\n", cmd);

src/wg-quick/darwin.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ add_route() {
370370
}
371371

372372
set_config() {
373-
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
373+
cmd wg addconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
374374
}
375375

376376
save_config() {

src/wg-quick/freebsd.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ add_route() {
338338
}
339339

340340
set_config() {
341-
echo "$WG_CONFIG" | cmd wg setconf "$INTERFACE" /dev/stdin
341+
echo "$WG_CONFIG" | cmd wg addconf "$INTERFACE" /dev/stdin
342342
}
343343

344344
save_config() {

src/wg-quick/linux.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ add_default() {
249249
}
250250

251251
set_config() {
252-
cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG")
252+
cmd wg addconf "$INTERFACE" <(echo "$WG_CONFIG")
253253
}
254254

255255
save_config() {

src/wg-quick/openbsd.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ add_route() {
338338
}
339339

340340
set_config() {
341-
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
341+
cmd wg addconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
342342
}
343343

344344
save_config() {

0 commit comments

Comments
 (0)