[WGID-200330] Replaced popen() with execv() 65/126365/1 accepted/tizen/3.0/common/20170508.153003 accepted/tizen/3.0/ivi/20170508.050424 accepted/tizen/3.0/mobile/20170508.050358 accepted/tizen/3.0/tv/20170508.050405 accepted/tizen/3.0/wearable/20170508.050420 submit/tizen_3.0-common/20170508.080135 submit/tizen_3.0-common/20170508.081301 submit/tizen_3.0-common/20170508.091535 submit/tizen_3.0/20170428.051156 submit/tizen_3.0/20170428.093500 submit/tizen_3.0_common/20170508.091735
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 21 Apr 2017 06:28:57 +0000 (15:28 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Fri, 21 Apr 2017 06:30:13 +0000 (15:30 +0900)
Change-Id: I98844b0e445413d907f2f49703540c595fb9db2d
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
src/vpnsvc-internal.c

index ed883f6..60a7138 100755 (executable)
@@ -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)