wg: fix errno propagation and messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
434bc616b2
commit
a8654606c2
5 changed files with 8 additions and 9 deletions
|
@ -185,7 +185,7 @@ static int userspace_get_wireguard_interfaces(struct inflatable_buffer *buffer)
|
||||||
|
|
||||||
dir = opendir(SOCK_PATH);
|
dir = opendir(SOCK_PATH);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return errno == ENOENT ? 0 : errno;
|
return errno == ENOENT ? 0 : -errno;
|
||||||
while ((ent = readdir(dir))) {
|
while ((ent = readdir(dir))) {
|
||||||
len = strlen(ent->d_name);
|
len = strlen(ent->d_name);
|
||||||
if (len <= strlen(SOCK_SUFFIX))
|
if (len <= strlen(SOCK_SUFFIX))
|
||||||
|
@ -964,7 +964,6 @@ char *ipc_list_devices(void)
|
||||||
cleanup:
|
cleanup:
|
||||||
errno = -ret;
|
errno = -ret;
|
||||||
if (errno) {
|
if (errno) {
|
||||||
perror("Error when trying to get a list of WireGuard interfaces");
|
|
||||||
free(buffer.buffer);
|
free(buffer.buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ int set_main(int argc, char *argv[])
|
||||||
device->name[IFNAMSIZ - 1] = '\0';
|
device->name[IFNAMSIZ - 1] = '\0';
|
||||||
|
|
||||||
if (ipc_set_device(device) != 0) {
|
if (ipc_set_device(device) != 0) {
|
||||||
perror("Unable to set device");
|
perror("Unable to modify interface");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ int setconf_main(int argc, char *argv[])
|
||||||
device->name[IFNAMSIZ - 1] = '\0';
|
device->name[IFNAMSIZ - 1] = '\0';
|
||||||
|
|
||||||
if (ipc_set_device(device) != 0) {
|
if (ipc_set_device(device) != 0) {
|
||||||
perror("Unable to set device");
|
perror("Unable to modify interface");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,7 +390,7 @@ int show_main(int argc, char *argv[])
|
||||||
char *interfaces = ipc_list_devices(), *interface;
|
char *interfaces = ipc_list_devices(), *interface;
|
||||||
|
|
||||||
if (!interfaces) {
|
if (!interfaces) {
|
||||||
perror("Unable to get devices");
|
perror("Unable to list interfaces");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
interface = interfaces;
|
interface = interfaces;
|
||||||
|
@ -398,7 +398,7 @@ int show_main(int argc, char *argv[])
|
||||||
struct wgdevice *device = NULL;
|
struct wgdevice *device = NULL;
|
||||||
|
|
||||||
if (ipc_get_device(&device, interface) < 0) {
|
if (ipc_get_device(&device, interface) < 0) {
|
||||||
perror("Unable to get device");
|
perror("Unable to access interface");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
|
@ -424,7 +424,7 @@ int show_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
interfaces = ipc_list_devices();
|
interfaces = ipc_list_devices();
|
||||||
if (!interfaces) {
|
if (!interfaces) {
|
||||||
perror("Unable to get devices");
|
perror("Unable to list interfaces");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
interface = interfaces;
|
interface = interfaces;
|
||||||
|
@ -437,7 +437,7 @@ int show_main(int argc, char *argv[])
|
||||||
struct wgdevice *device = NULL;
|
struct wgdevice *device = NULL;
|
||||||
|
|
||||||
if (ipc_get_device(&device, argv[1]) < 0) {
|
if (ipc_get_device(&device, argv[1]) < 0) {
|
||||||
perror("Unable to get device");
|
perror("Unable to access interface");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ int showconf_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipc_get_device(&device, argv[1])) {
|
if (ipc_get_device(&device, argv[1])) {
|
||||||
perror("Unable to get device");
|
perror("Unable to access interface");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue