aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/setconf.c
diff options
context:
space:
mode:
authorJulian Orth <ju.orth@gmail.com>2018-09-11 20:14:55 +0200
committerJulian Orth <ju.orth@gmail.com>2018-12-17 15:39:45 +0100
commit21e5f1bcc352af8a2ed8b4212872688d214ae464 (patch)
tree6e2a9c46e38e5829f49fc7be39943b5cffc6e2e2 /src/tools/setconf.c
parenttools: add framework for shared options (diff)
downloadwireguard-monolithic-historical-21e5f1bcc352af8a2ed8b4212872688d214ae464.tar.xz
wireguard-monolithic-historical-21e5f1bcc352af8a2ed8b4212872688d214ae464.zip
tools: allow specifying the device namespace
The user can now use wg --netns <pid|file-path> <subcommand> to specify the network namespace in which wg should act. This sets the attribute WGDEVICE_A_DEV_NETNS_PID or WGDEVICE_A_DEV_NETNS_FD. In the case of wg --netns <pid|file-path> show all we have to try to enter the network namespace because the kernel interface does not allow us to list devices in a network namespace referenced by pid or fd. Since entering a network namespace requires CAP_SYS_ADMIN in the current user namespace and the target user namespace, this is almost useless. TODO: Add the missing functionality to the kernel.
Diffstat (limited to 'src/tools/setconf.c')
-rw-r--r--src/tools/setconf.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/tools/setconf.c b/src/tools/setconf.c
index 8133bdd..cf224fe 100644
--- a/src/tools/setconf.c
+++ b/src/tools/setconf.c
@@ -21,7 +21,6 @@ int setconf_main(int argc, char *argv[], struct wgoptions *options)
char *config_buffer = NULL;
size_t config_buffer_len = 0;
int ret = 1;
- (void)options;
if (argc != 3) {
fprintf(stderr, "Usage: %s %s <interface> <configuration filename>\n", PROG_NAME, argv[0]);
@@ -51,7 +50,7 @@ int setconf_main(int argc, char *argv[], struct wgoptions *options)
strncpy(device->name, argv[1], IFNAMSIZ - 1);
device->name[IFNAMSIZ - 1] = '\0';
- if (ipc_set_device(device) != 0) {
+ if (ipc_set_device(&options->dev_netns, device) != 0) {
perror("Unable to modify interface");
goto cleanup;
}