Fix Wformat build error
[platform/core/connectivity/stc-manager.git] / src / stc-manager.c
old mode 100755 (executable)
new mode 100644 (file)
index 00854ea..f0d7e57
@@ -26,6 +26,7 @@
 #include "helper-cgroup.h"
 #include "helper-nfacct-rule.h"
 #include "helper-iptables.h"
+#include "helper-inotify.h"
 #include "stc-monitor.h"
 #include "stc-firewall.h"
 #include "stc-manager-plugin-appstatus.h"
@@ -36,7 +37,6 @@
 
 static stc_s *g_stc = NULL;
 
-/*
 static gboolean __validate_ident(const char *ident)
 {
        unsigned int i;
@@ -50,7 +50,22 @@ static gboolean __validate_ident(const char *ident)
 
        return TRUE;
 }
-*/
+
+static void __stc_inotify_handler(struct inotify_event *event, const char *ident)
+{
+       if (!ident)
+               return;
+
+       if (!__validate_ident(ident)) {
+               STC_LOGE("Invalid ident [%s]", ident);
+               return;
+       }
+
+       if (!g_strcmp0(ident, INFO_CONFIG)) {
+               int debug = stc_util_get_config_int(INFO_DEBUGLOG);
+               stc_util_set_debuglog(debug);
+       }
+}
 
 static void __stc_manager_deinit(void)
 {
@@ -76,6 +91,9 @@ static void __stc_manager_deinit(void)
        stc_plugin_exception_deinit();
        stc_plugin_procfs_deinit();
 
+       inotify_deregister(INFO_STORAGE_DIR);
+       inotify_deinitialize();
+
        STC_LOGI("stc manager deinitialized");
        FREE(g_stc);
        __STC_LOG_FUNC_EXIT__;
@@ -96,6 +114,9 @@ static stc_s *__stc_manager_init(void)
 
        stc_util_initialize_config();
 
+       inotify_initialize();
+       inotify_register(INFO_STORAGE_DIR, __stc_inotify_handler);
+
        cgroup_set_release_agent(NET_CLS_SUBSYS, NET_RELEASE_AGENT);
 
        EXEC(STC_ERROR_NONE, stc_db_initialize());
@@ -155,7 +176,7 @@ int stc_commit_iptables(char *cmd, int *err_num, char **err_str)
        if (pid == 0) {
                errno = 0;
                if (execv(args[0], args) == -1) {
-                       STC_LOGE("Failed to execute [%s]", err_str);
+                       STC_LOGE("Failed to execute [%s]", *err_str);
                        g_strfreev(args);
                        exit(-1);
                }