From: hyunuktak Date: Tue, 10 Oct 2017 05:04:47 +0000 (+0900) Subject: Removed is_rule_present which is not valid X-Git-Tag: accepted/tizen/unified/20171011.150213~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d21fab5a8447ff76098bdad41f3a133b6359994;p=platform%2Fcore%2Fconnectivity%2Fstc-manager.git Removed is_rule_present which is not valid Change-Id: I783916db78b09d9351f2d322be9eb0007d3dfb69 Signed-off-by: hyunuktak --- diff --git a/src/helper/helper-nfacct-rule.c b/src/helper/helper-nfacct-rule.c index a8474a1..aec0ef3 100755 --- a/src/helper/helper-nfacct-rule.c +++ b/src/helper/helper-nfacct-rule.c @@ -402,60 +402,6 @@ static void wait_for_rule_cmd(pid_t pid) } } -static char* get_cmd_pos(const char *cmd_buf) -{ - char *cmd_pos = strstr(cmd_buf, APPEND); - if (!cmd_pos) - cmd_pos = strstr(cmd_buf, INSERT); - - return cmd_pos; -} - -static bool is_rule_present(const char *cmd_buf) -{ - bool ret = false; - pid_t pid = fork(); - - if (pid == 0) { - gchar **args = NULL; - size_t buf_len; - char *exec_buf; - char *cmd_pos = get_cmd_pos(cmd_buf); - - if (!cmd_pos) - exit(1); - - buf_len = strlen(cmd_buf) + 1; - exec_buf = (char *)malloc(buf_len); - if (!exec_buf) - exit(1); - - strncpy(exec_buf, cmd_buf, buf_len); - strncpy(exec_buf + (cmd_pos - cmd_buf), IPTABLES_CHECK, - sizeof(IPTABLES_CHECK) - 1); - -#if STC_DEBUG_LOG - STC_LOGD("check rule %s", exec_buf); -#endif - - args = g_strsplit_set(exec_buf, " ", -1); - - ret = execv(args[0], args); - if (ret) { - char buf[BUF_SIZE_FOR_ERR] = { 0 }; - STC_LOGE("Can't execute %s: %s", - cmd_buf, strerror_r(errno, buf, - BUF_SIZE_FOR_ERR)); - } - - free(exec_buf); - g_strfreev(args); - exit(ret); - } - - return ret; -} - stc_error_e exec_iptables_cmd(const char *cmd_buf, pid_t *cmd_pid) { const size_t args_number = get_args_number(cmd_buf); @@ -476,11 +422,6 @@ stc_error_e exec_iptables_cmd(const char *cmd_buf, pid_t *cmd_pid) STC_LOGD("executing iptables cmd %s in forked process", cmd_buf); #endif - if (is_rule_present(cmd_buf)) { - STC_LOGD("Rule %s already present", cmd_buf); - exit(0); - } - args[0] = "iptables"; cmd = strtok_r((char *)cmd_buf, " ", &save_ptr); if (cmd == NULL) { @@ -527,11 +468,6 @@ stc_error_e exec_ip6tables_cmd(const char *cmd_buf, pid_t *cmd_pid) STC_LOGD("executing ip6tables cmd %s in forked process", cmd_buf); #endif - if (is_rule_present(cmd_buf)) { - STC_LOGD("Rule %s already present", cmd_buf); - exit(0); - } - args[0] = "ip6tables"; cmd = strtok_r((char *)cmd_buf, " ", &save_ptr); if (cmd == NULL) {