From 91bdc2a05d20c447afb986511b0c80ce832718cb Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 21 Apr 2017 15:28:57 +0900 Subject: [PATCH] [WGID-200330] Replaced popen() with execv() Change-Id: I98844b0e445413d907f2f49703540c595fb9db2d Signed-off-by: Seonah Moon --- src/vpnsvc-internal.c | 46 +++++-------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/src/vpnsvc-internal.c b/src/vpnsvc-internal.c index f0b4d88..ae8baee 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) -- 2.34.1