diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-10 02:40:55 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-10 02:48:05 +0100 |
commit | b3e928c1bfb3e38f00ff1f24585ef4cba50e1432 (patch) | |
tree | fce3d98a42a1a5c289ed9c34ee59e342d5fd2b7f /app | |
parent | 01faa9b35894a132e7af82bd2bc1a69bbfc3ef19 (diff) |
tools: error if setconf fails
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/tools/wg-quick.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/tools/wg-quick.c b/app/tools/wg-quick.c index 0d4b714a..204c3c0f 100644 --- a/app/tools/wg-quick.c +++ b/app/tools/wg-quick.c @@ -173,7 +173,7 @@ _printf_(1, 2) static void cmd(const char *cmd_fmt, ...) if (ret < 0) ret = ESRCH; else if (ret > 0) - ret = WEXITSTATUS(ret); + ret = WIFEXITED(ret) ? WEXITSTATUS(ret) : EIO; if (ret && !is_exiting) exit(ret); @@ -428,6 +428,7 @@ static void set_config(const char *iface, const char *config) { FILE *config_writer; _cleanup_free_ char *cmd = concat("wg setconf ", iface, " /proc/self/fd/0", NULL); + int ret; printf("[#] %s\n", cmd); @@ -440,7 +441,9 @@ static void set_config(const char *iface, const char *config) perror("Error: fputs"); exit(errno); } - pclose(config_writer); + ret = pclose(config_writer); + if (ret) + exit(WIFEXITED(ret) ? WEXITSTATUS(ret) : EIO); } static void print_search_paths(FILE *file, const char *prefix) |