aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-09-26 15:02:41 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-09-26 15:04:07 +0200
commit892ccaf6f9782d8d5159d45649adfa0f8c8d06a6 (patch)
treed5cf5d89db2f1e2a7acb50f641cfc1d97eb7c126 /src
parentreceive: mark function static (diff)
downloadwireguard-monolithic-historical-892ccaf6f9782d8d5159d45649adfa0f8c8d06a6.tar.xz
wireguard-monolithic-historical-892ccaf6f9782d8d5159d45649adfa0f8c8d06a6.zip
tools: uapi: only make sure socket file is socket
Diffstat (limited to '')
-rw-r--r--src/tools/ipc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tools/ipc.c b/src/tools/ipc.c
index d0b5a46..45278ec 100644
--- a/src/tools/ipc.c
+++ b/src/tools/ipc.c
@@ -129,11 +129,16 @@ out:
static bool userspace_has_wireguard_interface(const char *interface)
{
- FILE *f = userspace_interface_file(interface);
- if (!f)
+ struct stat sbuf;
+ char path[PATH_MAX] = { 0 };
+
+ if (strchr(interface, '/'))
return false;
- fclose(f);
- return true;
+ if (snprintf(path, sizeof(path) - 1, SOCK_PATH "%s" SOCK_SUFFIX, interface) < 0)
+ return false;
+ if (stat(path, &sbuf) < 0)
+ return false;
+ return S_ISSOCK(sbuf.st_mode);
}
static int userspace_get_wireguard_interfaces(struct inflatable_buffer *buffer)