X-Git-Url: https://git.syn-net.org/?p=debian%2Fuanytun.git;a=blobdiff_plain;f=src%2Flinux%2Ftun.c;h=10037ea1bf7cdc44e03982dfbe80a3fe30d28b02;hp=c2187a60fd07fac5df8592e9887df6a8ee64a0d9;hb=e3f8e33112e2191999c6d6f6b6a767c72db800a0;hpb=b81b2c1954fe3e3317e6fa260c5ffdc9eeee966c diff --git a/src/linux/tun.c b/src/linux/tun.c index c2187a6..10037ea 100644 --- a/src/linux/tun.c +++ b/src/linux/tun.c @@ -20,8 +20,9 @@ * This file is part of uAnytun. * * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. * * uAnytun is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -54,6 +55,7 @@ #define DEFAULT_DEVICE "/dev/net/tun" #include "log.h" +#include "sysexec.h" int tun_init(tun_device_t* dev, const char* dev_name, const char* dev_type, const char* ifcfg_addr, u_int16_t ifcfg_prefix){ if(!dev) @@ -189,18 +191,16 @@ void tun_do_ifconfig(tun_device_t* dev) if(!dev || !dev->actual_name_ || !dev->net_addr_ || !dev->net_mask_) return; - char* command = NULL; - asprintf(&command, "/sbin/ifconfig %s %s netmask %s mtu %d", dev->actual_name_, dev->net_addr_, dev->net_mask_, dev->mtu_); - if(!command) { + char* mtu_str = NULL; + asprintf(&mtu_str, "%d", dev->mtu_); + if(!mtu_str) { log_printf(ERROR, "Execution of ifconfig failed"); return; } - int result = system(command); - if(result == -1) - log_printf(ERROR, "Execution of ifconfig failed"); - else - log_printf(NOTICE, "ifconfig returned %d", WEXITSTATUS(result)); + char* const argv[] = { "/sbin/ifconfig", dev->actual_name_, dev->net_addr_, "netmask", dev->net_mask_, "mtu", mtu_str, NULL }; + char* const evp[] = { NULL }; + uanytun_exec("/sbin/ifconfig", argv, evp); - free(command); + free(mtu_str); }