From 420b163ee31fce410d7518a7b7c028a34c14a1cc Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Fri, 9 Jun 2017 09:58:52 +0900 Subject: [PATCH 01/16] Get launch-on-event items for default user - At first, get the launch-on-event items for default user. - Listen UserSessionStartupFinished signal and update launch-on-event items if another user is activated. Change-Id: I70336e21bdf4123429ef478dc0b94bb1999c10b8 Signed-off-by: Jiwoong Im --- include/eventsystem_daemon.h | 1 + src/esd_main.c | 99 ++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/include/eventsystem_daemon.h b/include/eventsystem_daemon.h index 56f44a0..a5aaa8f 100644 --- a/include/eventsystem_daemon.h +++ b/include/eventsystem_daemon.h @@ -46,6 +46,7 @@ extern "C" { #define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager" #define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1" #define SYSTEMD_DBUS_SIGNAL_STARTUP_FINISHED "StartupFinished" +#define SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED "UserSessionStartupFinished" int __esd_register_vconf_callbacks(void); diff --git a/src/esd_main.c b/src/esd_main.c index b7f7eac..8e70da8 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -21,6 +21,7 @@ #include #include "eventsystem_daemon.h" +#define DEFAULT_USER tzplatform_getuid(TZ_SYS_DEFAULT_USER) #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) #define ROOT_USER 0 @@ -978,58 +979,42 @@ static int __esd_dbus_name_monitor(GDBusConnection *connection) return ES_R_OK; } -static int __esd_get_user_items(void) +static int __esd_get_user_items(uid_t uid) { int ret = 0; - int i = 0; - uid_t *uids = NULL; - uid_t cur_uid = 0; pkgmgrinfo_appinfo_filter_h handle = NULL; - ret = sd_get_uids(&uids); + _I("get user items for uid(%d)", uid); + /* reset user's item */ + __esd_launch_table_remove_private_usr_items(); + + ret = pkgmgrinfo_appinfo_filter_create(&handle); if (ret < 0) { - _E("failed to get uids (%d)", ret); + _E("failed to create appinfo filter"); return ES_R_ERROR; } - - if (ret == 0 || uids == NULL) { - _I("there is no uid for now"); - } else { - /* reset user's item */ - __esd_launch_table_remove_private_usr_items(); - for (i = 0; i < ret; i++) { - cur_uid = uids[i]; - _I("found uid(%d)", cur_uid); - - ret = pkgmgrinfo_appinfo_filter_create(&handle); - if (ret < 0) { - _E("failed to create appinfo filter"); - return ES_R_ERROR; - } - ret = pkgmgrinfo_appinfo_filter_add_string(handle, - PMINFO_APPINFO_PROP_APP_COMPONENT, "svcapp"); - if (ret < 0) { - _E("failed to add appinfo filter string"); - pkgmgrinfo_appinfo_filter_destroy(handle); - return ES_R_ERROR; - } - ret = pkgmgrinfo_appinfo_filter_add_string(handle, - PMINFO_APPINFO_PROP_APP_OPERATION, APPSVC_OPERATION_LAUNCH_ON_EVENT); - if (ret < 0) { - _E("failed to add appinfo filter string"); - pkgmgrinfo_appinfo_filter_destroy(handle); - return ES_R_ERROR; - } - ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, - __esd_add_appinfo_handler, &cur_uid, cur_uid); - if (ret < 0) { - _E("appinfo filter foreach error"); - pkgmgrinfo_appinfo_filter_destroy(handle); - return ES_R_ERROR; - } - pkgmgrinfo_appinfo_filter_destroy(handle); - } + ret = pkgmgrinfo_appinfo_filter_add_string(handle, + PMINFO_APPINFO_PROP_APP_COMPONENT, "svcapp"); + if (ret < 0) { + _E("failed to add appinfo filter string"); + pkgmgrinfo_appinfo_filter_destroy(handle); + return ES_R_ERROR; } + ret = pkgmgrinfo_appinfo_filter_add_string(handle, + PMINFO_APPINFO_PROP_APP_OPERATION, APPSVC_OPERATION_LAUNCH_ON_EVENT); + if (ret < 0) { + _E("failed to add appinfo filter string"); + pkgmgrinfo_appinfo_filter_destroy(handle); + return ES_R_ERROR; + } + ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, + __esd_add_appinfo_handler, &uid, uid); + if (ret < 0) { + _E("appinfo filter foreach error"); + pkgmgrinfo_appinfo_filter_destroy(handle); + return ES_R_ERROR; + } + pkgmgrinfo_appinfo_filter_destroy(handle); __esd_launch_table_print_items(); @@ -1046,6 +1031,7 @@ static void __esd_signal_handler(GDBusConnection *connection, { int handle; bundle *b; + guint64 uid = 0; if (!g_strcmp0(signal_name, SYSTEMD_DBUS_SIGNAL_STARTUP_FINISHED)) { @@ -1060,6 +1046,12 @@ static void __esd_signal_handler(GDBusConnection *connection, handle = creat(ESD_BOOT_COMPLETED, 0640); if (handle != -1) close(handle); + } else if (!g_strcmp0(signal_name, + SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED)) { + g_variant_get(parameters, "(t)", &uid); + _I("User session finished uid : %d", uid); + if ((uid_t)uid != DEFAULT_USER) + __esd_get_user_items((uid_t)uid); } } @@ -1655,6 +1647,7 @@ static void __esd_on_bus_acquired(GDBusConnection *connection, guint reg_id = 0; guint boot_id = 0; + guint user_boot_id = 0; GError *error = NULL; reg_id = g_dbus_connection_register_object(connection, @@ -1682,6 +1675,22 @@ static void __esd_on_bus_acquired(GDBusConnection *connection, _E("g_dbus_connection_signal_subscribe() is failed."); g_object_unref(connection); } + + user_boot_id = g_dbus_connection_signal_subscribe(connection, + NULL, + SYSTEMD_DBUS_IFACE_MANAGER, + SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED, + SYSTEMD_DBUS_PATH, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + __esd_signal_handler, + NULL, + NULL); + + if (user_boot_id == 0) { + _E("g_dbus_connection_signal_subscribe() is failed."); + g_object_unref(connection); + } } static void __esd_on_name_acquired(GDBusConnection *connection, @@ -1703,7 +1712,7 @@ static void __esd_on_name_acquired(GDBusConnection *connection, __esd_trusted_busname_print_items(); - __esd_get_user_items(); + __esd_get_user_items(DEFAULT_USER); __esd_dbus_name_monitor(connection); } -- 2.7.4 From ed48e2cae0ef38c5e5bef2013c2800c1ebf9a437 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Tue, 13 Jun 2017 13:46:11 +0900 Subject: [PATCH 02/16] Release version 0.1.3 Changes: - Remove unnecessarily strictt dependency on dbus.service - Fix invalid log format - Get launch-on-event items for default user Change-Id: I8ddac8d2377e8d1eb25634ace79b007b7c69018d Signed-off-by: Jiwoong Im --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index e56eb2a..6ae397f 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.2 +Version: 0.1.3 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From cc753f4b3b54fdb94723ca81cb0688f1d8cfcca2 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Mon, 26 Jun 2017 11:04:29 +0900 Subject: [PATCH 03/16] Fix invalid log format Change-Id: Ia155634c3b362ba8d7cdc9a26598682e2fbeb22d Signed-off-by: Jiwoong Im --- src/esd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esd_main.c b/src/esd_main.c index 8e70da8..a4cd99a 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -1049,7 +1049,7 @@ static void __esd_signal_handler(GDBusConnection *connection, } else if (!g_strcmp0(signal_name, SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED)) { g_variant_get(parameters, "(t)", &uid); - _I("User session finished uid : %d", uid); + _I("User session finished uid : %d", (int)uid); if ((uid_t)uid != DEFAULT_USER) __esd_get_user_items((uid_t)uid); } -- 2.7.4 From 4e0489f86edd3b15040fd357780f51a9fd6106a8 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Fri, 7 Jul 2017 09:52:45 +0900 Subject: [PATCH 04/16] Release version 0.1.4 Changes: - Fix invalid log format Change-Id: I2cfbec617dae12f9994e7a465276f30d9800559e Signed-off-by: Jiwoong Im --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index 6ae397f..dd6731b 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.3 +Version: 0.1.4 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From e19a781652600371cb890496d73d8d15b3e2df22 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Fri, 21 Jul 2017 13:52:44 +0900 Subject: [PATCH 05/16] Add null check in __esd_appcontrol_cb - Add null check of uri in __esd_appcontrol_cb Change-Id: I77bca91456a842186721f9d059d6cae94abb3caf Signed-off-by: Jiwoong Im --- src/esd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esd_main.c b/src/esd_main.c index a4cd99a..784a514 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -1913,7 +1913,7 @@ static int __esd_appcontrol_cb(const char *operation, uid, appid, pkgid, operation, uri, mime); if (!strcmp(operation, APPSVC_OPERATION_LAUNCH_ON_EVENT)) { - if (!strncmp(uri, prefix, strlen(prefix))) { + if (uri && !strncmp(uri, prefix, strlen(prefix))) { event_name = strdup(&uri[8]); if (event_name) { _D("appid(%s), event_name(%s)", appid, event_name); -- 2.7.4 From 27b2108b650d2f2e5db81223c511f24bfd7c4849 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Fri, 21 Jul 2017 11:15:59 +0900 Subject: [PATCH 06/16] Add wifi event for launch on event - Add SYS_EVENT_WIFI_STATE event to launch on event list. Change-Id: I1699b73fb0fe78001c796534729508d40b9ac787 Signed-off-by: Jiwoong Im --- src/esd_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/esd_main.c b/src/esd_main.c index 784a514..40987f2 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -36,7 +36,8 @@ static const char *event_launch_support_list[] = { SYS_EVENT_USB_STATUS, SYS_EVENT_EARJACK_STATUS, SYS_EVENT_INCOMMING_MSG, - SYS_EVENT_OUTGOING_MSG + SYS_EVENT_OUTGOING_MSG, + SYS_EVENT_WIFI_STATE }; struct privilege_info { @@ -823,6 +824,13 @@ static void __esd_launch_event_handler(char *event_name, bundle *data, void *use _D("msg_id(%s)", msg_id); if (msg_id == NULL) return; + } else if (strcmp(SYS_EVENT_WIFI_STATE, event_name) == 0) { + val = bundle_get_val(data, EVT_KEY_WIFI_STATE); + if (val == NULL) + return; + _D("wifi_state(%s)", val); + if (strcmp(EVT_VAL_WIFI_CONNECTED, val) != 0) + return; } eep = calloc(1, sizeof(esd_event_param)); -- 2.7.4 From ebbd7f0b72f4043825c9666a072c40f2daf11eb5 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Tue, 1 Aug 2017 14:54:26 +0900 Subject: [PATCH 07/16] Release version 0.1.5 Changes: - Add null check in __esd_appcontrol_cb - Add wifi event for launch on event Change-Id: I474a4d12a04523eee83ca60a7d997de3bf43d3e8 Signed-off-by: Jiwoong Im --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index dd6731b..fa4231c 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.4 +Version: 0.1.5 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From 930baf75b3ad8731dd37fb5a69fcb7b63996bd7c Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 12 Sep 2017 13:56:16 +0900 Subject: [PATCH 08/16] Adjust coding rule ERROR: do not initialise statics to 0 or NULL Signed-off-by: Seungha Son Change-Id: I2e7a31bde8f3273fec33ccc446cbf680b332ab2c --- src/esd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esd_main.c b/src/esd_main.c index 40987f2..2ea6dba 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -142,7 +142,7 @@ typedef struct __esd_appctrl_cb_data { static void __esd_event_handler(char *event_name, bundle *data, void *user_data); static int __esd_add_appinfo_handler(const pkgmgrinfo_appinfo_h handle, void *data); -static cynara *r_cynara = NULL; +static cynara *r_cynara; static int __esd_init_cynara(void) { -- 2.7.4 From eee2674479a64eecb57fa69300c0c35d302e2f39 Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Wed, 13 Sep 2017 11:18:56 +0900 Subject: [PATCH 09/16] fix coding rule error Change-Id: I84a63051517f849c35c25bc734bccf91b9d30c6a --- src/esd_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/esd_main.c b/src/esd_main.c index 2ea6dba..1655228 100644 --- a/src/esd_main.c +++ b/src/esd_main.c @@ -264,9 +264,8 @@ static int __get_sender_uid(GDBusConnection *conn, const char *sender_name) int uid = -1; uid = __get_sender_unixinfo(conn, sender_name, "GetConnectionUnixUser"); - if (uid < 0) { + if (uid < 0) _E("failed to get uid"); - } _D("sender_name(%s), uid(%d)", sender_name, uid); -- 2.7.4 From c5c186432cf1ede55b7bf74deaa4de1adc2775dd Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 15 Sep 2017 11:25:04 +0900 Subject: [PATCH 10/16] Release version 0.1.6 Changes: - Adjust coding rule - fix coding rule error Change-Id: Iced4251908469b6f010ed86f6c6168a55c9b7c47 Signed-off-by: Semun Lee --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index fa4231c..7faf4ee 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.5 +Version: 0.1.6 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From efc4493bf328d613d3d6091535660aa584b2e8bb Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Wed, 28 Mar 2018 16:29:05 +0900 Subject: [PATCH 11/16] Add RELRO for excutables Change-Id: Ibea807acd545b31250d108edeb026e98e823e556 Signed-off-by: Inkyun Kil --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68006e9..3936be4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") add_executable(esd ${SRCS}) TARGET_LINK_LIBRARIES(esd eventsystem pkgmgr-client ${pkgs_LDFLAGS}) SET_TARGET_PROPERTIES(esd PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE") -SET_TARGET_PROPERTIES(esd PROPERTIES LINK_FLAGS "-pie") +SET_TARGET_PROPERTIES(esd PROPERTIES LINK_FLAGS "-pie -Wl,-z,relro") # pkgconfig file configure_file(esd.manifest.in esd.manifest @ONLY) -- 2.7.4 From 6ab8f10a278956415ed91a58e2d8d50a52a8f5ac Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Wed, 4 Apr 2018 10:57:11 +0900 Subject: [PATCH 12/16] Release version 0.1.7 Changes: - Add RELRO for excutables Change-Id: I8d2848fc5391aeebe0c628bf83ad444568b51728 Signed-off-by: Inkyun Kil --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index 7faf4ee..87f811a 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.6 +Version: 0.1.7 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From a5df67a23f11d6a6442df8b94ee09eabb557850d Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Tue, 17 Apr 2018 19:18:22 +0900 Subject: [PATCH 13/16] Change rules for default dbus policy Change-Id: I611704d1d12f021984290352de382a06ee950b9f Signed-off-by: Inkyun Kil --- eventsystem.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eventsystem.conf b/eventsystem.conf index 48953d2..5252e86 100644 --- a/eventsystem.conf +++ b/eventsystem.conf @@ -4,6 +4,8 @@ + + @@ -13,6 +15,10 @@ + + + + -- 2.7.4 From 06d67d53b784caff819e401932c524a87f530e87 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Wed, 2 May 2018 14:20:55 +0900 Subject: [PATCH 14/16] Release version 0.1.8 Changes: - Change rules for default dbus policy Change-Id: I557787a2a8c27b0ec9a6a46412f595b183d1dd1f Signed-off-by: Inkyun Kil --- packaging/esd.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/esd.spec b/packaging/esd.spec index 87f811a..2f81b4f 100644 --- a/packaging/esd.spec +++ b/packaging/esd.spec @@ -1,6 +1,6 @@ Name: esd Summary: Event system daemon -Version: 0.1.7 +Version: 0.1.8 Release: 1 Group: Application Framework/Service License: Apache-2.0 -- 2.7.4 From bba6ba5bf1be1936faa925845694e2d631d484c3 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Tue, 15 May 2018 14:25:46 +0900 Subject: [PATCH 15/16] Add allow rule for dbus-policy Change-Id: I2ffb1aa6e0644da7548d69c7f14ba066d81bdcbb Signed-off-by: Inkyun Kil --- eventsystem.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/eventsystem.conf b/eventsystem.conf index 5252e86..f10352a 100644 --- a/eventsystem.conf +++ b/eventsystem.conf @@ -18,6 +18,7 @@ + -- 2.7.4 From db77850e1ffcc417b5a407e1c954b4df22866d8a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 27 Jun 2018 19:16:51 +0900 Subject: [PATCH 16/16] Add a dependency on the service file RequiresMountsFor=/opt/usr is added. Change-Id: Icd39c5f5ff906ae0bca1fdbc859485bb64e9a7f5 Signed-off-by: Hwankyu Jhun --- packaging/esd.service | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/esd.service b/packaging/esd.service index cd5f3ca..21c1cde 100644 --- a/packaging/esd.service +++ b/packaging/esd.service @@ -1,5 +1,6 @@ [Unit] Description=Start the Event System Daemon +RequiresMountsFor=/opt/usr [Service] User=app_fw -- 2.7.4