wg: only error on wg show if all interfaces fail

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-07-08 19:46:05 +02:00
parent 4367cd0d3d
commit 4502f4f2b7
1 changed files with 4 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <netdb.h>
@ -394,12 +395,13 @@ int show_main(int argc, char *argv[])
perror("Unable to list interfaces");
return 1;
}
ret = !!*interfaces;
interface = interfaces;
for (size_t len = 0; (len = strlen(interface)); interface += len + 1) {
struct wgdevice *device = NULL;
if (ipc_get_device(&device, interface) < 0) {
perror("Unable to access interface");
fprintf(stderr, "Unable to access interface %s: %s\n", interface, strerror(errno));
continue;
}
if (argc == 3) {
@ -414,6 +416,7 @@ int show_main(int argc, char *argv[])
printf("\n");
}
free_wgdevice(device);
ret = 0;
}
free(interfaces);
} else if (!strcmp(argv[1], "interfaces")) {