wg: uapi: only make sure socket file is socket
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
9ef84af8c0
commit
9a0790b50a
13
src/ipc.c
13
src/ipc.c
|
@ -129,11 +129,16 @@ out:
|
||||||
|
|
||||||
static bool userspace_has_wireguard_interface(const char *interface)
|
static bool userspace_has_wireguard_interface(const char *interface)
|
||||||
{
|
{
|
||||||
FILE *f = userspace_interface_file(interface);
|
struct stat sbuf;
|
||||||
if (!f)
|
char path[PATH_MAX] = { 0 };
|
||||||
|
|
||||||
|
if (strchr(interface, '/'))
|
||||||
return false;
|
return false;
|
||||||
fclose(f);
|
if (snprintf(path, sizeof(path) - 1, SOCK_PATH "%s" SOCK_SUFFIX, interface) < 0)
|
||||||
return true;
|
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)
|
static int userspace_get_wireguard_interfaces(struct inflatable_buffer *buffer)
|
||||||
|
|
Loading…
Reference in a new issue