commit be7726bad1d6bf2f95215e4091246505734940e9
parent 060e651d5ab6194e8986c3b0bcc095d93deda628
Author: sin <sin@2f30.org>
Date: Thu, 14 Apr 2016 12:12:47 +0100
use basename() so one can specify /dev/tunX as well
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev_bsd.c b/dev_bsd.c
@@ -12,6 +12,7 @@
#include <netinet/in.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
@@ -25,7 +26,7 @@ devopen(char *ifname)
struct tuninfo ti;
int fd;
- snprintf(dev, sizeof(dev), "/dev/%s", ifname);
+ snprintf(dev, sizeof(dev), "/dev/%s", basename(ifname));
if ((fd = open(dev, O_RDWR)) < 0)
logerr("failed to open %s", dev);
if (ioctl(fd, TUNGIFINFO, &ti) < 0)