From c82a1239deb59784f75b305af7aff69af5d42408 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Mon, 18 May 2020 16:57:23 +0900 Subject: [PATCH 01/16] Modify database query appropriately Change-Id: I45bc4f031cd65252d85fd5de9bba6e3eee00b24c Signed-off-by: hyunuk.tak --- src/database/tables/table-statistics.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/database/tables/table-statistics.c b/src/database/tables/table-statistics.c index b631d47..2bfff70 100755 --- a/src/database/tables/table-statistics.c +++ b/src/database/tables/table-statistics.c @@ -85,19 +85,19 @@ #define SELECT_CHUNKS_APP "select iftype, hw_net_protocol_type, " \ "is_roaming, sum(received) as received, sum(sent) as sent, " \ - "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \ + "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as timestamp " \ "from statistics " \ - "group by iftype, ifname, time_stamp, hw_net_protocol_type, is_roaming " \ - "order by time_stamp, iftype, ifname, hw_net_protocol_type, is_roaming" + "group by iftype, ifname, timestamp, hw_net_protocol_type, is_roaming " \ + "order by timestamp, iftype, ifname, hw_net_protocol_type, is_roaming" #define SELECT_CHUNKS_APP_IFACE "select iftype, hw_net_protocol_type, " \ "is_roaming, sum(received) as received, sum(sent) as sent, " \ - "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \ + "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as timestamp " \ "from statistics where time_stamp between ? and ? and binpath = ? " \ "and iftype = ? " \ - "group by time_stamp, hw_net_protocol_type, is_roaming, " \ + "group by timestamp, hw_net_protocol_type, is_roaming, " \ "iftype, ifname, subscriber_id " \ - "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ + "order by timestamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ "is_roaming" #define SELECT_TOTAL "select iftype, hw_net_protocol_type, " \ @@ -121,22 +121,22 @@ #define SELECT_CHUNKS_TOTAL "select iftype, hw_net_protocol_type, " \ "is_roaming, sum(received) as received, sum(sent) as sent, " \ - "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \ + "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as timestamp " \ "from statistics where time_stamp between ? and ? " \ "and binpath NOT LIKE 'TOTAL_%' " \ - "group by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ + "group by timestamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ "is_roaming " \ - "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ + "order by timestamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \ "is_roaming" #define SELECT_CHUNKS_TOTAL_IFACE "select iftype, hw_net_protocol_type, " \ "is_roaming, sum(received) as received, sum(sent) as sent, " \ - "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \ + "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as timestamp " \ "from statistics where time_stamp between ? and ? " \ "and iftype = ? " \ "and binpath NOT LIKE 'TOTAL_%' " \ - "group by time_stamp, hw_net_protocol_type, is_roaming, iftype, ifname, subscriber_id " \ - "order by time_stamp, hw_net_protocol_type, is_roaming, iftype, " \ + "group by timestamp, hw_net_protocol_type, is_roaming, iftype, ifname, subscriber_id " \ + "order by timestamp, hw_net_protocol_type, is_roaming, iftype, " \ "ifname, subscriber_id" /* INSERT statement */ -- 2.7.4 From ab517e17e80fec38739dffe83e8f14af5487b586 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Tue, 19 May 2020 08:30:47 +0900 Subject: [PATCH 02/16] Fix to delete iptables rule while unsetting restrictions We should delete block rules Change-Id: I4c3db4db451f034a9257ebda234dbfa275c19813 Signed-off-by: Semun Lee --- plugin/monitor/stc-plugin-monitor-rstn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor-rstn.c b/plugin/monitor/stc-plugin-monitor-rstn.c index b985baf..5398c1d 100755 --- a/plugin/monitor/stc-plugin-monitor-rstn.c +++ b/plugin/monitor/stc-plugin-monitor-rstn.c @@ -622,10 +622,10 @@ static void __rstn_process(enum traffic_restriction_type rstn_type, int i; if (rstn_data->classid == STC_TETHERING_APP_CLASSID) - __rstn_del_ipt_rule(rstn_data->classid, NFACCT_BLOCK, + __rstn_del_ipt_rule(rstn_data->classid, NFACCT_TETH_BLOCK, rstn_data->iftype); else - __rstn_del_ipt_rule(rstn_data->classid, rstn_data->rstn_type, + __rstn_del_ipt_rule(rstn_data->classid, NFACCT_BLOCK, rstn_data->iftype); rstn_data->rstn_state = STC_RSTN_STATE_DEACTIVATED; -- 2.7.4 From fa0667b02fc4cbb72344d5ea3c6d591115d98218 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 21 Apr 2020 21:45:14 +0900 Subject: [PATCH 03/16] [fix] Rename dbus auto-activation service file Naming rule for dbus auto-activation service file : well-known name + ".service" https://bugs.freedesktop.org/show_bug.cgi?id=99874 Change-Id: I2ad7c6d4c9673a7bc50fed93e23a61429c1ff403 --- packaging/stc-manager.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 6a86074..79eb620 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -149,7 +149,7 @@ mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc-manager.service +cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service #OS Upgrade mkdir -p %{buildroot}%{upgrade_script_path} -- 2.7.4 From 73ab8e313957e16854708bc16a717d822f8f4a88 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 29 May 2020 19:06:24 +0900 Subject: [PATCH 04/16] Fix to init g_system as NULL in error case Change-Id: I2a70043afafb76f1594313899a16f01679e82586 Signed-off-by: Semun Lee --- plugin/monitor/stc-plugin-monitor.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index fc71c8c..1f08dc3 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -68,6 +68,17 @@ static gboolean __process_contr_reply(GIOChannel *source, GIOCondition condition, gpointer user_data); +static void __free_system(stc_system_s *system) +{ + /* destroy monitored application tree */ + if (system->apps) + g_hash_table_destroy(system->apps); + /* destroy restriction rules tree */ + if (system->rstns) + g_hash_table_destroy(system->rstns); + FREE(system); +} + static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) { GIOChannel *gio = NULL; @@ -88,7 +99,8 @@ static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) system->contr_sock = create_netlink(NETLINK_NETFILTER, 0); if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); - FREE(system); + __free_system(system); + g_system = NULL; return STC_ERROR_FAIL; } @@ -349,7 +361,7 @@ stc_error_e stc_plugin_monitor_initialize(void) system->contr_sock = create_netlink(NETLINK_NETFILTER, 0); if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); - FREE(system); + __free_system(system); return STC_ERROR_FAIL; } @@ -403,15 +415,8 @@ stc_error_e stc_plugin_monitor_deinitialize(void) g_system->contr_timer_id = 0; } - /* destroy monitored application tree */ - g_hash_table_destroy(g_system->apps); - g_system->apps = NULL; - - /* destroy restriction rules tree */ - g_hash_table_destroy(g_system->rstns); - g_system->rstns = NULL; - - FREE(g_system); + __free_system(g_system); + g_system = NULL; return STC_ERROR_NONE; } -- 2.7.4 From 713f5536e99bdc86ed59dec477a2b0b83cad723a Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 18:13:40 +0530 Subject: [PATCH 05/16] Add retry mechanism for netlink socket creation Change-Id: Ic0512f1bc680a68a9209c097b7ef4a2fb1a8548c Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- src/helper/helper-nl.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 79eb620..a418017 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.0.99 +Version: 0.1.0 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/helper/helper-nl.c b/src/helper/helper-nl.c index ff9d1af..6d54e8f 100755 --- a/src/helper/helper-nl.c +++ b/src/helper/helper-nl.c @@ -20,35 +20,54 @@ #include #include #include +#include -/** - * create_netlink(): Create netlink socket and returns it. - * Returns: Created socket on success and -1 on failure. - */ -API int create_netlink(int protocol, uint32_t groups) +#define NETLINK_SOCK_RETRY_COUNT 3 + +int __create_netlink(int protocol, uint32_t groups, int retry) { /** * TODO it's one socket, in future make set of sockets * unique for protocol and groups */ int sock; - sock = socket(PF_NETLINK, SOCK_RAW, protocol); - if (sock < 0) + + if (retry <= 0) return -EINVAL; //LCOV_EXCL_LINE + errno = 0; + sock = socket(PF_NETLINK, SOCK_RAW, protocol); + if (sock < 0) { + STC_LOGE("failed to open socket errno [%d], retry [%d]", + errno, NETLINK_SOCK_RETRY_COUNT - retry); //LCOV_EXCL_LINE + return __create_netlink(protocol, groups, --retry); //LCOV_EXCL_LINE + } + struct sockaddr_nl src_addr = { 0, }; src_addr.nl_family = AF_NETLINK; src_addr.nl_groups = groups; + errno = 0; if (bind(sock, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) { + STC_LOGE("failed to bind socket errno [%d], retry [%d]", + errno, NETLINK_SOCK_RETRY_COUNT - retry); //LCOV_EXCL_LINE close(sock); //LCOV_EXCL_LINE - return -1; //LCOV_EXCL_LINE + return __create_netlink(protocol, groups, --retry); //LCOV_EXCL_LINE } return sock; } +/** + * create_netlink(): Create netlink socket and returns it. + * Returns: Created socket on success and -1 on failure. + */ +API int create_netlink(int protocol, uint32_t groups) +{ + return __create_netlink(protocol, groups, NETLINK_SOCK_RETRY_COUNT); +} + void fill_attribute_list(struct rtattr **atb, const int max_len, struct rtattr *rt_na, int rt_len) { -- 2.7.4 From 15af46f1287673a3bdb9d34be47da459a4c75cc7 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 20:34:55 +0530 Subject: [PATCH 06/16] Add callback in monitor plugin to stop stc-manager Change-Id: I88c9d9275620ee1ee32ee62e853e88c46c535a3f Signed-off-by: Nishant Chaprana --- include/stc-manager-plugin-monitor.h | 2 +- packaging/stc-manager.spec | 2 +- plugin/monitor/include/stc-plugin-monitor.h | 6 ++++-- plugin/monitor/stc-plugin-monitor.c | 11 ++++++++++- src/stc-manager-plugin-monitor.c | 4 ++-- src/stc-manager.c | 18 +++++++++++++++++- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/stc-manager-plugin-monitor.h b/include/stc-manager-plugin-monitor.h index 3830608..76a65bd 100755 --- a/include/stc-manager-plugin-monitor.h +++ b/include/stc-manager-plugin-monitor.h @@ -21,7 +21,7 @@ #include "stc-plugin-monitor.h" -int stc_plugin_monitor_init(void); +int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb); int stc_plugin_monitor_deinit(void); int stc_plugin_monitor_add_app(uint32_t classid, diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index a418017..f8690c2 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.0 +Version: 0.1.1 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/plugin/monitor/include/stc-plugin-monitor.h b/plugin/monitor/include/stc-plugin-monitor.h index 35509c8..0cc8c42 100755 --- a/plugin/monitor/include/stc-plugin-monitor.h +++ b/plugin/monitor/include/stc-plugin-monitor.h @@ -38,8 +38,10 @@ #define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction" #endif +typedef void (*stc_manager_stop_cb)(void); + typedef struct { - int (*initialize_plugin) (void); + int (*initialize_plugin) (stc_manager_stop_cb stop_cb); int (*deinitialize_plugin) (void); int (*add_application) (uint32_t classid, @@ -68,7 +70,7 @@ typedef struct { int (*check_excn_by_cmdline) (char *cmdline); } stc_plugin_monitor_s; -stc_error_e stc_plugin_monitor_initialize(void); +stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb); stc_error_e stc_plugin_monitor_deinitialize(void); GHashTable *stc_monitor_get_system_apps(void); diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index 1f08dc3..ab06816 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -32,6 +32,7 @@ #include "stc-manager-plugin-exception.h" static stc_system_s *g_system = NULL; +static stc_manager_stop_cb g_stop_cb = NULL; static int __vconf_get_int(const char *key, int *value) { @@ -101,6 +102,7 @@ static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system) STC_LOGE("failed to open socket"); __free_system(system); g_system = NULL; + g_stop_cb(); return STC_ERROR_FAIL; } @@ -337,7 +339,7 @@ static void __fill_exceptions_list(void) stc_plugin_fill_exception_list(); } -stc_error_e stc_plugin_monitor_initialize(void) +stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; @@ -347,6 +349,11 @@ stc_error_e stc_plugin_monitor_initialize(void) ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY, "stc_system_s malloc fail!"); + ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, + "stop_cb callback is NULL"); + + g_stop_cb = stop_cb; + /* initializing current classid */ init_current_classid(); @@ -362,6 +369,7 @@ stc_error_e stc_plugin_monitor_initialize(void) if (system->contr_sock < 0) { STC_LOGE("failed to open socket"); __free_system(system); + g_stop_cb(); return STC_ERROR_FAIL; } @@ -417,6 +425,7 @@ stc_error_e stc_plugin_monitor_deinitialize(void) __free_system(g_system); g_system = NULL; + g_stop_cb = NULL; return STC_ERROR_NONE; } diff --git a/src/stc-manager-plugin-monitor.c b/src/stc-manager-plugin-monitor.c index 209b1a1..efdf759 100755 --- a/src/stc-manager-plugin-monitor.c +++ b/src/stc-manager-plugin-monitor.c @@ -24,7 +24,7 @@ static void *handle_plugin; static stc_plugin_monitor_s *stc_plugin; //LCOV_EXCL_START -API int stc_plugin_monitor_init(void) +API int stc_plugin_monitor_init(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; @@ -43,7 +43,7 @@ API int stc_plugin_monitor_init(void) return STC_ERROR_UNINITIALIZED; } - stc_plugin->initialize_plugin(); + stc_plugin->initialize_plugin(stop_cb); stc_plugin_enabled = TRUE; __STC_LOG_FUNC_EXIT__; diff --git a/src/stc-manager.c b/src/stc-manager.c index a376e7f..0011c97 100755 --- a/src/stc-manager.c +++ b/src/stc-manager.c @@ -38,6 +38,7 @@ #define BUF_SIZE_FOR_ERR 100 static stc_s *g_stc = NULL; +static gboolean g_is_fail_exit = FALSE; static gboolean __validate_ident(const char *ident) { @@ -100,6 +101,15 @@ static void __stc_manager_deinit(void) __STC_LOG_FUNC_EXIT__; } +void __stc_manager_stop_with_fail(void) +{ + STC_LOGI("plugin needs stc-manager to exit"); + + g_is_fail_exit = TRUE; + + stc_stop_manager(); +} + static stc_s *__stc_manager_init(void) { __STC_LOG_FUNC_ENTER__; @@ -134,7 +144,7 @@ static stc_s *__stc_manager_init(void) stc_plugin_tether_init(); if (stc_plugin_pcap_init() == STC_ERROR_NONE) g_stc->ondemand_mode = FALSE; - if (stc_plugin_monitor_init() == STC_ERROR_NONE) + if (stc_plugin_monitor_init(__stc_manager_stop_with_fail) == STC_ERROR_NONE) g_stc->ondemand_mode = FALSE; stc_plugin_firewall_init(); @@ -265,6 +275,9 @@ gint32 main(gint32 argc, gchar *argv[]) if (!g_stc) goto fail; + if (g_is_fail_exit == TRUE) + goto fail; + /* Crate the GLIB main loop */ main_loop = g_main_loop_new(NULL, FALSE); g_stc->main_loop = main_loop; @@ -283,5 +296,8 @@ fail: if (main_loop) g_main_loop_unref(main_loop); + if (g_is_fail_exit == TRUE) + exit(-1); + return 0; } -- 2.7.4 From a0acdcb8da80127d74553c56844117fde085b100 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 11 Jun 2020 22:09:52 +0530 Subject: [PATCH 07/16] Restart stc-manager at non-zero exit code after 5 seconds Change-Id: I56bf9171a996846606c40b019d4694af837269ac Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- resources/systemd/stc-manager.service | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index f8690c2..b6c1b12 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.1 +Version: 0.1.2 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/resources/systemd/stc-manager.service b/resources/systemd/stc-manager.service index e20402f..899db52 100644 --- a/resources/systemd/stc-manager.service +++ b/resources/systemd/stc-manager.service @@ -6,6 +6,8 @@ Type=dbus BusName=net.stc SmackProcessLabel=System ExecStart=/usr/bin/stc-manager +Restart=on-failure +RestartSec=5 [Install] WantedBy=multi-user.target -- 2.7.4 From acfe9db1a6d1e7d8d9f5a8f90c5f9db323bdd821 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Wed, 10 Jun 2020 15:50:51 +0900 Subject: [PATCH 08/16] Modify to add/remove rule list by connection Change-Id: I97dd168f82a457968672e2a7dafa9b83444aaa5d Signed-off-by: hyunuk.tak --- plugin/monitor/include/stc-plugin-monitor-ipt.h | 3 + plugin/monitor/stc-plugin-monitor-app.c | 150 +++++++++++++++++++++++- plugin/monitor/stc-plugin-monitor-connection.c | 9 +- plugin/monitor/stc-plugin-monitor-ipt.c | 16 +++ plugin/monitor/stc-plugin-monitor.c | 3 - src/helper/helper-iptables.c | 137 ++++++++++++++++++++++ src/helper/helper-iptables.h | 2 + src/helper/helper-nfacct-rule.c | 82 +++++++++++++ src/helper/helper-nfacct-rule.h | 2 + 9 files changed, 393 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/helper/helper-iptables.h diff --git a/plugin/monitor/include/stc-plugin-monitor-ipt.h b/plugin/monitor/include/stc-plugin-monitor-ipt.h index a104c10..ab7286d 100755 --- a/plugin/monitor/include/stc-plugin-monitor-ipt.h +++ b/plugin/monitor/include/stc-plugin-monitor-ipt.h @@ -29,6 +29,9 @@ stc_error_e stc_monitor_ip6t_add_out(struct nfacct_rule *counter); stc_error_e stc_monitor_ip6t_del_in(struct nfacct_rule *counter); stc_error_e stc_monitor_ip6t_del_out(struct nfacct_rule *counter); +stc_error_e stc_monitor_ipt_add_list(GSList *counter_list, nfacct_rule_iptype iptype); +stc_error_e stc_monitor_ipt_del_list(GSList *counter_list, nfacct_rule_iptype iptype); + stc_error_e stc_monitor_tether_add_in(struct nfacct_rule *counter, const gchar *ipaddr); stc_error_e stc_monitor_tether_add_out(struct nfacct_rule *counter, diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c index a5804da..6bc410a 100755 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stc-plugin-monitor-app.c @@ -558,15 +558,135 @@ void stc_monitor_app_add_monitor(gpointer key, } } +typedef struct { + GSList *counter_v4_list; + GSList *counter_v6_list; + stc_connection_s *connection; + nfacct_rule_action action; + nfacct_rule_intend intend; +} counter_list_data; + +static void __make_counter(stc_app_value_s *app_value, + nfacct_rule_direction iotype, nfacct_rule_iptype iptype, + counter_list_data *list_data) +{ + stc_s *stc = stc_get_manager(); + struct nfacct_rule *counter; + + if (!stc || !list_data->connection || !list_data->connection->ifname) + return; + + if (!stc->carg) { + stc->carg = MALLOC0(counter_arg_s, 1); + if (stc->carg == NULL) + return; + + stc->carg->sock = stc_monitor_get_contr_sock(); + } + + counter = MALLOC0(struct nfacct_rule, 1); + if (counter == NULL) + return; + + counter->carg = stc->carg; + counter->classid = app_value->classid; + counter->app_state = app_value->state; + counter->intend = list_data->intend; + counter->action = list_data->action; + counter->iotype = iotype; + counter->iftype = list_data->connection->type; + g_strlcpy(counter->ifname, list_data->connection->ifname, MAX_IFACE_LENGTH); + switch (counter->intend) { + case NFACCT_BLOCK: + case NFACCT_TETH_BLOCK: + counter->jump = NFACCT_JUMP_REJECT; + break; + case NFACCT_WARN: + case NFACCT_ALLOW: + case NFACCT_TETH_ALLOW: + counter->jump = NFACCT_JUMP_ACCEPT; + break; + default: + counter->jump = NFACCT_JUMP_UNKNOWN; + } + counter->send_limit = 0; + counter->rcv_limit = 0; + + if (iptype == NFACCT_TYPE_IPV4) + list_data->counter_v4_list = g_slist_append(list_data->counter_v4_list, counter); + else if (iptype == NFACCT_TYPE_IPV6) + list_data->counter_v6_list = g_slist_append(list_data->counter_v6_list, counter); +} + +static void __make_counter_list(stc_app_value_s *app_value, counter_list_data *list_data) +{ + switch (app_value->classid) { + case STC_TOTAL_IPV4_CLASSID: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV4, list_data); + break; + case STC_TOTAL_IPV6_CLASSID: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV6, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV6, list_data); + break; + default: + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV4, list_data); + __make_counter(app_value, NFACCT_COUNTER_IN, NFACCT_TYPE_IPV6, list_data); + __make_counter(app_value, NFACCT_COUNTER_OUT, NFACCT_TYPE_IPV6, list_data); + } +} + +static void __foreach_app_table(gpointer key, gpointer value, gpointer data) +{ + stc_app_value_s *app_value = (stc_app_value_s *)value; + counter_list_data *list_data = (counter_list_data *)data; + + if (app_value->classid == STC_TOTAL_DATACALL_CLASSID || + app_value->classid == STC_TOTAL_WIFI_CLASSID || + app_value->classid == STC_TOTAL_BLUETOOTH_CLASSID) + return; + + list_data->intend = NFACCT_COUNTER; + __make_counter_list(app_value, list_data); + + if (app_value->state == STC_APP_STATE_FOREGROUND) { + list_data->intend = NFACCT_ALLOW; + __make_counter_list(app_value, list_data); + } +} + void stc_monitor_app_add_by_connection(stc_connection_s *conn) { GHashTable *apps = stc_monitor_get_system_apps(); + counter_list_data list_data = { 0, }; + struct timespec start, end; + time_t sec; + long int nsec; if (!apps) return; - g_hash_table_foreach(apps, stc_monitor_app_add_monitor, conn); - g_hash_table_foreach(apps, stc_monitor_app_add_accept, conn); + list_data.connection = conn; + list_data.action = NFACCT_ACTION_INSERT; + + g_hash_table_foreach(apps, __foreach_app_table, &list_data); + + clock_gettime(CLOCK_MONOTONIC, &start); + + stc_monitor_ipt_add_list(list_data.counter_v4_list, NFACCT_TYPE_IPV4); + stc_monitor_ipt_add_list(list_data.counter_v6_list, NFACCT_TYPE_IPV6); + + g_slist_free_full(list_data.counter_v4_list, g_free); + g_slist_free_full(list_data.counter_v6_list, g_free); + + clock_gettime(CLOCK_MONOTONIC, &end); + + sec = end.tv_sec - start.tv_sec; + nsec = end.tv_nsec - start.tv_nsec; + if (nsec < 0) + nsec += 1000000000; + STC_LOGD("Added by [%s] connection [%3ld.%09ld]s", conn->ifname, sec, nsec); } void stc_monitor_app_add_accept(gpointer key, @@ -679,12 +799,34 @@ void stc_monitor_app_remove_monitor(gpointer key, void stc_monitor_app_remove_by_connection(stc_connection_s *conn) { GHashTable *apps = stc_monitor_get_system_apps(); + counter_list_data list_data = { 0, }; + struct timespec start, end; + time_t sec; + long int nsec; if (!apps) return; - g_hash_table_foreach(apps, stc_monitor_app_remove_monitor, conn); - g_hash_table_foreach(apps, stc_monitor_app_remove_accept, conn); + list_data.connection = conn; + list_data.action = NFACCT_ACTION_DELETE; + + g_hash_table_foreach(apps, __foreach_app_table, &list_data); + + clock_gettime(CLOCK_MONOTONIC, &start); + + stc_monitor_ipt_del_list(list_data.counter_v4_list, NFACCT_TYPE_IPV4); + stc_monitor_ipt_del_list(list_data.counter_v6_list, NFACCT_TYPE_IPV6); + + g_slist_free_full(list_data.counter_v4_list, g_free); + g_slist_free_full(list_data.counter_v6_list, g_free); + + clock_gettime(CLOCK_MONOTONIC, &end); + + sec = end.tv_sec - start.tv_sec; + nsec = end.tv_nsec - start.tv_nsec; + if (nsec < 0) + nsec += 1000000000; + STC_LOGD("Removed by [%s] connection [%3ld.%09ld]s", conn->ifname, sec, nsec); } void stc_monitor_app_remove_accept(gpointer key, diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index a305002..2ed2161 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -212,7 +212,7 @@ static void __telephony_update_default_modem_subscriber_id(GDBusConnection *conn return; } -static void __print_connection_info(stc_connection_s *conn) +static void __print_connection_info(stc_connection_s *conn, const char *state) { STC_LOGI("============= connection info ============"); STC_LOGI("path [%s]", conn->path); @@ -221,6 +221,7 @@ static void __print_connection_info(stc_connection_s *conn) STC_LOGI("roaming [%u]", conn->roaming ? TRUE : FALSE); if (conn->type == STC_IFACE_DATACALL) STC_LOGI("sub_id [%s]", conn->subscriber_id); + STC_LOGI("state [%s]", state); STC_LOGI("=================================================="); } @@ -437,7 +438,7 @@ static stc_error_e __get_connected_profiles(GDBusConnection *connection) } __get_connection_info(connection, conn, conn->path); - __print_connection_info(conn); + __print_connection_info(conn, "connected"); if (default_conn == TRUE) { g_default_connection = conn; @@ -525,7 +526,7 @@ static void __append_connected_profile(GDBusConnection *connection, } __get_connection_info(connection, conn, conn->path); - __print_connection_info(conn); + __print_connection_info(conn, "connected"); g_connection_list = g_slist_append(g_connection_list, conn); @@ -538,7 +539,7 @@ static void __append_connected_profile(GDBusConnection *connection, static void __remove_disconnected_profile(GDBusConnection *connection, stc_connection_s *conn) { - __print_connection_info(conn); + __print_connection_info(conn, "disconnected"); stc_monitor_remove_by_connection(conn); diff --git a/plugin/monitor/stc-plugin-monitor-ipt.c b/plugin/monitor/stc-plugin-monitor-ipt.c index c8fa882..f9df3fb 100755 --- a/plugin/monitor/stc-plugin-monitor-ipt.c +++ b/plugin/monitor/stc-plugin-monitor-ipt.c @@ -153,6 +153,22 @@ stc_error_e stc_monitor_ip6t_del_out(struct nfacct_rule *counter) return produce_net_rule(counter); } +stc_error_e stc_monitor_ipt_add_list(GSList *counter_list, nfacct_rule_iptype iptype) +{ + if (counter_list == NULL) + return STC_ERROR_INVALID_PARAMETER; + + return produce_net_list(counter_list, iptype, NFACCT_ACTION_INSERT); +} + +stc_error_e stc_monitor_ipt_del_list(GSList *counter_list, nfacct_rule_iptype iptype) +{ + if (counter_list == NULL) + return STC_ERROR_INVALID_PARAMETER; + + return produce_net_list(counter_list, iptype, NFACCT_ACTION_DELETE); +} + stc_error_e stc_monitor_tether_add_in(struct nfacct_rule *counter, const gchar *ipaddr) { diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index 1f08dc3..8bf1c30 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -546,9 +546,6 @@ void stc_monitor_update_by_connection(void *data) stc_connection_s *connection = (stc_connection_s *)data; if (connection != NULL && connection->path != NULL) { - stc_monitor_app_remove_by_connection(connection); - stc_monitor_rstn_remove_by_connection(connection); - iptables_flush_chains(); stc_monitor_app_add_by_connection(connection); diff --git a/src/helper/helper-iptables.c b/src/helper/helper-iptables.c index 519d898..ffffd21 100755 --- a/src/helper/helper-iptables.c +++ b/src/helper/helper-iptables.c @@ -32,6 +32,10 @@ #define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_RULE "IptRemoveRule" #define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_RULE "Ip6tAddRule" #define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_RULE "Ip6tRemoveRule" +#define STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST "IptAddList" +#define STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST "IptRemoveList" +#define STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST "Ip6tAddList" +#define STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST "Ip6tRemoveList" #define RULE_CHAIN "chain" #define RULE_DIRECTION "direction" @@ -141,6 +145,43 @@ static void __remove_rule_reply( g_free(nfacct_name); } +static void __add_list_info_to_builder(GVariantBuilder *builder, + GSList *iptables_list) +{ + GSList *list; + GVariantBuilder sub_builder; + + for (list = iptables_list; list; list = list->next) { + iptables_rule_s *rule = list->data; + + g_variant_builder_init(&sub_builder, G_VARIANT_TYPE("a{sv}")); + + g_variant_builder_add(&sub_builder, "{sv}", RULE_CHAIN, + g_variant_new_string(rule->chain)); + + g_variant_builder_add(&sub_builder, "{sv}", RULE_DIRECTION, + g_variant_new_uint16(rule->direction)); + + if (rule->ifname) + g_variant_builder_add(&sub_builder, "{sv}", RULE_IFNAME, + g_variant_new_string(rule->ifname)); + + if (rule->classid > 0) + g_variant_builder_add(&sub_builder, "{sv}", RULE_CGROUP, + g_variant_new_uint32(rule->classid)); + + if (rule->nfacct_name) + g_variant_builder_add(&sub_builder, "{sv}", RULE_NFACCT, + g_variant_new_string(rule->nfacct_name)); + + if (rule->target) + g_variant_builder_add(&sub_builder, "{sv}", RULE_TARGET, + g_variant_new_string(rule->target)); + + g_variant_builder_add_value(builder, g_variant_builder_end(&sub_builder)); + } +} + static int __iptables_rule_add(GDBusConnection *connection, iptables_rule_s *rule) { @@ -269,6 +310,82 @@ static int __ip6tables_rule_remove(GDBusConnection *connection, return result; } +static int __iptables_list_add(GDBusConnection *connection, + GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_error_e result = STC_ERROR_NONE; + GVariantBuilder *builder = NULL; + GVariant *params = NULL; + GVariant *message = NULL; + const char *method = (iptype == IP_TYPE_IPV4) ? + STC_IPTABLES_DBUS_METHOD_IPT_ADD_LIST : + STC_IPTABLES_DBUS_METHOD_IP6T_ADD_LIST; + + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); + __add_list_info_to_builder(builder, iptables_list); + params = g_variant_new("(aa{sv})", builder); + g_variant_builder_unref(builder); + + message = stc_manager_gdbus_call_sync(connection, + STC_IPTABLES_DBUS_SERVICE, + STC_IPTABLES_DBUS_RULE_PATH, + STC_IPTABLES_DBUS_RULE_INTERFACE, + method, + params); + + if (message == NULL) { + STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE + return STC_ERROR_FAIL; //LCOV_EXCL_LINE + } + + g_variant_get(message, "(i)", &result); + + STC_LOGD("%s to add list [%s:%d]", + result == STC_ERROR_NONE ? "Successed" : "Failed", + iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result); + + g_variant_unref(message); + return result; +} + +static int __iptables_list_remove(GDBusConnection *connection, + GSList *iptables_list, iptables_ip_type_e iptype) +{ + int result = 0; + GVariantBuilder *builder = NULL; + GVariant *params = NULL; + GVariant *message = NULL; + const char *method = (iptype == IP_TYPE_IPV4) ? + STC_IPTABLES_DBUS_METHOD_IPT_REMOVE_LIST : + STC_IPTABLES_DBUS_METHOD_IP6T_REMOVE_LIST; + + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); + __add_list_info_to_builder(builder, iptables_list); + params = g_variant_new("(aa{sv})", builder); + g_variant_builder_unref(builder); + + message = stc_manager_gdbus_call_sync(connection, + STC_IPTABLES_DBUS_SERVICE, + STC_IPTABLES_DBUS_RULE_PATH, + STC_IPTABLES_DBUS_RULE_INTERFACE, + method, + params); + + if (message == NULL) { + STC_LOGE("Failed to invoke dbus method"); //LCOV_EXCL_LINE + return STC_ERROR_FAIL; //LCOV_EXCL_LINE + } + + g_variant_get(message, "(i)", &result); + + STC_LOGD("%s to add list [%s:%d]", + result == STC_ERROR_NONE ? "Successed" : "Failed", + iptype == IP_TYPE_IPV4 ? "IPv4" : "IPv6", result); + + g_variant_unref(message); + return STC_ERROR_NONE; +} + static int __iptables_add_chain(GDBusConnection *connection, const char *chain) { @@ -931,6 +1048,26 @@ done: return ret; } +stc_error_e iptables_add_list(GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_s *stc = stc_get_manager(); + + if (!stc || !stc->connection) + return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + + return __iptables_list_add(stc->connection, iptables_list, iptype); +} + +stc_error_e iptables_remove_list(GSList *iptables_list, iptables_ip_type_e iptype) +{ + stc_s *stc = stc_get_manager(); + + if (!stc || !stc->connection) + return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + + return __iptables_list_remove(stc->connection, iptables_list, iptype); +} + API stc_error_e iptables_flush_chains(void) { stc_error_e ret = STC_ERROR_NONE; diff --git a/src/helper/helper-iptables.h b/src/helper/helper-iptables.h old mode 100644 new mode 100755 index 6fa7908..f9f069a --- a/src/helper/helper-iptables.h +++ b/src/helper/helper-iptables.h @@ -76,6 +76,8 @@ typedef struct { stc_error_e iptables_add(iptables_rule_s *rule, iptables_ip_type_e iptype); stc_error_e iptables_remove(iptables_rule_s *rule, iptables_ip_type_e iptype); +stc_error_e iptables_add_list(GSList *iptables_list, iptables_ip_type_e iptype); +stc_error_e iptables_remove_list(GSList *iptables_list, iptables_ip_type_e iptype); stc_error_e iptables_flush_chains(void); stc_error_e iptables_init(void); stc_error_e iptables_deinit(void); diff --git a/src/helper/helper-nfacct-rule.c b/src/helper/helper-nfacct-rule.c index 070052b..ff703d3 100755 --- a/src/helper/helper-nfacct-rule.c +++ b/src/helper/helper-nfacct-rule.c @@ -850,6 +850,88 @@ API stc_error_e produce_net_rule(nfacct_rule_s *rule) return ret; } +static stc_error_e append_iptables_cmd(GSList **iptables_list, nfacct_rule_s *rule) +{ + iptables_rule_s *iptables_rule = NULL; + + iptables_rule = MALLOC0(iptables_rule_s, 1); + if (!iptables_rule) + return STC_ERROR_OUT_OF_MEMORY; + + iptables_rule->nfacct_name = g_strdup(rule->name); + iptables_rule->ifname = g_strdup(rule->ifname); + iptables_rule->target = g_strdup(get_iptables_jump(rule->jump)); + iptables_rule->chain = g_strdup(get_iptables_chain(rule->classid, + rule->iotype, rule->app_state, rule->intend)); + if (rule->classid < STC_RESERVED_CLASSID_MAX) + iptables_rule->classid = STC_UNKNOWN_CLASSID; + else + iptables_rule->classid = rule->classid; + iptables_rule->direction = (rule->iotype & NFACCT_COUNTER_IN) ? + IPTABLES_DIRECTION_IN : IPTABLES_DIRECTION_OUT; + + *iptables_list = g_slist_append(*iptables_list, iptables_rule); + + return STC_ERROR_NONE; +} + +static void iptables_list_free(gpointer value) +{ + iptables_rule_s *iptables_rule = (iptables_rule_s *)value; + + g_free(iptables_rule->chain); + g_free(iptables_rule->nfacct_name); + g_free(iptables_rule->ifname); + g_free(iptables_rule->target); + g_free(iptables_rule); +} + +API stc_error_e produce_net_list(GSList *rule_list, + nfacct_rule_iptype iptype, nfacct_rule_action action) +{ + GSList *list = NULL; + GSList *iptables_list = NULL; + stc_error_e ret = STC_ERROR_NONE; + + for (list = rule_list; list; list = list->next) { + nfacct_rule_s *rule = list->data; + + if (rule->action == NFACCT_ACTION_APPEND && + rule->intend == NFACCT_WARN && + !rule->send_limit && !rule->rcv_limit) + continue; + + generate_counter_name(rule); + if (rule->action != NFACCT_ACTION_DELETE) { + ret = nfacct_send_del(rule); + if (ret != STC_ERROR_NONE) + continue; + + ret = nfacct_send_new(rule); + if (ret != STC_ERROR_NONE) + continue; + } + + append_iptables_cmd(&iptables_list, rule); + } + + if (action == NFACCT_ACTION_INSERT || + action == NFACCT_ACTION_APPEND) + ret = iptables_add_list(iptables_list, iptype); + else if (action == NFACCT_ACTION_DELETE) + ret = iptables_remove_list(iptables_list, iptype); + + for (list = rule_list; list; list = list->next) { + nfacct_rule_s *rule = list->data; + + if (rule->action == NFACCT_ACTION_DELETE) + nfacct_send_del(rule); + } + + g_slist_free_full(iptables_list, iptables_list_free); + return ret; +} + void generate_counter_name(nfacct_rule_s *counter) { char warn_symbol = 'c'; diff --git a/src/helper/helper-nfacct-rule.h b/src/helper/helper-nfacct-rule.h index 80b9f83..f313849 100755 --- a/src/helper/helper-nfacct-rule.h +++ b/src/helper/helper-nfacct-rule.h @@ -134,6 +134,8 @@ bool recreate_counter_by_name(char *cnt_name, nfacct_rule_s *counter); stc_error_e nfacct_send_get_all(struct counter_arg *carg); stc_error_e produce_net_rule(nfacct_rule_s *rule); +stc_error_e produce_net_list(GSList *rule_list, + nfacct_rule_iptype iptype, nfacct_rule_action action); netlink_serialization_command * netlink_create_command(struct netlink_serialization_params *params); -- 2.7.4 From ee2840c9abe00ab42f19e32024c19c7809d4e30c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 22 Jun 2020 15:34:16 +0900 Subject: [PATCH 09/16] Fix memory leak in stc_plugin_monitor_initialize Variable system going out of scope leaks the memory it points to. Change-Id: I9d2c5dc3cc3b951954e793cf3864f270810d846c Signed-off-by: Jaehyun Kim --- plugin/monitor/stc-plugin-monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c index a26749f..7922b88 100755 --- a/plugin/monitor/stc-plugin-monitor.c +++ b/plugin/monitor/stc-plugin-monitor.c @@ -343,15 +343,15 @@ stc_error_e stc_plugin_monitor_initialize(stc_manager_stop_cb stop_cb) { __STC_LOG_FUNC_ENTER__; + ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, + "stop_cb callback is NULL"); + stc_system_s *system = MALLOC0(stc_system_s, 1); GIOChannel *gio = NULL; ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY, "stc_system_s malloc fail!"); - ret_value_msg_if(stop_cb == NULL, STC_ERROR_INVALID_PARAMETER, - "stop_cb callback is NULL"); - g_stop_cb = stop_cb; /* initializing current classid */ -- 2.7.4 From fd15fe5dda52af31a84ccb4c67da58714c7d9eaa Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Wed, 24 Jun 2020 15:42:03 +0900 Subject: [PATCH 10/16] Change the service file path for 64bit build Change-Id: Ib65165167a09f007f61192dd81bdd5df3084b8ac Signed-off-by: Jaehyun Kim --- packaging/stc-manager.spec | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index b6c1b12..2f2b56c 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -138,11 +138,11 @@ mkdir -p %{buildroot}/%{_localstatedir}/lib/stc cp data/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions #Systemd service file -mkdir -p %{buildroot}%{_libdir}/systemd/system/ -cp resources/systemd/stc-manager.service %{buildroot}%{_libdir}/systemd/system/stc-manager.service +mkdir -p %{buildroot}%{_unitdir} +cp resources/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service -mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/ -ln -s ../stc-manager.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/stc-manager.service +mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ +ln -s ../stc-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/stc-manager.service #DBus DAC (stc-manager.manifest enables DBus SMACK) mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d @@ -161,8 +161,8 @@ cp -f scripts/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} %defattr(-,root,root,-) %attr(500,root,root) %{_bindir}/* -%attr(644,root,root) %{_libdir}/systemd/system/stc-manager.service -%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/stc-manager.service +%attr(644,root,root) %{_unitdir}/stc-manager.service +%attr(644,root,root) %{_unitdir}/multi-user.target.wants/stc-manager.service %attr(755,network_fw,network_fw) /%{_localstatedir}/lib/stc %attr(600,root,root) /%{_localstatedir}/lib/stc/exceptions -- 2.7.4 From 5fe6aec4480cf8ae8062df2faa5f8add6cb24b62 Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 25 Jun 2020 18:38:43 +0900 Subject: [PATCH 11/16] Free all the unpacked values if breaking out of g_variant_iter_loop Change-Id: Ib5e67dfa852f38431f19ed66a540275165073724 --- plugin/monitor/stc-plugin-monitor-connection.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index 2ed2161..1f03737 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -490,6 +490,8 @@ static stc_error_e __get_default_connection(GDBusConnection *connection) if (comp && comp->data) g_default_connection = comp->data; + g_free(object_path); + g_variant_iter_free(next); break; } } -- 2.7.4 From 040cfa48a4c49ef8566246cc66898efa5c938d4d Mon Sep 17 00:00:00 2001 From: Cheoleun Moon Date: Thu, 25 Jun 2020 18:42:14 +0900 Subject: [PATCH 12/16] Free before return Change-Id: I951213a634605c561d9061c45134c6d7ef924d67 --- src/stc-manager-util.c | 1 + src/stc-pcap.c | 6 ++++++ src/stc-restriction.c | 20 ++++++++++++++++++++ src/stc-statistics.c | 2 ++ 4 files changed, 29 insertions(+) diff --git a/src/stc-manager-util.c b/src/stc-manager-util.c index 1f25927..3e77610 100755 --- a/src/stc-manager-util.c +++ b/src/stc-manager-util.c @@ -182,4 +182,5 @@ void stc_util_initialize_config(void) } __save_key_file(keyfile, path); + g_key_file_free(keyfile); } diff --git a/src/stc-pcap.c b/src/stc-pcap.c index 3faa7ec..29f5037 100755 --- a/src/stc-pcap.c +++ b/src/stc-pcap.c @@ -106,6 +106,7 @@ gboolean handle_pcap_start(StcPcap *object, if (__validate_pcap(&pcap) == FALSE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -113,11 +114,13 @@ gboolean handle_pcap_start(StcPcap *object, ret = stc_plugin_pcap_register_loop(pcap.ifname, pcap.nflog_group); if (ret != STC_ERROR_NONE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } STC_DBUS_REPLY_ERROR_NONE(invocation); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -147,6 +150,7 @@ gboolean handle_pcap_stop(StcPcap *object, if (__validate_pcap(&pcap) == FALSE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -154,11 +158,13 @@ gboolean handle_pcap_stop(StcPcap *object, ret = stc_plugin_pcap_unregister_loop(pcap.ifname, pcap.nflog_group); if (ret != STC_ERROR_NONE) { STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } STC_DBUS_REPLY_ERROR_NONE(invocation); + g_free(pcap.ifname); __STC_LOG_FUNC_EXIT__; return TRUE; } diff --git a/src/stc-restriction.c b/src/stc-restriction.c index d47aaf0..47bfee8 100755 --- a/src/stc-restriction.c +++ b/src/stc-restriction.c @@ -259,6 +259,14 @@ static void __stc_extract_restriction_rule(const char *key, GVariant *value, } } +static void __stc_free_restriction_rule_members(table_restrictions_info *rule) +{ + FREE(rule->app_id); + FREE(rule->ifname); + FREE(rule->subscriber_id); + FREE(rule->mac); +} + gboolean handle_restriction_set(StcRestriction *object, GDBusMethodInvocation *invocation, GVariant *parameters, @@ -285,6 +293,7 @@ gboolean handle_restriction_set(StcRestriction *object, if (__validate_rstn_rule(&rule) == FALSE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -293,12 +302,14 @@ gboolean handle_restriction_set(StcRestriction *object, if (ret != STC_ERROR_NONE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_DB_FAILED); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } stc_plugin_monitor_add_rstn(&rule); STC_DBUS_REPLY_ERROR_NONE(invocation); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -329,6 +340,7 @@ gboolean handle_restriction_unset(StcRestriction *object, if (__validate_rstn_rule(&rule) == FALSE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_INVALID_PARAMETER); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -338,12 +350,14 @@ gboolean handle_restriction_unset(StcRestriction *object, if (ret != STC_ERROR_NONE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE STC_ERROR_DB_FAILED); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } stc_plugin_monitor_remove_rstn(&rule); STC_DBUS_REPLY_ERROR_NONE(invocation); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; return TRUE; } @@ -376,6 +390,7 @@ gboolean handle_restriction_set_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -385,11 +400,13 @@ gboolean handle_restriction_set_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } } + __stc_free_restriction_rule_members(&rule); g_variant_iter_free(iter_row); } g_variant_iter_free(iter); @@ -428,6 +445,7 @@ gboolean handle_restriction_unset_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } @@ -437,11 +455,13 @@ gboolean handle_restriction_unset_list(StcRestriction *object, STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE g_variant_iter_free(iter_row); g_variant_iter_free(iter); + __stc_free_restriction_rule_members(&rule); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; } } + __stc_free_restriction_rule_members(&rule); g_variant_iter_free(iter_row); } g_variant_iter_free(iter); diff --git a/src/stc-statistics.c b/src/stc-statistics.c index 0e26464..ee61443 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -345,6 +345,7 @@ gboolean handle_statistics_get(StcStatistics *object, if (ret < STC_ERROR_NONE) { g_variant_builder_unref(builder); //LCOV_EXCL_LINE STC_STATISTICS_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE + g_free(rule.app_id); __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return TRUE; //LCOV_EXCL_LINE } @@ -355,6 +356,7 @@ gboolean handle_statistics_get(StcStatistics *object, DEBUG_GDBUS_VARIANT("Return parameters: ", return_parameters); STC_DBUS_REPLY(invocation, return_parameters); + g_free(rule.app_id); __STC_LOG_FUNC_EXIT__; return TRUE; } -- 2.7.4 From 7ed139f064240de4485f1342f037e9a05e2ada0d Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Thu, 2 Jul 2020 12:14:59 +0530 Subject: [PATCH 13/16] Fix build when using gcov and gtests build flags [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp: In member function 'error_e Firewall::GetLock(int*)': [ 75s] /usr/include/dlog/dlog-internal.h:72:31: error: format '%d' expects argument of type 'int', but argument 8 has type 'int*' [-Werror=format=] [ 75s] 72 | __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##__VA_ARGS__); \ [ 75s] /usr/include/dlog/dlog-internal.h:166:27: note: in expansion of macro 'LOG_' [ 75s] 166 | #define LOGD(format, ...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##__VA_ARGS__) [ 75s] | ^~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/stcmgr.h:30:32: note: in expansion of macro 'LOGD' [ 75s] 30 | #define GLOGD(format, args...) LOGD(format, ##args) [ 75s] | ^~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp:484:2: note: in expansion of macro 'GLOGD' [ 75s] 484 | GLOGD("Succeeded to get lock state[%d]", state); [ 75s] | ^~~~~ [ 75s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/firewall.cpp:484:38: note: format string is defined here [ 75s] 484 | GLOGD("Succeeded to get lock state[%d]", state); [ 75s] | ~^ [ 75s] | | [ 75s] | int [ 75s] | %n [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/statistics.cpp: In member function 'error_e Statistics::ResetStatistics()': [ 78s] /usr/include/dlog/dlog-internal.h:72:31: error: too many arguments for format [-Werror=format-extra-args] [ 78s] 72 | __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##__VA_ARGS__); \ [ 78s] /usr/include/dlog/dlog-internal.h:166:27: note: in expansion of macro 'LOG_' [ 78s] 166 | #define LOGD(format, ...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##__VA_ARGS__) [ 78s] | ^~~~ [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/stcmgr.h:30:32: note: in expansion of macro 'LOGD' [ 78s] 30 | #define GLOGD(format, args...) LOGD(format, ##args) [ 78s] | ^~~~ [ 78s] /home/abuild/rpmbuild/BUILD/stc-manager-0.1.2/unittest/statistics.cpp:292:2: note: in expansion of macro 'GLOGD' [ 78s] 292 | GLOGD("Succeeded to reset statistics", result); [ 78s] | ^~~~~ Change-Id: I5a23d18e3e8b3d510cacac834506ec22fa2bd193 Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- unittest/firewall.cpp | 4 ++-- unittest/statistics.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 2f2b56c..cff6b78 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.2 +Version: 0.1.3 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/unittest/firewall.cpp b/unittest/firewall.cpp index 44bcfe5..0cf9521 100644 --- a/unittest/firewall.cpp +++ b/unittest/firewall.cpp @@ -480,8 +480,8 @@ error_e Firewall::GetLock(int *state) return error; } - g_variant_get(message, "(i)", &state); - GLOGD("Succeeded to get lock state[%d]", state); + g_variant_get(message, "(i)", state); + GLOGD("Succeeded to get lock state[%d]", *state); g_variant_unref(message); return ERROR_NONE; diff --git a/unittest/statistics.cpp b/unittest/statistics.cpp index 7c816cc..6c80db1 100644 --- a/unittest/statistics.cpp +++ b/unittest/statistics.cpp @@ -289,7 +289,7 @@ error_e Statistics::ResetStatistics(void) } g_variant_get(message, "(i)", &result); - GLOGD("Succeeded to reset statistics", result); + GLOGD("Succeeded to reset statistics [%d]", result); g_variant_unref(message); return ERROR_NONE; -- 2.7.4 From cf268a5d8be0a4064fcd9cbeffa012080466279c Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Tue, 7 Jul 2020 09:50:29 +0900 Subject: [PATCH 14/16] Fix a coverity for 1142644 Change-Id: I2865c692003f0ae45a73918e84ad7810864903fc Signed-off-by: hyunuk.tak --- plugin/monitor/stc-plugin-monitor-app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c index 6bc410a..4b5703b 100755 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stc-plugin-monitor-app.c @@ -614,7 +614,7 @@ static void __make_counter(stc_app_value_s *app_value, if (iptype == NFACCT_TYPE_IPV4) list_data->counter_v4_list = g_slist_append(list_data->counter_v4_list, counter); - else if (iptype == NFACCT_TYPE_IPV6) + else list_data->counter_v6_list = g_slist_append(list_data->counter_v6_list, counter); } -- 2.7.4 From a93ae15925a8ee955c3f20c687a7f7e40cd4ed88 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Fri, 3 Jul 2020 11:21:46 +0530 Subject: [PATCH 15/16] Add test cases for removing rule post warn and restriction limit are crossed Change-Id: I47486ce363fb157b77824dd140052262c1b43495 Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- unittest/unittest.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index cff6b78..0690fde 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.1.3 +Version: 0.1.4 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index 8b467f7..41d57c4 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -328,6 +328,84 @@ TEST(StcManager_Statistics, Reset_p) EXPECT_EQ(ERROR_NONE, ret); } +TEST(StcManager_Restriction, RemoveRulePostWarnLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + -1, + 1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_EQ(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + +TEST(StcManager_Restriction, RemoveRulePostRestrictionLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + 2, + -1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_NE(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + +TEST(StcManager_Restriction, RemoveRulePostBothLimitCrossed_p) +{ + error_e ret = ERROR_NONE; + int sys_ret; + Restriction rest; + + ret = rest.SetRule("TOTAL_WIFI", + "wlan0", + NULL, + IFACE_WIFI, + 2, + 1, + ROAMING_UNKNOWN, + GTEST_MAC); + EXPECT_EQ(ERROR_NONE, ret); + + ret = rest.SetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); + + sys_ret = system("toybox ping -c 5 www.tizen.org"); + EXPECT_NE(0, sys_ret); + + ret = rest.UnsetRstriction(); + EXPECT_EQ(ERROR_NONE, ret); +} + TEST(StcManager_Firewall, Lock_p) { error_e ret = ERROR_NONE; -- 2.7.4 From 5b8edd8d8ca57403e6775811d195134d644f7634 Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Thu, 20 Aug 2020 17:35:39 +0900 Subject: [PATCH 16/16] [cleanup] change file location and mode Change-Id: I1f74ff9259a5c02a161bb75d4dd2ea15b0c6de6f --- CMakeLists.txt | 11 ++++--- LICENSE => LICENSE.APLv2 | 0 {interfaces => dbus-interface}/CMakeLists.txt | 0 .../stcmanager-iface-firewall.xml | 0 .../stcmanager-iface-manager.xml | 0 .../stcmanager-iface-pcap.xml | 0 .../stcmanager-iface-restriction.xml | 0 .../stcmanager-iface-statistics.xml | 0 {src/configure/include => include}/counter.h | 0 .../include => include/db}/table-counters.h | 0 .../include => include/db}/table-firewall.h | 0 .../include => include/db}/table-restrictions.h | 0 .../include => include/db}/table-statistics.h | 0 {src/database/include => include}/stc-db.h | 0 include/stc-error.h | 0 include/stc-firewall.h | 0 include/stc-manager-gdbus.h | 0 include/stc-manager-plugin-appstatus.h | 0 include/stc-manager-plugin-exception.h | 0 include/stc-manager-plugin-firewall.h | 0 include/stc-manager-plugin-monitor.h | 0 include/stc-manager-plugin-pcap.h | 0 include/stc-manager-plugin-procfs.h | 0 include/stc-manager-plugin-tether.h | 0 include/stc-manager-util.h | 0 include/stc-manager.h | 0 include/stc-pcap.h | 0 include/stc-restriction.h | 0 include/stc-statistics.h | 0 include/transmission.h | 0 {src => manager}/CMakeLists.txt | 38 ++++++++-------------- {src => manager}/database/db-common.c | 0 {src => manager}/database/db-guard.c | 0 .../include => manager/database}/db-internal.h | 0 .../tables => manager/database}/table-counters.c | 0 .../tables => manager/database}/table-firewall.c | 0 .../database}/table-restrictions.c | 0 .../tables => manager/database}/table-statistics.c | 0 .../include => manager/helper}/configure_stub.h | 0 {src => manager}/helper/helper-cgroup.c | 0 {src => manager}/helper/helper-cgroup.h | 0 {src => manager}/helper/helper-file.c | 0 {src => manager}/helper/helper-file.h | 0 {src => manager}/helper/helper-firewall.c | 0 {src => manager}/helper/helper-firewall.h | 0 {src => manager}/helper/helper-inotify.c | 0 {src => manager}/helper/helper-inotify.h | 0 {src => manager}/helper/helper-iptables.c | 0 {src => manager}/helper/helper-iptables.h | 0 {src => manager}/helper/helper-net-cls.c | 0 {src => manager}/helper/helper-net-cls.h | 0 {src => manager}/helper/helper-nfacct-rule.c | 1 - {src => manager}/helper/helper-nfacct-rule.h | 1 - {src => manager}/helper/helper-nl.c | 0 {src => manager}/helper/helper-nl.h | 0 {src => manager}/helper/helper-procfs.c | 0 {src => manager}/helper/helper-procfs.h | 0 {src => manager}/stc-firewall.c | 0 {src => manager}/stc-manager-gdbus.c | 0 {src => manager}/stc-manager-plugin-appstatus.c | 0 {src => manager}/stc-manager-plugin-exception.c | 0 {src => manager}/stc-manager-plugin-firewall.c | 0 {src => manager}/stc-manager-plugin-monitor.c | 0 {src => manager}/stc-manager-plugin-pcap.c | 0 {src => manager}/stc-manager-plugin-procfs.c | 0 {src => manager}/stc-manager-plugin-tether.c | 0 {src => manager}/stc-manager.c | 0 {src => manager}/stc-pcap.c | 0 {src => manager}/stc-restriction.c | 0 {src => manager}/stc-statistics.c | 0 {src => manager/util}/stc-manager-util.c | 0 {src/utils => misc}/CMakeLists.txt | 0 {src/utils => misc}/net-cls-release.c | 0 .../stc-manager.manifest | 1 - packaging/stc-manager.spec | 15 +++++---- plugin/CMakeLists.txt | 7 ++-- plugin/appstatus/CMakeLists.txt | 2 -- plugin/appstatus/stc-plugin-appstatus.c | 0 .../appstatus/{include => }/stc-plugin-appstatus.h | 0 plugin/exception/CMakeLists.txt | 2 -- plugin/exception/stc-plugin-exception.c | 0 .../exception/{include => }/stc-plugin-exception.h | 0 plugin/firewall/CMakeLists.txt | 2 -- plugin/firewall/stc-plugin-firewall.c | 0 .../firewall/{include => }/stc-plugin-firewall.h | 0 plugin/monitor/CMakeLists.txt | 10 +++--- plugin/monitor/stc-plugin-monitor-app.c | 0 .../monitor/{include => }/stc-plugin-monitor-app.h | 0 plugin/monitor/stc-plugin-monitor-connection.c | 0 .../{include => }/stc-plugin-monitor-connection.h | 0 .../{include => }/stc-plugin-monitor-context.h | 0 plugin/monitor/stc-plugin-monitor-ipt.c | 0 .../monitor/{include => }/stc-plugin-monitor-ipt.h | 0 plugin/monitor/stc-plugin-monitor-proc.c | 0 .../{include => }/stc-plugin-monitor-proc.h | 0 plugin/monitor/stc-plugin-monitor-rstn.c | 0 .../{include => }/stc-plugin-monitor-rstn.h | 0 plugin/monitor/stc-plugin-monitor-time.c | 0 .../{include => }/stc-plugin-monitor-time.h | 0 plugin/monitor/stc-plugin-monitor.c | 0 plugin/monitor/{include => }/stc-plugin-monitor.h | 0 plugin/pcap/CMakeLists.txt | 2 -- .../pcap/{include => }/stc-plugin-pcap-internal.h | 0 plugin/pcap/stc-plugin-pcap.c | 0 plugin/pcap/{include => }/stc-plugin-pcap.h | 0 plugin/procfs/CMakeLists.txt | 5 ++- plugin/procfs/stc-plugin-procfs.c | 0 plugin/procfs/{include => }/stc-plugin-procfs.h | 0 plugin/tether/CMakeLists.txt | 3 +- plugin/tether/stc-plugin-tether.c | 0 plugin/tether/{include => }/stc-plugin-tether.h | 0 {scripts => res}/500.stc-manager_upgrade.sh | 0 {resources => res}/dbus/net.stc-manager.service | 0 {resources => res}/dbus/stc-manager.conf | 0 {data => res}/exceptions | 0 {data => res}/firewall_db.sql | 0 {resources => res}/systemd/stc-manager.service | 0 {data => res}/traffic_db.sql | 0 {unittest => tests}/CMakeLists.txt | 0 {unittest => tests}/common.cpp | 1 - {unittest => tests}/common.h | 0 {unittest => tests}/firewall.cpp | 1 - {unittest => tests}/firewall.h | 0 {unittest => tests}/gdbus.cpp | 0 {unittest => tests}/gdbus.h | 0 {unittest => tests}/manager.cpp | 0 {unittest => tests}/manager.h | 0 {unittest => tests}/restriction.cpp | 0 {unittest => tests}/restriction.h | 0 {unittest => tests}/statistics.cpp | 2 +- {unittest => tests}/statistics.h | 0 {unittest => tests}/stcmgr.cpp | 0 {unittest => tests}/stcmgr.h | 0 {unittest => tests}/unittest.cpp | 0 {unittest => tests}/unittest.h | 0 135 files changed, 38 insertions(+), 66 deletions(-) rename LICENSE => LICENSE.APLv2 (100%) rename {interfaces => dbus-interface}/CMakeLists.txt (100%) rename {interfaces => dbus-interface}/stcmanager-iface-firewall.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-manager.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-pcap.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-restriction.xml (100%) rename {interfaces => dbus-interface}/stcmanager-iface-statistics.xml (100%) rename {src/configure/include => include}/counter.h (100%) rename {src/database/include => include/db}/table-counters.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-firewall.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-restrictions.h (100%) mode change 100755 => 100644 rename {src/database/include => include/db}/table-statistics.h (100%) mode change 100755 => 100644 rename {src/database/include => include}/stc-db.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 include/stc-error.h mode change 100755 => 100644 include/stc-firewall.h mode change 100755 => 100644 include/stc-manager-gdbus.h mode change 100755 => 100644 include/stc-manager-plugin-appstatus.h mode change 100755 => 100644 include/stc-manager-plugin-exception.h mode change 100755 => 100644 include/stc-manager-plugin-firewall.h mode change 100755 => 100644 include/stc-manager-plugin-monitor.h mode change 100755 => 100644 include/stc-manager-plugin-pcap.h mode change 100755 => 100644 include/stc-manager-plugin-procfs.h mode change 100755 => 100644 include/stc-manager-plugin-tether.h mode change 100755 => 100644 include/stc-manager-util.h mode change 100755 => 100644 include/stc-manager.h mode change 100755 => 100644 include/stc-pcap.h mode change 100755 => 100644 include/stc-restriction.h mode change 100755 => 100644 include/stc-statistics.h mode change 100755 => 100644 include/transmission.h rename {src => manager}/CMakeLists.txt (68%) rename {src => manager}/database/db-common.c (100%) mode change 100755 => 100644 rename {src => manager}/database/db-guard.c (100%) rename {src/database/include => manager/database}/db-internal.h (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-counters.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-firewall.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-restrictions.c (100%) mode change 100755 => 100644 rename {src/database/tables => manager/database}/table-statistics.c (100%) mode change 100755 => 100644 rename {src/configure/include => manager/helper}/configure_stub.h (100%) rename {src => manager}/helper/helper-cgroup.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-cgroup.h (100%) rename {src => manager}/helper/helper-file.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-file.h (100%) rename {src => manager}/helper/helper-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-firewall.h (100%) rename {src => manager}/helper/helper-inotify.c (100%) rename {src => manager}/helper/helper-inotify.h (100%) rename {src => manager}/helper/helper-iptables.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-iptables.h (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-net-cls.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-net-cls.h (100%) rename {src => manager}/helper/helper-nfacct-rule.c (99%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nfacct-rule.h (99%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nl.c (100%) mode change 100755 => 100644 rename {src => manager}/helper/helper-nl.h (100%) rename {src => manager}/helper/helper-procfs.c (100%) rename {src => manager}/helper/helper-procfs.h (100%) rename {src => manager}/stc-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-gdbus.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-appstatus.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-exception.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-firewall.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-monitor.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-pcap.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-procfs.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager-plugin-tether.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-manager.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-pcap.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-restriction.c (100%) mode change 100755 => 100644 rename {src => manager}/stc-statistics.c (100%) mode change 100755 => 100644 rename {src => manager/util}/stc-manager-util.c (100%) mode change 100755 => 100644 rename {src/utils => misc}/CMakeLists.txt (100%) rename {src/utils => misc}/net-cls-release.c (100%) rename stc-manager.manifest => packaging/stc-manager.manifest (98%) mode change 100755 => 100644 plugin/appstatus/stc-plugin-appstatus.c rename plugin/appstatus/{include => }/stc-plugin-appstatus.h (100%) mode change 100755 => 100644 plugin/exception/stc-plugin-exception.c rename plugin/exception/{include => }/stc-plugin-exception.h (100%) mode change 100755 => 100644 plugin/firewall/stc-plugin-firewall.c rename plugin/firewall/{include => }/stc-plugin-firewall.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-app.c rename plugin/monitor/{include => }/stc-plugin-monitor-app.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-connection.c rename plugin/monitor/{include => }/stc-plugin-monitor-connection.h (100%) mode change 100755 => 100644 rename plugin/monitor/{include => }/stc-plugin-monitor-context.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-ipt.c rename plugin/monitor/{include => }/stc-plugin-monitor-ipt.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-proc.c rename plugin/monitor/{include => }/stc-plugin-monitor-proc.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-rstn.c rename plugin/monitor/{include => }/stc-plugin-monitor-rstn.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor-time.c rename plugin/monitor/{include => }/stc-plugin-monitor-time.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/monitor/stc-plugin-monitor.c rename plugin/monitor/{include => }/stc-plugin-monitor.h (100%) mode change 100755 => 100644 rename plugin/pcap/{include => }/stc-plugin-pcap-internal.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/pcap/stc-plugin-pcap.c rename plugin/pcap/{include => }/stc-plugin-pcap.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/procfs/stc-plugin-procfs.c rename plugin/procfs/{include => }/stc-plugin-procfs.h (100%) mode change 100755 => 100644 mode change 100755 => 100644 plugin/tether/stc-plugin-tether.c rename plugin/tether/{include => }/stc-plugin-tether.h (100%) rename {scripts => res}/500.stc-manager_upgrade.sh (100%) mode change 100644 => 100755 rename {resources => res}/dbus/net.stc-manager.service (100%) mode change 100755 => 100644 rename {resources => res}/dbus/stc-manager.conf (100%) mode change 100755 => 100644 rename {data => res}/exceptions (100%) rename {data => res}/firewall_db.sql (100%) rename {resources => res}/systemd/stc-manager.service (100%) rename {data => res}/traffic_db.sql (100%) rename {unittest => tests}/CMakeLists.txt (100%) rename {unittest => tests}/common.cpp (99%) rename {unittest => tests}/common.h (100%) rename {unittest => tests}/firewall.cpp (99%) rename {unittest => tests}/firewall.h (100%) rename {unittest => tests}/gdbus.cpp (100%) rename {unittest => tests}/gdbus.h (100%) rename {unittest => tests}/manager.cpp (100%) rename {unittest => tests}/manager.h (100%) rename {unittest => tests}/restriction.cpp (100%) rename {unittest => tests}/restriction.h (100%) rename {unittest => tests}/statistics.cpp (99%) rename {unittest => tests}/statistics.h (100%) rename {unittest => tests}/stcmgr.cpp (100%) rename {unittest => tests}/stcmgr.h (100%) rename {unittest => tests}/unittest.cpp (100%) rename {unittest => tests}/unittest.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3386c69..011c4bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(stc-manager C CXX) SET(PACKAGE ${PROJECT_NAME}) -SET(INTERFACES "${CMAKE_SOURCE_DIR}/interfaces") +SET(INTERFACES "${CMAKE_SOURCE_DIR}/dbus-interface") SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(LIBDIR ${PREFIX}/${LIB_PATH}) -SET(DATA_DIR ${CMAKE_SOURCE_DIR}/data) +SET(DATA_DIR ${CMAKE_SOURCE_DIR}/res) -ADD_SUBDIRECTORY(interfaces) -ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(dbus-interface) +ADD_SUBDIRECTORY(manager) ADD_SUBDIRECTORY(plugin) +ADD_SUBDIRECTORY(misc) IF(BUILD_GTESTS) - ADD_SUBDIRECTORY(unittest) + ADD_SUBDIRECTORY(tests) ENDIF(BUILD_GTESTS) diff --git a/LICENSE b/LICENSE.APLv2 similarity index 100% rename from LICENSE rename to LICENSE.APLv2 diff --git a/interfaces/CMakeLists.txt b/dbus-interface/CMakeLists.txt similarity index 100% rename from interfaces/CMakeLists.txt rename to dbus-interface/CMakeLists.txt diff --git a/interfaces/stcmanager-iface-firewall.xml b/dbus-interface/stcmanager-iface-firewall.xml similarity index 100% rename from interfaces/stcmanager-iface-firewall.xml rename to dbus-interface/stcmanager-iface-firewall.xml diff --git a/interfaces/stcmanager-iface-manager.xml b/dbus-interface/stcmanager-iface-manager.xml similarity index 100% rename from interfaces/stcmanager-iface-manager.xml rename to dbus-interface/stcmanager-iface-manager.xml diff --git a/interfaces/stcmanager-iface-pcap.xml b/dbus-interface/stcmanager-iface-pcap.xml similarity index 100% rename from interfaces/stcmanager-iface-pcap.xml rename to dbus-interface/stcmanager-iface-pcap.xml diff --git a/interfaces/stcmanager-iface-restriction.xml b/dbus-interface/stcmanager-iface-restriction.xml similarity index 100% rename from interfaces/stcmanager-iface-restriction.xml rename to dbus-interface/stcmanager-iface-restriction.xml diff --git a/interfaces/stcmanager-iface-statistics.xml b/dbus-interface/stcmanager-iface-statistics.xml similarity index 100% rename from interfaces/stcmanager-iface-statistics.xml rename to dbus-interface/stcmanager-iface-statistics.xml diff --git a/src/configure/include/counter.h b/include/counter.h similarity index 100% rename from src/configure/include/counter.h rename to include/counter.h diff --git a/src/database/include/table-counters.h b/include/db/table-counters.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-counters.h rename to include/db/table-counters.h diff --git a/src/database/include/table-firewall.h b/include/db/table-firewall.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-firewall.h rename to include/db/table-firewall.h diff --git a/src/database/include/table-restrictions.h b/include/db/table-restrictions.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-restrictions.h rename to include/db/table-restrictions.h diff --git a/src/database/include/table-statistics.h b/include/db/table-statistics.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/table-statistics.h rename to include/db/table-statistics.h diff --git a/src/database/include/stc-db.h b/include/stc-db.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/stc-db.h rename to include/stc-db.h diff --git a/include/stc-error.h b/include/stc-error.h old mode 100755 new mode 100644 diff --git a/include/stc-firewall.h b/include/stc-firewall.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-gdbus.h b/include/stc-manager-gdbus.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-appstatus.h b/include/stc-manager-plugin-appstatus.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-exception.h b/include/stc-manager-plugin-exception.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-firewall.h b/include/stc-manager-plugin-firewall.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-monitor.h b/include/stc-manager-plugin-monitor.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-pcap.h b/include/stc-manager-plugin-pcap.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-procfs.h b/include/stc-manager-plugin-procfs.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-plugin-tether.h b/include/stc-manager-plugin-tether.h old mode 100755 new mode 100644 diff --git a/include/stc-manager-util.h b/include/stc-manager-util.h old mode 100755 new mode 100644 diff --git a/include/stc-manager.h b/include/stc-manager.h old mode 100755 new mode 100644 diff --git a/include/stc-pcap.h b/include/stc-pcap.h old mode 100755 new mode 100644 diff --git a/include/stc-restriction.h b/include/stc-restriction.h old mode 100755 new mode 100644 diff --git a/include/stc-statistics.h b/include/stc-statistics.h old mode 100755 new mode 100644 diff --git a/include/transmission.h b/include/transmission.h old mode 100755 new mode 100644 diff --git a/src/CMakeLists.txt b/manager/CMakeLists.txt similarity index 68% rename from src/CMakeLists.txt rename to manager/CMakeLists.txt index 9883098..3c0d1b7 100644 --- a/src/CMakeLists.txt +++ b/manager/CMakeLists.txt @@ -21,10 +21,9 @@ FOREACH(flag ${stc_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) +SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) -SET(CONFIGURE_SOURCE_DIR ${SOURCE_DIR}/configure) SET(LIMITATION_SOURCE_DIR ${SOURCE_DIR}/limitation) SET(PLUGIN_DIR ${CMAKE_SOURCE_DIR}/plugin) SET(APPSTATUS_SOURCE_DIR ${PLUGIN_DIR}/appstatus) @@ -36,40 +35,31 @@ SET(MONITOR_SOURCE_DIR ${PLUGIN_DIR}/monitor) SET(FIREWALL_SOURCE_DIR ${PLUGIN_DIR}/firewall) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) INCLUDE_DIRECTORIES(${SOURCE_DIR}) INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) -INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CONFIGURE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${EXCEPTION_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${PCAP_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${TETHER_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${FIREWALL_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIMITATION_SOURCE_DIR}/include) - -INCLUDE_DIRECTORIES(${APPSTATUS_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${EXCEPTION_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${PROCFS_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${PCAP_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${TETHER_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${MONITOR_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${FIREWALL_SOURCE_DIR}/include) - -FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c) +FILE(GLOB SOURCE_SRCS ${SOURCE_DIR}/*.c util/*.c) FILE(GLOB HELPER_SRCS ${HELPER_SOURCE_DIR}/*.c) -FILE(GLOB CONFIGURE_SRCS ${CONFIGURE_SOURCE_DIR}/*.c) -FILE(GLOB LIMITATION_SRCS ${LIMITATION_SOURCE_DIR}/*.c) -SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS} ${CONFIGURE_SRCS} ${LIMITATION_SRCS}) +SET(SRCS ${SRCS} ${SOURCE_SRCS} ${HELPER_SRCS}) IF("${ENABLE_DATABASE}" STREQUAL "YES") FILE(GLOB DATABASE_SRCS ${DATABASE_SOURCE_DIR}/*.c) - FILE(GLOB DATABASE_TABLES_SRCS ${DATABASE_SOURCE_DIR}/tables/*.c) - SET(SRCS ${SRCS} ${DATABASE_SRCS} ${DATABASE_TABLES_SRCS}) + SET(SRCS ${SRCS} ${DATABASE_SRCS}) INSTALL(FILES ${DATA_DIR}/traffic_db.sql DESTINATION /usr/share) INSTALL(FILES ${DATA_DIR}/firewall_db.sql DESTINATION /usr/share) @@ -99,5 +89,3 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_pkgs_LDFLAGS} -ldl) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR}) ADD_DEPENDENCIES(${PROJECT_NAME} GENERATED_DBUS_CODE) - -ADD_SUBDIRECTORY(utils) diff --git a/src/database/db-common.c b/manager/database/db-common.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/db-common.c rename to manager/database/db-common.c diff --git a/src/database/db-guard.c b/manager/database/db-guard.c similarity index 100% rename from src/database/db-guard.c rename to manager/database/db-guard.c diff --git a/src/database/include/db-internal.h b/manager/database/db-internal.h old mode 100755 new mode 100644 similarity index 100% rename from src/database/include/db-internal.h rename to manager/database/db-internal.h diff --git a/src/database/tables/table-counters.c b/manager/database/table-counters.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-counters.c rename to manager/database/table-counters.c diff --git a/src/database/tables/table-firewall.c b/manager/database/table-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-firewall.c rename to manager/database/table-firewall.c diff --git a/src/database/tables/table-restrictions.c b/manager/database/table-restrictions.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-restrictions.c rename to manager/database/table-restrictions.c diff --git a/src/database/tables/table-statistics.c b/manager/database/table-statistics.c old mode 100755 new mode 100644 similarity index 100% rename from src/database/tables/table-statistics.c rename to manager/database/table-statistics.c diff --git a/src/configure/include/configure_stub.h b/manager/helper/configure_stub.h similarity index 100% rename from src/configure/include/configure_stub.h rename to manager/helper/configure_stub.h diff --git a/src/helper/helper-cgroup.c b/manager/helper/helper-cgroup.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-cgroup.c rename to manager/helper/helper-cgroup.c diff --git a/src/helper/helper-cgroup.h b/manager/helper/helper-cgroup.h similarity index 100% rename from src/helper/helper-cgroup.h rename to manager/helper/helper-cgroup.h diff --git a/src/helper/helper-file.c b/manager/helper/helper-file.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-file.c rename to manager/helper/helper-file.c diff --git a/src/helper/helper-file.h b/manager/helper/helper-file.h similarity index 100% rename from src/helper/helper-file.h rename to manager/helper/helper-file.h diff --git a/src/helper/helper-firewall.c b/manager/helper/helper-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-firewall.c rename to manager/helper/helper-firewall.c diff --git a/src/helper/helper-firewall.h b/manager/helper/helper-firewall.h similarity index 100% rename from src/helper/helper-firewall.h rename to manager/helper/helper-firewall.h diff --git a/src/helper/helper-inotify.c b/manager/helper/helper-inotify.c similarity index 100% rename from src/helper/helper-inotify.c rename to manager/helper/helper-inotify.c diff --git a/src/helper/helper-inotify.h b/manager/helper/helper-inotify.h similarity index 100% rename from src/helper/helper-inotify.h rename to manager/helper/helper-inotify.h diff --git a/src/helper/helper-iptables.c b/manager/helper/helper-iptables.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-iptables.c rename to manager/helper/helper-iptables.c diff --git a/src/helper/helper-iptables.h b/manager/helper/helper-iptables.h old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-iptables.h rename to manager/helper/helper-iptables.h diff --git a/src/helper/helper-net-cls.c b/manager/helper/helper-net-cls.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-net-cls.c rename to manager/helper/helper-net-cls.c diff --git a/src/helper/helper-net-cls.h b/manager/helper/helper-net-cls.h similarity index 100% rename from src/helper/helper-net-cls.h rename to manager/helper/helper-net-cls.h diff --git a/src/helper/helper-nfacct-rule.c b/manager/helper/helper-nfacct-rule.c old mode 100755 new mode 100644 similarity index 99% rename from src/helper/helper-nfacct-rule.c rename to manager/helper/helper-nfacct-rule.c index ff703d3..5694d14 --- a/src/helper/helper-nfacct-rule.c +++ b/manager/helper/helper-nfacct-rule.c @@ -959,4 +959,3 @@ void generate_counter_name(nfacct_rule_s *counter) warn_symbol, counter->iotype, counter->iftype, counter->classid, counter->ifname); } - diff --git a/src/helper/helper-nfacct-rule.h b/manager/helper/helper-nfacct-rule.h old mode 100755 new mode 100644 similarity index 99% rename from src/helper/helper-nfacct-rule.h rename to manager/helper/helper-nfacct-rule.h index f313849..5e09471 --- a/src/helper/helper-nfacct-rule.h +++ b/manager/helper/helper-nfacct-rule.h @@ -141,4 +141,3 @@ netlink_serialization_command * netlink_create_command(struct netlink_serialization_params *params); #endif /* __STC_NFACCT_RULE_H__ */ - diff --git a/src/helper/helper-nl.c b/manager/helper/helper-nl.c old mode 100755 new mode 100644 similarity index 100% rename from src/helper/helper-nl.c rename to manager/helper/helper-nl.c diff --git a/src/helper/helper-nl.h b/manager/helper/helper-nl.h similarity index 100% rename from src/helper/helper-nl.h rename to manager/helper/helper-nl.h diff --git a/src/helper/helper-procfs.c b/manager/helper/helper-procfs.c similarity index 100% rename from src/helper/helper-procfs.c rename to manager/helper/helper-procfs.c diff --git a/src/helper/helper-procfs.h b/manager/helper/helper-procfs.h similarity index 100% rename from src/helper/helper-procfs.h rename to manager/helper/helper-procfs.h diff --git a/src/stc-firewall.c b/manager/stc-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-firewall.c rename to manager/stc-firewall.c diff --git a/src/stc-manager-gdbus.c b/manager/stc-manager-gdbus.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-gdbus.c rename to manager/stc-manager-gdbus.c diff --git a/src/stc-manager-plugin-appstatus.c b/manager/stc-manager-plugin-appstatus.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-appstatus.c rename to manager/stc-manager-plugin-appstatus.c diff --git a/src/stc-manager-plugin-exception.c b/manager/stc-manager-plugin-exception.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-exception.c rename to manager/stc-manager-plugin-exception.c diff --git a/src/stc-manager-plugin-firewall.c b/manager/stc-manager-plugin-firewall.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-firewall.c rename to manager/stc-manager-plugin-firewall.c diff --git a/src/stc-manager-plugin-monitor.c b/manager/stc-manager-plugin-monitor.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-monitor.c rename to manager/stc-manager-plugin-monitor.c diff --git a/src/stc-manager-plugin-pcap.c b/manager/stc-manager-plugin-pcap.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-pcap.c rename to manager/stc-manager-plugin-pcap.c diff --git a/src/stc-manager-plugin-procfs.c b/manager/stc-manager-plugin-procfs.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-procfs.c rename to manager/stc-manager-plugin-procfs.c diff --git a/src/stc-manager-plugin-tether.c b/manager/stc-manager-plugin-tether.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-plugin-tether.c rename to manager/stc-manager-plugin-tether.c diff --git a/src/stc-manager.c b/manager/stc-manager.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager.c rename to manager/stc-manager.c diff --git a/src/stc-pcap.c b/manager/stc-pcap.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-pcap.c rename to manager/stc-pcap.c diff --git a/src/stc-restriction.c b/manager/stc-restriction.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-restriction.c rename to manager/stc-restriction.c diff --git a/src/stc-statistics.c b/manager/stc-statistics.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-statistics.c rename to manager/stc-statistics.c diff --git a/src/stc-manager-util.c b/manager/util/stc-manager-util.c old mode 100755 new mode 100644 similarity index 100% rename from src/stc-manager-util.c rename to manager/util/stc-manager-util.c diff --git a/src/utils/CMakeLists.txt b/misc/CMakeLists.txt similarity index 100% rename from src/utils/CMakeLists.txt rename to misc/CMakeLists.txt diff --git a/src/utils/net-cls-release.c b/misc/net-cls-release.c similarity index 100% rename from src/utils/net-cls-release.c rename to misc/net-cls-release.c diff --git a/stc-manager.manifest b/packaging/stc-manager.manifest similarity index 98% rename from stc-manager.manifest rename to packaging/stc-manager.manifest index 81ace0c..97e8c31 100644 --- a/stc-manager.manifest +++ b/packaging/stc-manager.manifest @@ -3,4 +3,3 @@ - diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 0690fde..c19c312 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -5,6 +5,7 @@ Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 Source0: %{name}-%{version}.tar.gz +Source1001: %{name}.manifest %define enable_database YES %define enable_statistics YES @@ -93,7 +94,7 @@ A smart traffic control manager extension for firewall plugin %prep %setup -q -chmod 644 %{SOURCE0} +cp %{SOURCE1001} ./%{name}.manifest %build @@ -135,29 +136,29 @@ rm -rf %{buildroot} #Exceptions file mkdir -p %{buildroot}/%{_localstatedir}/lib/stc -cp data/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions +cp res/exceptions %{buildroot}/%{_localstatedir}/lib/stc/exceptions #Systemd service file mkdir -p %{buildroot}%{_unitdir} -cp resources/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service +cp res/systemd/stc-manager.service %{buildroot}%{_unitdir}/stc-manager.service mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/ ln -s ../stc-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/stc-manager.service #DBus DAC (stc-manager.manifest enables DBus SMACK) mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d -cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf +cp res/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service +cp res/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system-services/net.stc.service #OS Upgrade mkdir -p %{buildroot}%{upgrade_script_path} -cp -f scripts/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} +cp -f res/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} %files %manifest %{name}.manifest -%license LICENSE +%license LICENSE.APLv2 %defattr(-,root,root,-) %attr(500,root,root) %{_bindir}/* diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 98f28b7..d1777f2 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -1,15 +1,14 @@ -SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) +SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/manager) SET(HELPER_SOURCE_DIR ${SOURCE_DIR}/helper) SET(DATABASE_SOURCE_DIR ${SOURCE_DIR}/database) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/interfaces) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbus-interface) INCLUDE_DIRECTORIES(${SOURCE_DIR}) INCLUDE_DIRECTORIES(${HELPER_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DATABASE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/db) ADD_SUBDIRECTORY(appstatus) ADD_SUBDIRECTORY(exception) diff --git a/plugin/appstatus/CMakeLists.txt b/plugin/appstatus/CMakeLists.txt index d4d7428..0a3acf7 100644 --- a/plugin/appstatus/CMakeLists.txt +++ b/plugin/appstatus/CMakeLists.txt @@ -16,8 +16,6 @@ FOREACH(flag ${appstatus_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") diff --git a/plugin/appstatus/stc-plugin-appstatus.c b/plugin/appstatus/stc-plugin-appstatus.c old mode 100755 new mode 100644 diff --git a/plugin/appstatus/include/stc-plugin-appstatus.h b/plugin/appstatus/stc-plugin-appstatus.h similarity index 100% rename from plugin/appstatus/include/stc-plugin-appstatus.h rename to plugin/appstatus/stc-plugin-appstatus.h diff --git a/plugin/exception/CMakeLists.txt b/plugin/exception/CMakeLists.txt index 1ccf391..06b6d93 100644 --- a/plugin/exception/CMakeLists.txt +++ b/plugin/exception/CMakeLists.txt @@ -15,8 +15,6 @@ FOREACH(flag ${exception_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") diff --git a/plugin/exception/stc-plugin-exception.c b/plugin/exception/stc-plugin-exception.c old mode 100755 new mode 100644 diff --git a/plugin/exception/include/stc-plugin-exception.h b/plugin/exception/stc-plugin-exception.h similarity index 100% rename from plugin/exception/include/stc-plugin-exception.h rename to plugin/exception/stc-plugin-exception.h diff --git a/plugin/firewall/CMakeLists.txt b/plugin/firewall/CMakeLists.txt index 05c4d90..2576f2d 100644 --- a/plugin/firewall/CMakeLists.txt +++ b/plugin/firewall/CMakeLists.txt @@ -14,8 +14,6 @@ FOREACH(flag ${firewall_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") diff --git a/plugin/firewall/stc-plugin-firewall.c b/plugin/firewall/stc-plugin-firewall.c old mode 100755 new mode 100644 diff --git a/plugin/firewall/include/stc-plugin-firewall.h b/plugin/firewall/stc-plugin-firewall.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/firewall/include/stc-plugin-firewall.h rename to plugin/firewall/stc-plugin-firewall.h diff --git a/plugin/monitor/CMakeLists.txt b/plugin/monitor/CMakeLists.txt index e1e0048..c05a448 100644 --- a/plugin/monitor/CMakeLists.txt +++ b/plugin/monitor/CMakeLists.txt @@ -18,12 +18,10 @@ FOREACH(flag ${monitor_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/configure/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/tether/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/appstatus/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/firewall/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/tether) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/appstatus) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/firewall) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-app.h b/plugin/monitor/stc-plugin-monitor-app.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-app.h rename to plugin/monitor/stc-plugin-monitor-app.h diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-connection.h b/plugin/monitor/stc-plugin-monitor-connection.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-connection.h rename to plugin/monitor/stc-plugin-monitor-connection.h diff --git a/plugin/monitor/include/stc-plugin-monitor-context.h b/plugin/monitor/stc-plugin-monitor-context.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-context.h rename to plugin/monitor/stc-plugin-monitor-context.h diff --git a/plugin/monitor/stc-plugin-monitor-ipt.c b/plugin/monitor/stc-plugin-monitor-ipt.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-ipt.h b/plugin/monitor/stc-plugin-monitor-ipt.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-ipt.h rename to plugin/monitor/stc-plugin-monitor-ipt.h diff --git a/plugin/monitor/stc-plugin-monitor-proc.c b/plugin/monitor/stc-plugin-monitor-proc.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-proc.h b/plugin/monitor/stc-plugin-monitor-proc.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-proc.h rename to plugin/monitor/stc-plugin-monitor-proc.h diff --git a/plugin/monitor/stc-plugin-monitor-rstn.c b/plugin/monitor/stc-plugin-monitor-rstn.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-rstn.h b/plugin/monitor/stc-plugin-monitor-rstn.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-rstn.h rename to plugin/monitor/stc-plugin-monitor-rstn.h diff --git a/plugin/monitor/stc-plugin-monitor-time.c b/plugin/monitor/stc-plugin-monitor-time.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor-time.h b/plugin/monitor/stc-plugin-monitor-time.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor-time.h rename to plugin/monitor/stc-plugin-monitor-time.h diff --git a/plugin/monitor/stc-plugin-monitor.c b/plugin/monitor/stc-plugin-monitor.c old mode 100755 new mode 100644 diff --git a/plugin/monitor/include/stc-plugin-monitor.h b/plugin/monitor/stc-plugin-monitor.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/monitor/include/stc-plugin-monitor.h rename to plugin/monitor/stc-plugin-monitor.h diff --git a/plugin/pcap/CMakeLists.txt b/plugin/pcap/CMakeLists.txt index be4b022..48c7dae 100644 --- a/plugin/pcap/CMakeLists.txt +++ b/plugin/pcap/CMakeLists.txt @@ -14,8 +14,6 @@ FOREACH(flag ${pcap_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") diff --git a/plugin/pcap/include/stc-plugin-pcap-internal.h b/plugin/pcap/stc-plugin-pcap-internal.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/pcap/include/stc-plugin-pcap-internal.h rename to plugin/pcap/stc-plugin-pcap-internal.h diff --git a/plugin/pcap/stc-plugin-pcap.c b/plugin/pcap/stc-plugin-pcap.c old mode 100755 new mode 100644 diff --git a/plugin/pcap/include/stc-plugin-pcap.h b/plugin/pcap/stc-plugin-pcap.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/pcap/include/stc-plugin-pcap.h rename to plugin/pcap/stc-plugin-pcap.h diff --git a/plugin/procfs/CMakeLists.txt b/plugin/procfs/CMakeLists.txt index 17ab7f2..6e529c1 100644 --- a/plugin/procfs/CMakeLists.txt +++ b/plugin/procfs/CMakeLists.txt @@ -14,9 +14,8 @@ FOREACH(flag ${procfs_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/exception) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/procfs/stc-plugin-procfs.c b/plugin/procfs/stc-plugin-procfs.c old mode 100755 new mode 100644 diff --git a/plugin/procfs/include/stc-plugin-procfs.h b/plugin/procfs/stc-plugin-procfs.h old mode 100755 new mode 100644 similarity index 100% rename from plugin/procfs/include/stc-plugin-procfs.h rename to plugin/procfs/stc-plugin-procfs.h diff --git a/plugin/tether/CMakeLists.txt b/plugin/tether/CMakeLists.txt index b64cfbd..7918d2e 100644 --- a/plugin/tether/CMakeLists.txt +++ b/plugin/tether/CMakeLists.txt @@ -14,8 +14,7 @@ FOREACH(flag ${tether_plugin_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/monitor) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/plugin/tether/stc-plugin-tether.c b/plugin/tether/stc-plugin-tether.c old mode 100755 new mode 100644 diff --git a/plugin/tether/include/stc-plugin-tether.h b/plugin/tether/stc-plugin-tether.h similarity index 100% rename from plugin/tether/include/stc-plugin-tether.h rename to plugin/tether/stc-plugin-tether.h diff --git a/scripts/500.stc-manager_upgrade.sh b/res/500.stc-manager_upgrade.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/500.stc-manager_upgrade.sh rename to res/500.stc-manager_upgrade.sh diff --git a/resources/dbus/net.stc-manager.service b/res/dbus/net.stc-manager.service old mode 100755 new mode 100644 similarity index 100% rename from resources/dbus/net.stc-manager.service rename to res/dbus/net.stc-manager.service diff --git a/resources/dbus/stc-manager.conf b/res/dbus/stc-manager.conf old mode 100755 new mode 100644 similarity index 100% rename from resources/dbus/stc-manager.conf rename to res/dbus/stc-manager.conf diff --git a/data/exceptions b/res/exceptions similarity index 100% rename from data/exceptions rename to res/exceptions diff --git a/data/firewall_db.sql b/res/firewall_db.sql similarity index 100% rename from data/firewall_db.sql rename to res/firewall_db.sql diff --git a/resources/systemd/stc-manager.service b/res/systemd/stc-manager.service similarity index 100% rename from resources/systemd/stc-manager.service rename to res/systemd/stc-manager.service diff --git a/data/traffic_db.sql b/res/traffic_db.sql similarity index 100% rename from data/traffic_db.sql rename to res/traffic_db.sql diff --git a/unittest/CMakeLists.txt b/tests/CMakeLists.txt similarity index 100% rename from unittest/CMakeLists.txt rename to tests/CMakeLists.txt diff --git a/unittest/common.cpp b/tests/common.cpp similarity index 99% rename from unittest/common.cpp rename to tests/common.cpp index 3fbaf8d..0f2b8d4 100644 --- a/unittest/common.cpp +++ b/tests/common.cpp @@ -63,4 +63,3 @@ void MainLoop::quit(void) { timeoutCb(NULL); } - diff --git a/unittest/common.h b/tests/common.h similarity index 100% rename from unittest/common.h rename to tests/common.h diff --git a/unittest/firewall.cpp b/tests/firewall.cpp similarity index 99% rename from unittest/firewall.cpp rename to tests/firewall.cpp index 0cf9521..43f32e2 100644 --- a/unittest/firewall.cpp +++ b/tests/firewall.cpp @@ -536,4 +536,3 @@ error_e Firewall::Lock() return ERROR_NONE; } - diff --git a/unittest/firewall.h b/tests/firewall.h similarity index 100% rename from unittest/firewall.h rename to tests/firewall.h diff --git a/unittest/gdbus.cpp b/tests/gdbus.cpp similarity index 100% rename from unittest/gdbus.cpp rename to tests/gdbus.cpp diff --git a/unittest/gdbus.h b/tests/gdbus.h similarity index 100% rename from unittest/gdbus.h rename to tests/gdbus.h diff --git a/unittest/manager.cpp b/tests/manager.cpp similarity index 100% rename from unittest/manager.cpp rename to tests/manager.cpp diff --git a/unittest/manager.h b/tests/manager.h similarity index 100% rename from unittest/manager.h rename to tests/manager.h diff --git a/unittest/restriction.cpp b/tests/restriction.cpp similarity index 100% rename from unittest/restriction.cpp rename to tests/restriction.cpp diff --git a/unittest/restriction.h b/tests/restriction.h similarity index 100% rename from unittest/restriction.h rename to tests/restriction.h diff --git a/unittest/statistics.cpp b/tests/statistics.cpp similarity index 99% rename from unittest/statistics.cpp rename to tests/statistics.cpp index 6c80db1..de870c4 100644 --- a/unittest/statistics.cpp +++ b/tests/statistics.cpp @@ -153,7 +153,7 @@ void Statistics::MakeRuleParams(GVariant **params, int mode) break; case 3: /* get all */ default: - *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder)); + *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder)); break; } diff --git a/unittest/statistics.h b/tests/statistics.h similarity index 100% rename from unittest/statistics.h rename to tests/statistics.h diff --git a/unittest/stcmgr.cpp b/tests/stcmgr.cpp similarity index 100% rename from unittest/stcmgr.cpp rename to tests/stcmgr.cpp diff --git a/unittest/stcmgr.h b/tests/stcmgr.h similarity index 100% rename from unittest/stcmgr.h rename to tests/stcmgr.h diff --git a/unittest/unittest.cpp b/tests/unittest.cpp similarity index 100% rename from unittest/unittest.cpp rename to tests/unittest.cpp diff --git a/unittest/unittest.h b/tests/unittest.h similarity index 100% rename from unittest/unittest.h rename to tests/unittest.h -- 2.7.4