From: Seonah Moon Date: Fri, 21 Apr 2017 06:28:57 +0000 (+0900) Subject: [WGID-200330] Replaced popen() with execv() X-Git-Tag: submit/tizen_3.0/20170428.051156^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e31d09a015edc9a92aa5f403470a0c829f838061;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git [WGID-200330] Replaced popen() with execv() Change-Id: I98844b0e445413d907f2f49703540c595fb9db2d Signed-off-by: Seonah Moon --- diff --git a/src/vpnsvc-internal.c b/src/vpnsvc-internal.c index ed883f6..60a7138 100755 --- a/src/vpnsvc-internal.c +++ b/src/vpnsvc-internal.c @@ -478,28 +478,6 @@ static int del_dns_suffix() return VPNSVC_ERROR_NONE; } -static int _check_config_str(void) -{ - char *buf = NULL; - size_t len; - - len = confstr(_CS_PATH, NULL, 0); - if (len == 0) - return -1; - - if ((buf = malloc(len)) == NULL) - return -1; - - if (confstr(_CS_PATH, buf, len) == 0) { - free(buf); - return -1; - } - - free(buf); - - return 0; -} - #if 0 static void dns_nat_register(char **vpn_dns_address, size_t nr_dns, char *vpn_device_address) { @@ -829,30 +807,16 @@ int vpn_service_init(const char* iface_name, size_t iface_name_len, int fd, vpns int vpn_service_deinit(const char* dev_name) { - char buf[100], *cmd; - FILE *fp = NULL; - - if (_check_config_str() != 0) { - ERR("Failed to get configuration string"); - return VPNSVC_ERROR_IO_ERROR; - } + char buf[100]; snprintf(buf, sizeof(buf), "/usr/sbin/ip link del %s", dev_name); - cmd = g_try_malloc0(strlen(buf) + 1); - strncpy(cmd, buf, strlen(buf)); - - DBG("link delete cmd : %s", cmd); - - fp = popen(cmd, "r"); - g_free(cmd); - - if (fp != NULL) { - pclose(fp); - return VPNSVC_ERROR_NONE; - } else { + if (netconfig_execute_cmd(buf)) { + ERR("Failed to execute command: %s", buf); return VPNSVC_ERROR_IO_ERROR; } + + return VPNSVC_ERROR_NONE; } int vpn_service_protect(int socket_fd, const char* dev_name)