From f96096d10de30f2feae573ba758d8a8277a2f607 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Tue, 19 Mar 2019 16:21:14 +0900 Subject: [PATCH 01/16] Change to operate in on-demand mode Change-Id: Iea3e5df460e906e6790d66f65e9db338667a1c13 Signed-off-by: hyunuktak --- data/exceptions | 1 + include/stc-manager.h | 4 ++++ packaging/stc-manager.spec | 4 ++++ resources/dbus/net.stc-manager.service | 5 ++++ resources/systemd/stc-manager.service | 4 ++-- src/stc-firewall.c | 26 +++++++++++++++++++++ src/stc-manager-gdbus.c | 6 +++++ src/stc-manager.c | 42 ++++++++++++++++++++++++++-------- src/stc-pcap.c | 8 +++++++ src/stc-restriction.c | 14 ++++++++++++ src/stc-statistics.c | 8 +++++++ 11 files changed, 111 insertions(+), 11 deletions(-) create mode 100755 resources/dbus/net.stc-manager.service diff --git a/data/exceptions b/data/exceptions index ef89dd3..c3d4cbe 100644 --- a/data/exceptions +++ b/data/exceptions @@ -28,6 +28,7 @@ ps:inst wlan.sh:script wpa_supp.sh:script stc-manager:sys +stc-iptables:sys dlogutil:sys wifi-loader:sys wrt-loader:sys diff --git a/include/stc-manager.h b/include/stc-manager.h index 82d8747..bc2047f 100755 --- a/include/stc-manager.h +++ b/include/stc-manager.h @@ -236,6 +236,9 @@ typedef struct { typedef struct { GMainLoop *main_loop; + guint timer; + gboolean keep_alive; + gboolean ondemand_mode; gpointer statistics_obj; gpointer restriction_obj; @@ -254,5 +257,6 @@ typedef struct { stc_s *stc_get_manager(void); void stc_stop_manager(void); int stc_commit_iptables(char *cmd, int *err_num, char **err_str); +void stc_set_keep_alive(gboolean keep_alive); #endif /* __STC_MANAGER__ */ diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 11549fe..b86122b 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -136,6 +136,9 @@ ln -s ../stc-manager.service %{buildroot}%{_libdir}/systemd/system/multi-user.ta 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 + %files %manifest %{name}.manifest %license LICENSE @@ -150,6 +153,7 @@ cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/st #DBus DAC %attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/* +%attr(644,root,root) %{_datadir}/dbus-1/system-services/* %if %{?enable_database} == YES %config(noreplace) %attr(660, root, root) %{database_full_path} diff --git a/resources/dbus/net.stc-manager.service b/resources/dbus/net.stc-manager.service new file mode 100755 index 0000000..13f4097 --- /dev/null +++ b/resources/dbus/net.stc-manager.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=net.stc +Exec=/bin/false +User=root +SystemdService=stc-manager.service diff --git a/resources/systemd/stc-manager.service b/resources/systemd/stc-manager.service index 70a9eef..e3bce9f 100644 --- a/resources/systemd/stc-manager.service +++ b/resources/systemd/stc-manager.service @@ -4,10 +4,10 @@ Requires=dbus.socket After=dbus.socket [Service] -Type=forking +Type=dbus +BusName=net.stc SmackProcessLabel=System ExecStart=/usr/bin/stc-manager -Restart=always [Install] WantedBy=multi-user.target diff --git a/src/stc-firewall.c b/src/stc-firewall.c index bc71cc9..c13d406 100755 --- a/src/stc-firewall.c +++ b/src/stc-firewall.c @@ -47,6 +47,8 @@ gboolean handle_firewall_lock(StcFirewall *object, { __STC_LOG_FUNC_ENTER__; + stc_set_keep_alive(TRUE); + stc_plugin_firewall_lock(); STC_DBUS_REPLY_ERROR_NONE(invocation); @@ -60,6 +62,8 @@ gboolean handle_firewall_unlock(StcFirewall *object, { __STC_LOG_FUNC_ENTER__; + stc_set_keep_alive(TRUE); + stc_plugin_firewall_unlock(); STC_DBUS_REPLY_ERROR_NONE(invocation); @@ -75,6 +79,8 @@ gboolean handle_firewall_get_lock(StcFirewall *object, GVariant *return_parameters = NULL; int state = 0; + stc_set_keep_alive(TRUE); + stc_plugin_firewall_get_lock(&state); return_parameters = g_variant_new("(i)", state); @@ -91,6 +97,8 @@ gboolean handle_firewall_add_chain(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + if (chain == NULL) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); @@ -118,6 +126,8 @@ gboolean handle_firewall_remove_chain(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + if (chain == NULL) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); @@ -145,6 +155,8 @@ gboolean handle_firewall_flush_chain(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + if (chain == NULL) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); @@ -172,6 +184,8 @@ gboolean handle_firewall_get_all_chain(StcFirewall *object, GVariantBuilder *builder = NULL; GVariant *return_parameters = NULL; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); stc_plugin_firewall_get_all_chain(builder); @@ -194,6 +208,8 @@ gboolean handle_firewall_set_chain(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + if (chain == NULL || target >= STC_FW_CHAIN_TARGET_MAX) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, @@ -222,6 +238,8 @@ gboolean handle_firewall_unset_chain(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + if (chain == NULL) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); @@ -249,6 +267,8 @@ gboolean handle_firewall_add_rule(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + ret = stc_plugin_firewall_add_rule(parameters); if (ret != STC_ERROR_NONE) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, ret); @@ -269,6 +289,8 @@ gboolean handle_firewall_remove_rule(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + ret = stc_plugin_firewall_remove_rule(parameters); if (ret != STC_ERROR_NONE) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, ret); @@ -289,6 +311,8 @@ gboolean handle_firewall_update_rule(StcFirewall *object, __STC_LOG_FUNC_ENTER__; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + ret = stc_plugin_firewall_update_rule(parameters); if (ret != STC_ERROR_NONE) { STC_FIREWALL_DBUS_REPLY_ERROR(invocation, ret); @@ -309,6 +333,8 @@ gboolean handle_firewall_get_all_rule(StcFirewall *object, GVariantBuilder *builder = NULL; GVariant *return_parameters = NULL; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); stc_plugin_firewall_get_all_rule(builder); diff --git a/src/stc-manager-gdbus.c b/src/stc-manager-gdbus.c index 7990287..943f466 100755 --- a/src/stc-manager-gdbus.c +++ b/src/stc-manager-gdbus.c @@ -568,6 +568,8 @@ gboolean handle_manager_stop(StcManager *object, __STC_LOG_FUNC_ENTER__; GVariant *return_parameters = NULL; + stc_set_keep_alive(TRUE); + STC_LOGI("stc manager stop"); return_parameters = g_variant_new("(i)", STC_ERROR_NONE); @@ -593,6 +595,8 @@ gboolean handle_manager_commit_iptables(StcManager *object, char *err_str = NULL; char cmd[STC_CMD_SIZE] = { 0, }; + stc_set_keep_alive(TRUE); + if (option == NULL) { STC_MANAGER_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); @@ -626,6 +630,8 @@ gboolean handle_manager_commit_ip6tables(StcManager *object, char *err_str = NULL; char cmd[STC_CMD_SIZE] = { 0, }; + stc_set_keep_alive(TRUE); + if (option == NULL) { STC_MANAGER_DBUS_REPLY_ERROR(invocation, STC_ERROR_INVALID_PARAMETER); diff --git a/src/stc-manager.c b/src/stc-manager.c index 5e5bcef..a376e7f 100755 --- a/src/stc-manager.c +++ b/src/stc-manager.c @@ -126,12 +126,16 @@ static stc_s *__stc_manager_init(void) return NULL; //LCOV_EXCL_LINE } + g_stc->ondemand_mode = TRUE; + stc_plugin_appstatus_init(); stc_plugin_exception_init(); stc_plugin_procfs_init(); stc_plugin_tether_init(); - stc_plugin_pcap_init(); - stc_plugin_monitor_init(); + if (stc_plugin_pcap_init() == STC_ERROR_NONE) + g_stc->ondemand_mode = FALSE; + if (stc_plugin_monitor_init() == STC_ERROR_NONE) + g_stc->ondemand_mode = FALSE; stc_plugin_firewall_init(); stc_plugin_procfs_load_pid(); @@ -143,6 +147,18 @@ static stc_s *__stc_manager_init(void) return stc; } +static gboolean __stc_timer_expired(gpointer data) +{ + if (g_stc->keep_alive) { + g_stc->keep_alive = FALSE; + return TRUE; + } + + g_main_loop_quit(g_stc->main_loop); + + return FALSE; +} + API stc_s *stc_get_manager(void) { return g_stc; @@ -220,10 +236,14 @@ int stc_commit_iptables(char *cmd, int *err_num, char **err_str) return STC_ERROR_FAIL; } +void stc_set_keep_alive(gboolean keep_alive) +{ + g_stc->keep_alive = keep_alive; +} + gint32 main(gint32 argc, gchar *argv[]) { GMainLoop *main_loop = NULL; - gint32 ret = -1; STC_LOGI("Smart Traffic Control Manager"); @@ -231,33 +251,37 @@ gint32 main(gint32 argc, gchar *argv[]) setenv("GCOV_PREFIX", "/tmp/daemon", 1); #endif +/* if (daemon(0, 0) != 0) STC_LOGE("Can't start daemon"); //LCOV_EXCL_LINE +*/ /* Initialize required subsystems */ #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif - /* Crate the GLIB main loop */ - main_loop = g_main_loop_new(NULL, FALSE); - g_stc = __stc_manager_init(); if (!g_stc) goto fail; + /* Crate the GLIB main loop */ + main_loop = g_main_loop_new(NULL, FALSE); g_stc->main_loop = main_loop; + if (g_stc->ondemand_mode) { + g_stc->timer = g_timeout_add_seconds(10, __stc_timer_expired, NULL); + g_stc->keep_alive = FALSE; + } + /* Run the main loop */ g_main_loop_run(main_loop); - ret = 0; - fail: __stc_manager_deinit(); if (main_loop) g_main_loop_unref(main_loop); - return ret; + return 0; } diff --git a/src/stc-pcap.c b/src/stc-pcap.c index 91dd1e2..3faa7ec 100755 --- a/src/stc-pcap.c +++ b/src/stc-pcap.c @@ -91,6 +91,8 @@ gboolean handle_pcap_start(StcPcap *object, stc_pcap_s pcap; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + memset(&pcap, 0, sizeof(stc_pcap_s)); g_variant_get(parameters, "a{sv}", &iter); @@ -130,6 +132,8 @@ gboolean handle_pcap_stop(StcPcap *object, stc_pcap_s pcap; int ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + memset(&pcap, 0, sizeof(stc_pcap_s)); g_variant_get(parameters, "a{sv}", &iter); @@ -167,6 +171,8 @@ gboolean handle_pcap_get_all(StcPcap *object, GVariantBuilder *builder = NULL; GVariant *return_parameters = NULL; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); stc_plugin_pcap_get_all_loop(builder); @@ -188,6 +194,8 @@ gboolean handle_pcap_find_all_devs(StcPcap *object, GVariantBuilder *builder = NULL; GVariant *return_parameters = NULL; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); stc_plugin_pcap_find_all_devs(builder); diff --git a/src/stc-restriction.c b/src/stc-restriction.c index d49eb42..d6bae55 100755 --- a/src/stc-restriction.c +++ b/src/stc-restriction.c @@ -269,6 +269,8 @@ gboolean handle_restriction_set(StcRestriction *object, table_restrictions_info rule; stc_error_e ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + memset(&rule, 0, sizeof(table_restrictions_info)); __initialize_rstn_rule(&rule); @@ -311,6 +313,8 @@ gboolean handle_restriction_unset(StcRestriction *object, table_restrictions_info rule; stc_error_e ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + memset(&rule, 0, sizeof(table_restrictions_info)); __initialize_rstn_rule(&rule); @@ -354,6 +358,8 @@ gboolean handle_restriction_set_list(StcRestriction *object, GVariantIter *iter_row = NULL; stc_error_e ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + g_variant_get(parameters, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { table_restrictions_info rule; @@ -403,6 +409,8 @@ gboolean handle_restriction_unset_list(StcRestriction *object, GVariantIter *iter_row = NULL; stc_error_e ret = STC_ERROR_NONE; + stc_set_keep_alive(TRUE); + g_variant_get(parameters, "aa{sv}", &iter); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { table_restrictions_info rule; @@ -453,6 +461,8 @@ gboolean handle_restriction_get(StcRestriction *object, GVariant *return_parameters = NULL; stc_error_e ret; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); ret = table_restrictions_per_app(app_id, @@ -483,6 +493,8 @@ gboolean handle_restriction_get_all(StcRestriction *object, GVariant *return_parameters = NULL; stc_error_e ret; + stc_set_keep_alive(TRUE); + builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); ret = table_restrictions_foreach(__table_restrictions_foreach_app_cb, @@ -514,6 +526,8 @@ gboolean handle_restriction_get_type(StcRestriction *object, stc_rstn_type_e type = STC_RSTN_TYPE_UNKNOWN; stc_error_e ret; + stc_set_keep_alive(TRUE); + ret = table_restrictions_get_restriction_type(app_id, iftype, &type); if (ret < STC_ERROR_NONE) { STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE diff --git a/src/stc-statistics.c b/src/stc-statistics.c index f2ff8e9..0d5a761 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -247,6 +247,8 @@ gboolean handle_statistics_get_all(StcStatistics *object, GVariant *return_parameters = NULL; stc_error_e ret; + stc_set_keep_alive(TRUE); + /* Total statistics since epoch */ rule.from = epoch; rule.to = cur_time; @@ -294,6 +296,8 @@ gboolean handle_statistics_init(StcStatistics *object, { __STC_LOG_FUNC_ENTER__; + stc_set_keep_alive(TRUE); + STC_LOGI("stc statistics initialized"); stc_statistics_complete_init(object, invocation); @@ -315,6 +319,8 @@ gboolean handle_statistics_get(StcStatistics *object, GVariant *return_parameters = NULL; stc_error_e ret; + stc_set_keep_alive(TRUE); + /* Total statistics since epoch */ rule.from = epoch; rule.to = cur_time; @@ -367,6 +373,8 @@ gboolean handle_statistics_reset(StcStatistics *object, GVariant *return_parameters = NULL; stc_error_e ret; + stc_set_keep_alive(TRUE); + if (reset_rule != NULL) { DEBUG_GDBUS_VARIANT("Selection rule: ", reset_rule); GVariantIter *iter = NULL; -- 2.7.4 From 3f428d201241eed5bddb4d7ad28d8d554daaec0b Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Mon, 13 May 2019 11:35:48 +0900 Subject: [PATCH 02/16] Add monitor plugin requires for install dependency Change-Id: I91be1576eeaf46259c953b7fbc1430c90c4f03ee Signed-off-by: hyunuktak --- packaging/stc-manager.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index b86122b..fbcc37b 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.91 +Version: 0.0.92 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 @@ -40,6 +40,7 @@ A smart traffic control manager to manage traffic counting and bandwidth limitat Summary: STC manager application status plugin BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(syspopup-caller) +Requires: stc-manager-plugin-monitor %description plugin-appstatus A smart traffic control manager extension for application status plugin @@ -47,12 +48,14 @@ A smart traffic control manager extension for application status plugin %package plugin-exception Summary: STC manager exception list plugin BuildRequires: pkgconfig(pkgmgr-info) +Requires: stc-manager-plugin-monitor %description plugin-exception A smart traffic control manager extension for exception list plugin %package plugin-procfs Summary: STC manager exception proc file system plugin +Requires: stc-manager-plugin-monitor %description plugin-procfs A smart traffic control manager extension for proc file system plugin @@ -66,6 +69,7 @@ A smart traffic control manager extension for packet capture plugin %package plugin-tether Summary: Tethering plugin for data usage of tethering clients +Requires: stc-manager-plugin-monitor %description plugin-tether A smart traffic control manager extension for tethering client data usage plugin -- 2.7.4 From d86257fc63b36492d2675bd6063935bf2badca0b Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Tue, 21 May 2019 11:25:31 +0900 Subject: [PATCH 03/16] Remove realpath check to create file Change-Id: I9b9c80aaad07f403c8712aa1ce2b4770450f6aba Signed-off-by: hyunuktak --- src/helper/helper-file.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/helper/helper-file.c b/src/helper/helper-file.c index 53dcad0..e2f284f 100755 --- a/src/helper/helper-file.c +++ b/src/helper/helper-file.c @@ -23,15 +23,10 @@ int fwrite_str(const char *path, const char *str) { _cleanup_fclose_ FILE *f = NULL; int ret; - char * t; assert(path); assert(str); - t = realpath(path, NULL); - ret_value_if(!t, -errno); - free(t); - f = fopen(path, "w"); ret_value_if(!f, -errno); -- 2.7.4 From 0ce9aca0bd562d6baa82e9a936d461b6238851f8 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Fri, 24 May 2019 17:14:09 +0900 Subject: [PATCH 04/16] Remove gvariant free for dauble free Change-Id: Ia3ed9d4ae536019ec735aaa02643a1258d2cb826 Signed-off-by: hyunuktak --- packaging/stc-manager.spec | 2 +- plugin/monitor/stc-plugin-monitor-connection.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index fbcc37b..55396af 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.92 +Version: 0.0.93 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index 010a6f2..1988a43 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -445,10 +445,6 @@ static stc_error_e __get_connected_profiles(GDBusConnection *connection) } g_connection_list = g_slist_append(g_connection_list, conn); - - g_free(object_path); - g_variant_iter_free(next); - continue; } } -- 2.7.4 From 8a8f25acc1b7375d54252e26819925ba84357e84 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Mon, 8 Jul 2019 20:31:13 +0900 Subject: [PATCH 05/16] Delete meaningless configuration Change-Id: I7800cb6dc01ab510bbd3bae125b6e7684f3bb375 --- resources/dbus/net.stc-manager.service | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/dbus/net.stc-manager.service b/resources/dbus/net.stc-manager.service index 13f4097..e5f96c4 100755 --- a/resources/dbus/net.stc-manager.service +++ b/resources/dbus/net.stc-manager.service @@ -1,5 +1,4 @@ [D-BUS Service] Name=net.stc Exec=/bin/false -User=root SystemdService=stc-manager.service -- 2.7.4 From 6e941f446a33913f02b02ffa42836dc4e48936ce Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Tue, 9 Jul 2019 14:53:05 +0530 Subject: [PATCH 06/16] Add support of app_id in GetAll method call on statistics interface Change-Id: I8afdfedd60ee2ce1b6708eec4034119dd405f85a Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- src/database/include/table-statistics.h | 3 ++- src/database/tables/table-statistics.c | 12 +++++++++--- src/stc-statistics.c | 9 ++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 55396af..4228bd8 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.93 +Version: 0.0.94 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/database/include/table-statistics.h b/src/database/include/table-statistics.h index 284fb48..a510f32 100755 --- a/src/database/include/table-statistics.h +++ b/src/database/include/table-statistics.h @@ -37,6 +37,7 @@ typedef struct { } table_statistics_reset_rule; typedef struct { + char *app_id; time_t from; time_t to; stc_iface_type_e iftype; @@ -55,7 +56,7 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul void *user_data); stc_error_e table_statistics_per_app(const char *app_id, - table_statistics_select_rule *rule, + const table_statistics_select_rule *rule, table_statistics_info_cb info_cb, void *user_data); diff --git a/src/database/tables/table-statistics.c b/src/database/tables/table-statistics.c index 719b9a2..7d13a3f 100755 --- a/src/database/tables/table-statistics.c +++ b/src/database/tables/table-statistics.c @@ -440,13 +440,19 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul bind parameters in the query */ stc_db_tm_interval_s interval; - memset(&data, 0, sizeof(data)); - if (!rule || !info_cb) { __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } + memset(&data, 0, sizeof(data)); + + if (rule->app_id) { + int ret = table_statistics_per_app(rule->app_id, rule, info_cb, user_data); + __STC_LOG_FUNC_EXIT__; + return ret; + } + /* pick a statement depending on parameters */ if (rule->granularity) { stmt = __is_iftype_defined(rule->iftype) ? @@ -508,7 +514,7 @@ handle_error: } API stc_error_e table_statistics_per_app(const char *app_id, - table_statistics_select_rule *rule, + const table_statistics_select_rule *rule, table_statistics_info_cb info_cb, void *user_data) { diff --git a/src/stc-statistics.c b/src/stc-statistics.c index 0d5a761..9c0559b 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -76,6 +76,11 @@ void __stc_extract_select_rule(const char *key, GVariant *value, rule->iftype = g_variant_get_uint16(value); STC_LOGD("iftype: [%u]", (unsigned int) rule->iftype); + } else if (!g_strcmp0(key, "app_id")) { + gsize length = 0; + rule->app_id = g_variant_dup_string(value, &length); + STC_LOGD("app_id: [%s]", rule->app_id); + } else { STC_LOGD("Unknown select rule"); //LCOV_EXCL_LINE } @@ -277,6 +282,7 @@ gboolean handle_statistics_get_all(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 } @@ -287,12 +293,13 @@ gboolean handle_statistics_get_all(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; } gboolean handle_statistics_init(StcStatistics *object, - GDBusMethodInvocation *invocation) + GDBusMethodInvocation *invocation) { __STC_LOG_FUNC_ENTER__; -- 2.7.4 From 3a79f8e428cc94e355de1248f37c021c6e9c45f8 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Tue, 9 Jul 2019 17:19:15 +0530 Subject: [PATCH 07/16] Add granularity support in GetAll method call on statistics interface Change-Id: Ic70dfb6aa08365175180d8d9f61092022b6641a8 Signed-off-by: Nishant Chaprana --- packaging/stc-manager.spec | 2 +- src/stc-statistics.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 4228bd8..f516dff 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.94 +Version: 0.0.95 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/stc-statistics.c b/src/stc-statistics.c index 9c0559b..a0b5a07 100755 --- a/src/stc-statistics.c +++ b/src/stc-statistics.c @@ -81,6 +81,10 @@ void __stc_extract_select_rule(const char *key, GVariant *value, rule->app_id = g_variant_dup_string(value, &length); STC_LOGD("app_id: [%s]", rule->app_id); + } else if (!g_strcmp0(key, "granularity")) { + rule->granularity = g_variant_get_int32(value); + STC_LOGD("granularity: [%d]", rule->granularity); + } else { STC_LOGD("Unknown select rule"); //LCOV_EXCL_LINE } -- 2.7.4 From fc002a7bf290493bf80001bf477c1c53365191e8 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Fri, 12 Jul 2019 15:11:47 +0200 Subject: [PATCH 08/16] Migrate to openssl 1.1 Change-Id: I6e927cbeaae3c0c7f8b933b5aaf61cf4734b5ea3 --- packaging/stc-manager.spec | 2 +- plugin/monitor/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 55396af..30d4919 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -20,7 +20,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-system-info) -BuildRequires: pkgconfig(openssl) +BuildRequires: pkgconfig(openssl1.1) %if %{?enable_database} == YES BuildRequires: pkgconfig(sqlite3) diff --git a/plugin/monitor/CMakeLists.txt b/plugin/monitor/CMakeLists.txt index d093f06..63b1b9d 100644 --- a/plugin/monitor/CMakeLists.txt +++ b/plugin/monitor/CMakeLists.txt @@ -9,7 +9,7 @@ PKG_CHECK_MODULES(monitor_plugin REQUIRED gio-unix-2.0 glib-2.0 vconf - openssl + openssl1.1 ) FOREACH(flag ${monitor_plugin_CFLAGS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb6a283..35aaafd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST} dlog vconf capi-system-info - openssl + openssl1.1 ) IF("${ENABLE_DATABASE}" STREQUAL "YES") -- 2.7.4 From 6b972771f438a39d01376da90db75012afa3558c Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Wed, 7 Aug 2019 12:23:20 +0900 Subject: [PATCH 09/16] Remove duplicate dependency with implicit dependencies at "Type=dbus" Refs: https://www.freedesktop.org/software/systemd/man/systemd.service.html - Services with Type=dbus set automatically acquire dependencies of type Requires= and After= on dbus.socket. Change-Id: If2f360a5d1014a4e06e9f212bd3383f266fb351d --- resources/systemd/stc-manager.service | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/systemd/stc-manager.service b/resources/systemd/stc-manager.service index e3bce9f..e20402f 100644 --- a/resources/systemd/stc-manager.service +++ b/resources/systemd/stc-manager.service @@ -1,7 +1,5 @@ [Unit] Description=Smart Traffic Control Manager -Requires=dbus.socket -After=dbus.socket [Service] Type=dbus -- 2.7.4 From 39bd4f4e677bdf2d75d5f8ad5cf9bb5cab9f3a7a Mon Sep 17 00:00:00 2001 From: prasadam-p Date: Mon, 12 Aug 2019 12:57:01 +0530 Subject: [PATCH 10/16] Fixed CID 1038526. Moved the log before the pcap_close call to fix USE_AFTER_FREE error. Change-Id: Ie586c93e538c0297cc3dfa5a18719fa21db137f3 Signed-off-by: prashanth prasadam --- plugin/pcap/stc-plugin-pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/pcap/stc-plugin-pcap.c b/plugin/pcap/stc-plugin-pcap.c index 0859700..862a0be 100755 --- a/plugin/pcap/stc-plugin-pcap.c +++ b/plugin/pcap/stc-plugin-pcap.c @@ -1441,8 +1441,8 @@ static gpointer __pcap_thread_func(gpointer data) pcap_loop(pcap_data->handle, 0, __pcap_handler, (u_char *)pcap_data); STC_LOGD("Pcap loop end [%s]", name); + STC_LOGD("Pcap before closing [%p]", pcap_data->handle); pcap_close(pcap_data->handle); - STC_LOGD("Pcap closed [%p]", pcap_data->handle); thread_exit: FREE(name); -- 2.7.4 From 6f2558cb5a4c1e4b7c2d3137cc6d1e67d587f153 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Mon, 12 Aug 2019 10:48:52 +0900 Subject: [PATCH 11/16] Add os upgrade file for database Change-Id: Ia679c169d26d8e9163d385362c08875776abc2ce Signed-off-by: hyunuk.tak --- packaging/stc-manager.spec | 8 ++++++ scripts/500.stc-manager_upgrade.sh | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 scripts/500.stc-manager_upgrade.sh diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 30d4919..2ed5dc0 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -10,6 +10,8 @@ Source0: %{name}-%{version}.tar.gz %define enable_statistics YES %define enable_restriction YES %define database_full_path /opt/usr/dbspace/.stc-manager-datausage.db +%define upgrade_script_filename 500.stc-manager_upgrade.sh +%define upgrade_script_path /usr/share/upgrade/scripts BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) @@ -143,6 +145,10 @@ cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/st 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 +#OS Upgrade +mkdir -p %{buildroot}%{upgrade_script_path} +cp -f scripts/%{upgrade_script_filename} %{buildroot}%{upgrade_script_path} + %files %manifest %{name}.manifest %license LICENSE @@ -168,6 +174,8 @@ cp resources/dbus/net.stc-manager.service %{buildroot}%{_datadir}/dbus-1/system- %{_bindir}/gtest* %endif +%{upgrade_script_path}/%{upgrade_script_filename} + %files plugin-appstatus %manifest %{name}.manifest %attr(644, -,-) %{_datadir}/icons/*.png diff --git a/scripts/500.stc-manager_upgrade.sh b/scripts/500.stc-manager_upgrade.sh new file mode 100644 index 0000000..ad0c84b --- /dev/null +++ b/scripts/500.stc-manager_upgrade.sh @@ -0,0 +1,52 @@ +#!/bin/sh +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +#----------------------------------------------------------------# +# stc-manager patch script for upgrade (4.0 -> the latest tizen) # +#----------------------------------------------------------------# + +if [ "$OLD_VER" = "4.0.0.0" ]; then + sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "alter table restrictions rename column rst_state to rstn_type;" + + sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_lock ( + name TEXT PRIMARY KEY, + state INT + );" + + sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_chains ( + chain TEXT PRIMARY KEY, + target INT, + priority INT + );" + + sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_rules ( + key BIGINT PRIMARY KEY, + chain TEXT NOT NULL, + direction INT, + s_ip_type INT, + d_ip_type INT, + s_port_type INT, + d_port_type INT, + protocol INT, + family INT, + s_ip1 TEXT NOT NULL, + s_ip2 TEXT NOT NULL, + d_ip1 TEXT NOT NULL, + d_ip2 TEXT NOT NULL, + s_port1 INT, + s_port2 INT, + d_port1 INT, + d_port2 INT, + ifname TEXT NOT NULL, + target INT, + log_level INT, + log_prefix TEXT NOT NULL, + nflog_group INT, + nflog_prefix TEXT NOT NULL, + nflog_range INT, + nflog_threshold INT, + identifier TEXT NOT NULL + );" + + sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE INDEX IF NOT EXISTS rules_index ON fw_rules (chain, target);" +fi -- 2.7.4 From 40194410f8b1589c1a3a0a6036a2976ab1a564f6 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Tue, 17 Sep 2019 17:12:33 +0900 Subject: [PATCH 12/16] Remove to check old version from upgrade script Change-Id: Ic6e537737db32b00d5ca625d390035e53092423d Signed-off-by: hyunuk.tak --- packaging/stc-manager.spec | 2 +- scripts/500.stc-manager_upgrade.sh | 80 +++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 2dc6918..69cbe48 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.95 +Version: 0.0.96 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/scripts/500.stc-manager_upgrade.sh b/scripts/500.stc-manager_upgrade.sh index ad0c84b..7c1945e 100644 --- a/scripts/500.stc-manager_upgrade.sh +++ b/scripts/500.stc-manager_upgrade.sh @@ -5,48 +5,46 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin # stc-manager patch script for upgrade (4.0 -> the latest tizen) # #----------------------------------------------------------------# -if [ "$OLD_VER" = "4.0.0.0" ]; then - sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "alter table restrictions rename column rst_state to rstn_type;" +sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "ALTER TABLE restrictions RENAME COLUMN rst_state TO rstn_type;" - sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_lock ( - name TEXT PRIMARY KEY, - state INT - );" +sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_lock ( + name TEXT PRIMARY KEY, + state INT +);" - sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_chains ( - chain TEXT PRIMARY KEY, - target INT, - priority INT - );" +sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_chains ( + chain TEXT PRIMARY KEY, + target INT, + priority INT +);" - sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_rules ( - key BIGINT PRIMARY KEY, - chain TEXT NOT NULL, - direction INT, - s_ip_type INT, - d_ip_type INT, - s_port_type INT, - d_port_type INT, - protocol INT, - family INT, - s_ip1 TEXT NOT NULL, - s_ip2 TEXT NOT NULL, - d_ip1 TEXT NOT NULL, - d_ip2 TEXT NOT NULL, - s_port1 INT, - s_port2 INT, - d_port1 INT, - d_port2 INT, - ifname TEXT NOT NULL, - target INT, - log_level INT, - log_prefix TEXT NOT NULL, - nflog_group INT, - nflog_prefix TEXT NOT NULL, - nflog_range INT, - nflog_threshold INT, - identifier TEXT NOT NULL - );" +sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE TABLE IF NOT EXISTS fw_rules ( + key BIGINT PRIMARY KEY, + chain TEXT NOT NULL, + direction INT, + s_ip_type INT, + d_ip_type INT, + s_port_type INT, + d_port_type INT, + protocol INT, + family INT, + s_ip1 TEXT NOT NULL, + s_ip2 TEXT NOT NULL, + d_ip1 TEXT NOT NULL, + d_ip2 TEXT NOT NULL, + s_port1 INT, + s_port2 INT, + d_port1 INT, + d_port2 INT, + ifname TEXT NOT NULL, + target INT, + log_level INT, + log_prefix TEXT NOT NULL, + nflog_group INT, + nflog_prefix TEXT NOT NULL, + nflog_range INT, + nflog_threshold INT, + identifier TEXT NOT NULL +);" - sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE INDEX IF NOT EXISTS rules_index ON fw_rules (chain, target);" -fi +sqlite3 /opt/usr/dbspace/.stc-manager-datausage.db "CREATE INDEX IF NOT EXISTS rules_index ON fw_rules (chain, target);" -- 2.7.4 From f24d823df9518db56e51f8c89bf03df673a1e316 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Thu, 26 Sep 2019 14:43:05 +0900 Subject: [PATCH 13/16] Fix to appropriate variable for default connection Change-Id: I43a8a7aca0c1fb4f62b3c41dc58ef40359bbeabf Signed-off-by: hyunuk.tak --- plugin/monitor/stc-plugin-monitor-connection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/monitor/stc-plugin-monitor-connection.c b/plugin/monitor/stc-plugin-monitor-connection.c index 1988a43..a305002 100755 --- a/plugin/monitor/stc-plugin-monitor-connection.c +++ b/plugin/monitor/stc-plugin-monitor-connection.c @@ -609,7 +609,7 @@ static void __vconf_key_callback(keynode_t *node, void *user_data) /* add monitoring for tethering if active found */ if (g_default_connection->tether_state == TRUE && g_default_connection->tether_iface.ifname) { __print_tether_connection_info(); - stc_monitor_update_by_connection(&g_default_connection); + stc_monitor_update_by_connection(g_default_connection); stc_plugin_firewall_update(); STC_LOGI("Data monitoring started for tethering iface !"); return; @@ -617,7 +617,7 @@ static void __vconf_key_callback(keynode_t *node, void *user_data) /* remove monitoring for tethering if in-active found */ if (g_default_connection->tether_state == FALSE && g_default_connection->tether_iface.ifname) { - stc_monitor_update_by_connection(&g_default_connection); + stc_monitor_update_by_connection(g_default_connection); g_free(g_default_connection->tether_iface.ifname); g_default_connection->tether_iface.ifname = NULL; g_default_connection->tether_iface.type = STC_IFACE_UNKNOWN; -- 2.7.4 From e9843c98cd3aea6d2a3fd663e8fbae05a01d8fc1 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Thu, 26 Dec 2019 15:00:50 +0900 Subject: [PATCH 14/16] Fix build warnings for gcc 9 Change-Id: I3bd2818c304e7a77987009d296e813d18bade7bb Signed-off-by: Semun Lee --- plugin/pcap/stc-plugin-pcap.c | 2 +- src/helper/helper-nfacct-rule.h | 2 +- src/helper/helper-procfs.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/pcap/stc-plugin-pcap.c b/plugin/pcap/stc-plugin-pcap.c index 862a0be..018254c 100755 --- a/plugin/pcap/stc-plugin-pcap.c +++ b/plugin/pcap/stc-plugin-pcap.c @@ -1153,7 +1153,7 @@ static void __pcap_nflog_tlv_info(const u_char **packet, GString *value; u_int16_t value_len; u_char *value_pos = NULL; - gchar *value_str = NULL; + gchar *value_str = ""; *pktlen -= SIZE_NFLOG_HDR; diff --git a/src/helper/helper-nfacct-rule.h b/src/helper/helper-nfacct-rule.h index 97c9b5e..80b9f83 100755 --- a/src/helper/helper-nfacct-rule.h +++ b/src/helper/helper-nfacct-rule.h @@ -25,7 +25,7 @@ #include "helper-nl.h" -#define NFACCT_NAME_MAX 32 +#define NFACCT_NAME_MAX 64 typedef enum { NFACCT_COUNTER_UNKNOWN, diff --git a/src/helper/helper-procfs.c b/src/helper/helper-procfs.c index 8cd0461..60e5db2 100644 --- a/src/helper/helper-procfs.c +++ b/src/helper/helper-procfs.c @@ -79,7 +79,8 @@ API int proc_get_cmdline(pid_t pid, char *cmdline) filename = filename + 1; } - strncpy(cmdline, filename, PROC_NAME_MAX-1); + strncpy(cmdline, filename, PROC_NAME_MAX - 1); + cmdline[PROC_NAME_MAX - 1] = '\0'; return STC_ERROR_NONE; } -- 2.7.4 From dc036545f577295486ea444743738e0352a885fe Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Fri, 31 Jan 2020 11:00:03 +0900 Subject: [PATCH 15/16] Fix ABI issue for app state and roaming Change-Id: Ib6bf8400e20adfed0fa98781fb19bc131995e0a6 Signed-off-by: hyunuk.tak --- include/stc-manager.h | 7 ++++--- plugin/monitor/stc-plugin-monitor-app.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/stc-manager.h b/include/stc-manager.h index bc2047f..cfa2404 100755 --- a/include/stc-manager.h +++ b/include/stc-manager.h @@ -133,8 +133,8 @@ typedef enum { */ typedef enum { STC_APP_STATE_UNKNOWN, - STC_APP_STATE_FOREGROUND, /** < foreground state */ - STC_APP_STATE_BACKGROUND, /** < background state */ + STC_APP_STATE_FOREGROUND = 1 << 1, /** < foreground state */ + STC_APP_STATE_BACKGROUND = 1 << 2, /** < background state */ STC_APP_STATE_LAST_ELEM } stc_app_state_e; @@ -179,8 +179,9 @@ typedef enum { * @brief Network roaming type */ typedef enum { - STC_ROAMING_DISABLE, /**< not in roaming */ + STC_ROAMING_UNKNOWN, STC_ROAMING_ENABLE, /**< in roaming */ + STC_ROAMING_DISABLE, /**< not in roaming */ } stc_roaming_type_e; /** diff --git a/plugin/monitor/stc-plugin-monitor-app.c b/plugin/monitor/stc-plugin-monitor-app.c index d7b3152..ca4a88f 100755 --- a/plugin/monitor/stc-plugin-monitor-app.c +++ b/plugin/monitor/stc-plugin-monitor-app.c @@ -101,7 +101,7 @@ static void __app_update_statistics(gpointer key, stat.app_id = g_strdup(app_value->app_id); stat.snd_count = app_value->counter.out_bytes; stat.rcv_count = app_value->counter.in_bytes; - stat.is_roaming = conn->roaming; + stat.is_roaming = (conn->roaming == TRUE) ? STC_ROAMING_ENABLE : STC_ROAMING_DISABLE; if (strstr(stat.app_id, "_BACKGROUND")) { stat.ground = STC_APP_STATE_BACKGROUND; -- 2.7.4 From 968e1a84eda591be4e85b02902e5455434be53bd Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Mon, 17 Feb 2020 21:52:00 +0900 Subject: [PATCH 16/16] Replaced strncpy() with g_strlcpy() in helper-procfs.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit strncpy doesn’t set zero byte implicitly. Change-Id: I45f322916017d2b727902e713284d0e8ffa19fad Signed-off-by: Jaehyun Kim --- src/helper/helper-procfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/helper-procfs.c b/src/helper/helper-procfs.c index 60e5db2..a0d9f0e 100644 --- a/src/helper/helper-procfs.c +++ b/src/helper/helper-procfs.c @@ -259,7 +259,7 @@ API int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX]) if (token != NULL) { while (isspace((unsigned char)*token)) token++; - strncpy(status[index], token, + g_strlcpy(status[index], token, sizeof(status[index])); updated[index] = TRUE; } -- 2.7.4