From 5e89ebc55003b4af395ec58dce301046f9a3e7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Mon, 24 Jun 2019 13:04:39 +0000 Subject: [PATCH] Improve error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- src/bind.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bind.c b/src/bind.c index e96fbba..a690b07 100644 --- a/src/bind.c +++ b/src/bind.c @@ -49,7 +49,7 @@ gt_setup_secretkey(struct mud *mud, const char *keyfile) } while (fd == -1 && errno == EINTR); if (fd == -1) { - perror("open keyfile"); + gt_log("couldn't open %s: %s\n", keyfile, strerror(errno)); return -1; } @@ -173,8 +173,10 @@ gt_bind(int argc, char **argv) size_t mtu = gt_setup_mtu(mud, 0, tun_name); - if (tun_set_persist(tun_fd, persist) == -1) - perror("tun_set_persist"); + if (tun_set_persist(tun_fd, persist) == -1) { + gt_log("unable to %sable persist mode on device %s\n", + persist ? "en" : "dis", tun_name); + } if (peer_addr.ss_family) { if (mud_peer(mud, (struct sockaddr *)&peer_addr)) { @@ -186,7 +188,8 @@ gt_bind(int argc, char **argv) const int ctl_fd = ctl_create(GT_RUNDIR, tun_name); if (ctl_fd == -1) { - perror("ctl_create"); + gt_log("couldn't create "GT_RUNDIR"/%s: %s\n", + tun_name, strerror(errno)); return 1; } @@ -335,10 +338,8 @@ gt_bind(int argc, char **argv) } } - if (gt_reload && tun_fd >= 0) { - if (tun_set_persist(tun_fd, 1) == -1) - perror("tun_set_persist"); - } + if (gt_reload && tun_fd >= 0) + tun_set_persist(tun_fd, 1); mud_delete(mud); ctl_delete(ctl_fd);