* limitations under the License.
*/
+#include <signal.h>
#include "stc-manager.h"
-#include "stc-statistics.h"
-#include "stc-restriction.h"
+#include "stc-emulator.h"
#include "stc-manager-gdbus.h"
#include "stc-db.h"
#include "counter.h"
#include "table-restrictions.h"
#include "helper-cgroup.h"
#include "helper-nfacct-rule.h"
+#include "helper-inotify.h"
#include "stc-monitor.h"
+#include "stc-manager-plugin.h"
+#include "stc-app-lifecycle.h"
static stc_s *g_stc = NULL;
+static gboolean __validate_ident(const char *ident)
+{
+ unsigned int i;
+
+ if (!ident)
+ return FALSE;
+
+ for (i = 0; i < strlen(ident); ++i)
+ if (!g_ascii_isprint(ident[i]))
+ return FALSE;
+
+ 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 (event->mask & IN_MODIFY) {
+ if (!g_strcmp0(ident, INFO_CONFIG)) {
+ int debug = 0;
+ debug = stc_util_get_config_int(INFO_DEBUGLOG);
+ stc_util_set_debuglog(debug);
+ }
+ }
+}
+
static void __stc_manager_deinit(void)
{
__STC_LOG_FUNC_ENTER__;
stc_monitor_deinit();
stc_deinit_db_guard();
stc_db_deinitialize();
+
stc_manager_gdbus_deinit((gpointer)g_stc);
+ stc_app_lifecycle_monitor_deinit();
+ stc_manager_plugin_deinit();
+
+ inotify_deregister(INFO_STORAGE_DIR);
+ inotify_deinitialize();
STC_LOGI("stc manager deinitialized");
FREE(g_stc);
{
__STC_LOG_FUNC_ENTER__;
stc_s *stc;
+ stc_error_e err = STC_ERROR_NONE;
stc = MALLOC0(stc_s, 1);
if (!stc) {
}
g_stc = stc;
+ 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());
- stc_monitor_init();
+ err = stc_monitor_init();
+ if (err != STC_ERROR_NONE)
+ goto handle_error;
+
+ stc_manager_plugin_init();
+ stc_app_lifecycle_monitor_init();
stc_manager_gdbus_init((gpointer)stc);
STC_LOGI("stc manager initialized");
g_type_init();
#endif
- 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;
+
+ stc_emulator_check_environment();
+ if (stc_emulator_is_emulated() == FALSE) {
+ g_stc = __stc_manager_init();
+ if (!g_stc)
+ goto fail;
+ g_stc->main_loop = main_loop;
+ }
/* Run the main loop */
g_main_loop_run(main_loop);
ret = 0;
fail:
- __stc_manager_deinit();
+ if (stc_emulator_is_emulated() == FALSE)
+ __stc_manager_deinit();
if (main_loop)
g_main_loop_unref(main_loop);