From 116e97e01cc23de2f3f1838d958a549f279bf3e6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Aug 2017 07:48:13 +0900 Subject: [PATCH 01/16] Release version 0.3.1 Changes: - Fix log format Change-Id: I3979f462307cee834fd4e447e8614c9857d69349 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 17c31e6..a71aa62 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.0 +Version: 0.3.1 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From ba33154eeb786c51fdd4a6daaab40686c1432fc0 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Tue, 18 Jul 2017 14:55:52 +0200 Subject: [PATCH 02/16] Add CAP_SYS_ADMIN capability Launchpad need additional capability to unshare mount namespace. Change-Id: I96277437b689c32683e46556d79b12cbb3d6e213 --- packaging/launchpad.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index a71aa62..3f9ddbf 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -106,9 +106,9 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %{_unitdir_user}/sockets.target.wants/launchpad-process-pool.socket %{_unitdir_user}/basic.target.wants/launchpad-process-pool.service %if 0%{?tizen_feature_priority_change} || 0%{?tizen_feature_loader_priority} -%caps(cap_mac_admin,cap_dac_override,cap_setgid,cap_sys_nice=ei) %{_bindir}/launchpad-process-pool +%caps(cap_mac_admin,cap_dac_override,cap_setgid,cap_sys_admin,cap_sys_nice=ei) %{_bindir}/launchpad-process-pool %else -%caps(cap_mac_admin,cap_dac_override,cap_setgid=ei) %{_bindir}/launchpad-process-pool +%caps(cap_mac_admin,cap_dac_override,cap_setgid,cap_sys_admin=ei) %{_bindir}/launchpad-process-pool %endif %attr(0644,root,root) %{_libdir}/liblaunchpad.so.* @@ -122,7 +122,7 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %license LICENSE %{_prefix}/share/aul/default.loader %if 0%{?tizen_feature_priority_change} || 0%{?tizen_feature_loader_priority} -%caps(cap_setgid,cap_sys_nice=ei) %{_bindir}/launchpad-loader +%caps(cap_setgid,cap_sys_admin,cap_sys_nice=ei) %{_bindir}/launchpad-loader %else -%caps(cap_setgid=ei) %{_bindir}/launchpad-loader +%caps(cap_setgid,cap_sys_admin=ei) %{_bindir}/launchpad-loader %endif -- 2.7.4 From 42ac47919df8a674a440f4ff7ef594e356dbc761 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 28 Aug 2017 08:17:12 +0900 Subject: [PATCH 03/16] Release version 0.3.2 Changes: - Add CAP_SYS_ADMIN capability Change-Id: Icdab9561533a0bcbba1fb91cb86bc49fe5fd1b40 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 3f9ddbf..2e5d5ab 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.1 +Version: 0.3.2 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b22fcb1814a94c8071db62c4a8baa70354f2250c Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Mon, 28 Aug 2017 15:06:13 +0900 Subject: [PATCH 04/16] Add Obsoletes dependency to amd-mod-launchpad When launchpad is installed, amd-mod-launchpad is useless and should be removed. Change-Id: Ie76ef1fad081c7c0d70426aa6a7906d3bcf394fb Signed-off-by: Semun Lee --- packaging/launchpad.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 2e5d5ab..fdaee17 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -30,6 +30,8 @@ Requires(postun): /sbin/ldconfig Requires(postun): /usr/bin/systemctl Requires(preun): /usr/bin/systemctl +Obsoletes: amd-mod-launchpad + %define tizen_feature_priority_change 0 %define tizen_feature_loader_priority 0 %ifarch armv7l i586 -- 2.7.4 From bfe6e3983aa4ebb75b1721f3c0ef4cb3885d2e41 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 28 Aug 2017 15:12:33 +0900 Subject: [PATCH 05/16] Release version 0.3.3 Changes: - Add Obsoletes dependency to amd-mod-launchpad Change-Id: I53f49b5fc94287462ae7554d01687e3e0ac5b320 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index fdaee17..26e8c42 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.2 +Version: 0.3.3 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 0be2f3895e946fb278530e25af49be0bd40ea2e5 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 23 Aug 2017 15:41:58 +0900 Subject: [PATCH 06/16] Set environment variable LANG - Before calling main(), this variable should be set. Change-Id: I65fa6a7a709cac85e41475dd878496653d239eec Signed-off-by: Junghoon Park --- src/launchpad.c | 19 +++++++++++++++++++ src/launchpad_lib.c | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/launchpad.c b/src/launchpad.c index 69f841c..8288d4c 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1775,9 +1775,18 @@ static void __vconf_cb(keynode_t *key, void *data) } } +static void __update_lang(keynode_t *node, void *user_data) +{ + char *lang = vconf_keynode_get_str(node); + + if (lang) + setenv("LANG", lang, 1); +} + static int __before_loop(int argc, char **argv) { int ret; + char *lang; ret = __init_sigchild_fd(); if (ret != 0) { @@ -1804,6 +1813,16 @@ static int __before_loop(int argc, char **argv) VCONFKEY_SETAPPL_APP_HW_ACCELERATION); } + lang = vconf_get_str(VCONFKEY_LANGSET); + if (lang) { + setenv("LANG", lang, 1); + free(lang); + } + + ret = vconf_notify_key_changed(VCONFKEY_LANGSET, __update_lang, NULL); + if (ret != 0) + _E("Failed to register callback for %s", VCONFKEY_LANGSET); + ret = __init_label_monitor_fd(); if (ret != 0) _W("Failed to initialize label monitor"); diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index d1a3b89..183bd71 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "launchpad_common.h" #include "launchpad.h" @@ -269,6 +270,14 @@ static void __receiver_cb(int fd) } } +static void __update_lang(keynode_t *node, void *user_data) +{ + char *lang = vconf_keynode_get_str(node); + + if (lang) + setenv("LANG", lang, 1); +} + static int __before_loop(int argc, char **argv) { int client_fd; @@ -310,11 +319,16 @@ static int __before_loop(int argc, char **argv) __loader_adapter->add_fd(__loader_user_data, client_fd, __receiver_cb); + if (vconf_notify_key_changed(VCONFKEY_LANGSET, __update_lang, NULL) != 0) + _E("vconf_notify_key_changed failed"); + return ret; } static int __after_loop(void) { + vconf_ignore_key_changed(VCONFKEY_LANGSET, __update_lang); + if (__loader_callbacks->terminate) { return __loader_callbacks->terminate(__argc, __argv, __loader_user_data); -- 2.7.4 From 19398cc1994e107bb2b4dc296656a4258a5053a3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 29 Aug 2017 13:31:27 +0900 Subject: [PATCH 07/16] Release version 0.3.4 Changes: - Set environment variable LANG Change-Id: I2b1f6731870fac7243e493fb095d550e412287ac Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 26e8c42..944554e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.3 +Version: 0.3.4 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From e69e5bbb0a7b979fe1127a5804a011feec93c3c7 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 15 Sep 2017 13:24:15 +0900 Subject: [PATCH 08/16] Revert "Add Obsoletes dependency to amd-mod-launchpad" This reverts commit b22fcb1814a94c8071db62c4a8baa70354f2250c. Change-Id: I6f79068e78a92d7d3c685386129590605f7c9721 Signed-off-by: Semun Lee --- packaging/launchpad.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 944554e..971e10c 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -30,8 +30,6 @@ Requires(postun): /sbin/ldconfig Requires(postun): /usr/bin/systemctl Requires(preun): /usr/bin/systemctl -Obsoletes: amd-mod-launchpad - %define tizen_feature_priority_change 0 %define tizen_feature_loader_priority 0 %ifarch armv7l i586 -- 2.7.4 From 941c4a77072ae1757561604bdebd30b70d82d3bd Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 15 Sep 2017 13:28:25 +0900 Subject: [PATCH 09/16] Release version 0.3.5 Changes: - Revert "Add Obsoletes dependency to amd-mod-launchpad" Change-Id: I06c23e1ec85385e0a13bbf983875b6a23e053428 Signed-off-by: Semun Lee --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 971e10c..5eb154b 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.4 +Version: 0.3.5 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 3e34b4cfc1ff787802f423ac36565bc84c07bfa6 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 15 Sep 2017 18:21:47 +0900 Subject: [PATCH 10/16] Provides app-launchpad pseudo package - amd-mod-launchpad and launchpad provides app-launchpad pseudo package - launchpad will be used when both are selected Change-Id: I99690a1ed3f264b130f0d0d568d5bb2557951efb Signed-off-by: Semun Lee --- packaging/launchpad.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 5eb154b..e8aa072 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -30,6 +30,9 @@ Requires(postun): /sbin/ldconfig Requires(postun): /usr/bin/systemctl Requires(preun): /usr/bin/systemctl +Provides: app-launchpad +Obsoletes: amd-mod-launchpad + %define tizen_feature_priority_change 0 %define tizen_feature_loader_priority 0 %ifarch armv7l i586 -- 2.7.4 From 0bb08be21efc759fc6aec1a8458f15bef20b6a87 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Tue, 19 Sep 2017 09:07:08 +0900 Subject: [PATCH 11/16] Release version 0.3.6 Changes: - Provides app-launchpad pseudo package Change-Id: I54bf548fe1c54e97ed91501015186164619bdda9 Signed-off-by: Semun Lee --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index e8aa072..e60c5bc 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.5 +Version: 0.3.6 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 4b08233be2b9381dde4b506a81c49a22f4eb8880 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 13 Oct 2017 12:17:09 +0900 Subject: [PATCH 12/16] Add ON_BOOT tag for skipping loader - To skip making some candidate processes right after booting, the new tag was added Change-Id: If0eebf5920f0bdff2b7e2db97c8fc8a738cda4c2 Signed-off-by: Junghoon Park --- inc/loader_info.h | 1 + src/launchpad.c | 37 ++++++++++++++++++++++++++++++------- src/loader_info.c | 5 +++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/inc/loader_info.h b/inc/loader_info.h index 2e5a21d..a3c58bb 100644 --- a/inc/loader_info.h +++ b/inc/loader_info.h @@ -39,6 +39,7 @@ typedef struct _loader_info { bundle *extra; int cpu_threshold_max; int cpu_threshold_min; + bool on_boot; } loader_info_t; GList *_loader_info_load(const char *path); diff --git a/src/launchpad.c b/src/launchpad.c index 8288d4c..fc7d8bb 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -85,6 +85,7 @@ typedef struct { int threshold_max; int threshold_min; int cur_event; + bool on_boot; } candidate_process_context_t; typedef struct { @@ -115,7 +116,7 @@ static GList *launcher_info_list; static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *extra, int detection_method, int timeout_val, - int threshold_max, int threshold_min); + int threshold_max, int threshold_min, bool on_boot); static int __remove_slot(int type, int loader_id); static int __add_default_slots(void); static gboolean __handle_idle_checker(gpointer data); @@ -1184,6 +1185,9 @@ static int __add_idle_checker(int detection_method, GList *cur) continue; } + if (detection_method == EVENT_BOOTING && !cpc->on_boot) + continue; + if (cpc->pid == CANDIDATE_NONE && (detection_method == EVENT_BOOTING || (cpc->detection_method & detection_method))) { @@ -1236,7 +1240,8 @@ static int __dispatch_cmd_add_loader(bundle *kb) cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid), add_slot_str, extra, METHOD_TIMEOUT | METHOD_VISIBILITY, 2000, - DEFAULT_CPU_THRESHOLD_MAX, DEFAULT_CPU_THRESHOLD_MIN); + DEFAULT_CPU_THRESHOLD_MAX, DEFAULT_CPU_THRESHOLD_MIN, + false); __set_timer(cpc); return lid; } @@ -1287,7 +1292,8 @@ static bool __is_hw_acc(const char *hwacc) } static candidate_process_context_t *__find_available_slot(const char *hwacc, - const char *app_type, const char *loader_name) + const char *app_type, const char *loader_name, + candidate_process_context_t **org_cpc) { int type; candidate_process_context_t *cpc; @@ -1306,6 +1312,8 @@ static candidate_process_context_t *__find_available_slot(const char *hwacc, if (!cpc) return NULL; + *org_cpc = cpc; + if (cpc->prepared) return cpc; @@ -1335,6 +1343,7 @@ static gboolean __handle_launch_event(gpointer data) app_pkt_t *pkt = NULL; appinfo_t *menu_info = NULL; candidate_process_context_t *cpc = NULL; + candidate_process_context_t *org_cpc = NULL; const char *app_path = NULL; int pid = -1; int clifd = -1; @@ -1443,7 +1452,7 @@ static gboolean __handle_launch_event(gpointer data) if (loader_id <= PAD_LOADER_ID_STATIC) { cpc = __find_available_slot(menu_info->hwacc, menu_info->app_type, - menu_info->loader_name); + menu_info->loader_name, &org_cpc); } else { type = LAUNCHPAD_TYPE_DYNAMIC; cpc = __find_slot(type, loader_id); @@ -1462,6 +1471,19 @@ static gboolean __handle_launch_event(gpointer data) _W("Launch directly %d %p", loader_id, cpc); pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL); + if (org_cpc) { + if (org_cpc->timer > 0) { + g_source_remove(org_cpc->timer); + org_cpc->timer = 0; + } + + if (org_cpc->idle_checker > 0) { + g_source_remove(org_cpc->idle_checker); + org_cpc->idle_checker = 0; + } + + __set_timer(org_cpc); + } } else { _W("Launch %d type process", cpc->type); pid = __send_launchpad_loader(cpc, pkt, app_path, clifd); @@ -1492,7 +1514,7 @@ end: static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *loader_extra, int detection_method, - int timeout_val, int threshold_max, int threshold_min) + int timeout_val, int threshold_max, int threshold_min, bool on_boot) { candidate_process_context_t *cpc; int fd = -1; @@ -1525,6 +1547,7 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, cpc->threshold = threshold_max; cpc->threshold_max = threshold_max; cpc->threshold_min = threshold_min; + cpc->on_boot = on_boot; fd = __listen_candidate_process(cpc->type, cpc->loader_id); if (fd == -1) { @@ -1719,7 +1742,7 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset, PAD_LOADER_ID_DIRECT, 0, info->exe, NULL, 0, 0, - info->cpu_threshold_max, info->cpu_threshold_min); + info->cpu_threshold_max, info->cpu_threshold_min, false); if (cpc == NULL) return; @@ -1739,7 +1762,7 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) PAD_LOADER_ID_STATIC, 0, info->exe, (char *)extra, info->detection_method, info->timeout_val, - info->cpu_threshold_max, info->cpu_threshold_min); + info->cpu_threshold_max, info->cpu_threshold_min, info->on_boot); if (cpc == NULL) return; diff --git a/src/loader_info.c b/src/loader_info.c index bf9dc49..5d2e327 100644 --- a/src/loader_info.c +++ b/src/loader_info.c @@ -37,6 +37,7 @@ #define TAG_HW_ACC "HW_ACC" #define TAG_CPU_THRESHOLD_MAX "CPU_THRESHOLD_MAX" #define TAG_CPU_THRESHOLD_MIN "CPU_THRESHOLD_MIN" +#define TAG_ON_BOOT "ON_BOOT" #define VAL_ON "ON" #define VAL_OFF "OFF" #define VAL_METHOD_TIMEOUT "TIMEOUT" @@ -65,6 +66,7 @@ static loader_info_t *__create_loader_info() info->extra = bundle_create(); info->cpu_threshold_max = DEFAULT_CPU_THRESHOLD_MAX; info->cpu_threshold_min = DEFAULT_CPU_THRESHOLD_MIN; + info->on_boot = true; return info; } @@ -228,6 +230,9 @@ static GList *__parse_file(GList *list, const char *path) cur_info->cpu_threshold_max = atoi(tok2); } else if (strcasecmp(TAG_CPU_THRESHOLD_MIN, tok1) == 0) { cur_info->cpu_threshold_min = atoi(tok2); + } else if (strcasecmp(TAG_ON_BOOT, tok1) == 0) { + if (tok2 && strcasecmp(VAL_OFF, tok2) == 0) + cur_info->on_boot = false; } } -- 2.7.4 From ced56c0ef979c2bb5697f1ebc8c7d69d44dd6a47 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Tue, 24 Oct 2017 13:12:06 +0900 Subject: [PATCH 13/16] Call API to support trust-anchor Change-Id: I7d9aef6f16ca18c7fd1cfdbdc1a7403b9cd86cae Signed-off-by: Junghoon Park --- CMakeLists.txt | 5 +++++ inc/key.h | 1 + inc/launchpad_common.h | 4 ++++ inc/loader_info.h | 1 + packaging/launchpad.spec | 1 + src/launchpad.c | 11 +++++++++++ src/launchpad_common.c | 6 ++++++ src/launchpad_lib.c | 21 +++++++++++++++++---- 8 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ecb214..1e1b618 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ PKG_CHECK_MODULES(${this_target_pool} REQUIRED dlog libsystemd security-manager + tanchor bundle gio-2.0 ttrace @@ -25,6 +26,8 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED ecore elementary security-manager + libtzplatform-config + tanchor bundle aul vconf @@ -41,6 +44,8 @@ PKG_CHECK_MODULES(${this_target_lib} REQUIRED bundle aul security-manager + libtzplatform-config + tanchor ) FOREACH(flag ${${this_target_lib}_CFLAGS}) diff --git a/inc/key.h b/inc/key.h index 71877b7..2628999 100644 --- a/inc/key.h +++ b/inc/key.h @@ -43,6 +43,7 @@ extern "C" { #define AUL_K_SDK "__AUL_SDK__" #define AUL_K_ORG_CALLER_PID "__AUL_ORG_CALLER_PID__" #define AUL_K_HIGHPRIORITY "__AUL_HIGHPRIORITY__" +#define AUL_K_IS_GLOBAL "__AUL_IS_GLOBAL__" #ifdef __cplusplus } diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 5bc4142..90bb662 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include #ifdef LAUNCHPAD_LOG #undef LOG_TAG @@ -66,6 +68,7 @@ } while (0) #define ARRAY_SIZE(x) ((sizeof(x)) / sizeof(x[0])) +#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) enum loader_arg { LOADER_ARG_PATH, @@ -95,6 +98,7 @@ typedef struct { char *internal_pool; char *root_path; char *loader_name; + bool global; } appinfo_t; void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd); diff --git a/inc/loader_info.h b/inc/loader_info.h index a3c58bb..493cdf6 100644 --- a/inc/loader_info.h +++ b/inc/loader_info.h @@ -40,6 +40,7 @@ typedef struct _loader_info { int cpu_threshold_max; int cpu_threshold_min; bool on_boot; + bool global; } loader_info_t; GList *_loader_info_load(const char *path); diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index e60c5bc..5c593ed 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -23,6 +23,7 @@ BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(ttrace) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(libcap) +BuildRequires: pkgconfig(tanchor) Requires(post): /sbin/ldconfig Requires(post): /usr/bin/systemctl diff --git a/src/launchpad.c b/src/launchpad.c index fc7d8bb..8f51b79 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "perf.h" #include "launchpad_common.h" @@ -731,6 +732,16 @@ static int __prepare_exec(const char *appid, const char *app_path, /* TODO : should be add to check permission in the kernel*/ setsid(); + if (menu_info->global) + ret = trust_anchor_launch(menu_info->pkgid, GLOBAL_USER); + else + ret = trust_anchor_launch(menu_info->pkgid, getuid()); + if (ret != TRUST_ANCHOR_ERROR_NONE && + ret != TRUST_ANCHOR_ERROR_NOT_INSTALLED) { + _E("trust_anchor_launch() returns %d", ret); + return PAD_ERR_REJECTED; + } + /* SET PRIVILEGES*/ ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) diff --git a/src/launchpad_common.c b/src/launchpad_common.c index d73952c..e6123b5 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -479,6 +479,12 @@ appinfo_t *_appinfo_create(bundle *kb) if (ptr) menu_info->loader_name = strdup(ptr); + ptr = bundle_get_val(kb, AUL_K_IS_GLOBAL); + if (ptr && strcmp(ptr, "true") == 0) + menu_info->global = true; + else + menu_info->global = false; + if (!_appinfo_get_app_path(menu_info)) { _appinfo_free(menu_info); return NULL; diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 183bd71..97b8e9e 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,7 @@ static void __at_exit_to_release_bundle(void) } static int __prepare_exec(const char *appid, const char *app_path, - const char *pkg_type, int type) + const char *pkg_type, int type, const char* pkgid, bool global) { const char *file_name = NULL; char process_name[AUL_PR_NAME] = { 0, }; @@ -66,6 +67,18 @@ static int __prepare_exec(const char *appid, const char *app_path, /* SET PRIVILEGES*/ SECURE_LOGD("[candidata] appid : %s / pkg_type : %s / app_path : %s", appid, pkg_type, app_path); + + if (global) + ret = trust_anchor_launch(pkgid, GLOBAL_USER); + else + ret = trust_anchor_launch(pkgid, getuid()); + + if (ret != TRUST_ANCHOR_ERROR_NONE && + ret != TRUST_ANCHOR_ERROR_NOT_INSTALLED) { + _E("trust_anchor_launch() returns %d", ret); + return -1; + } + ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) { _E("Failed to set privileges %s:%d", appid, ret); @@ -122,11 +135,11 @@ static int __prepare_exec(const char *appid, const char *app_path, static int __default_launch_cb(bundle *kb, const char *appid, const char *app_path, const char *root_path, - const char *pkgid, const char *pkg_type, int loader_type) + const char *pkgid, const char *pkg_type, int loader_type, bool global) { char err_str[MAX_LOCAL_BUFSZ] = { 0, }; - if (__prepare_exec(appid, app_path, pkg_type, loader_type) < 0) { + if (__prepare_exec(appid, app_path, pkg_type, loader_type, pkgid, global) < 0) { _E("__candidate_process_prepare_exec() failed"); if (access(app_path, F_OK | R_OK)) { SECURE_LOGE("access() failed for file: \"%s\", " \ @@ -205,7 +218,7 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t *pkt, __default_launch_cb(kb, menu_info->appid, app_path, menu_info->root_path, menu_info->pkgid, - menu_info->pkg_type, type); + menu_info->pkg_type, type, menu_info->global); if (__loader_callbacks->launch) { ret = __loader_callbacks->launch(tmp_argc, tmp_argv, app_path, -- 2.7.4 From b2a73eee0bc8e27ffa9507813891d486c3a90609 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Tue, 31 Oct 2017 15:07:52 +0900 Subject: [PATCH 14/16] Release version 0.3.7 Changes: - Call API to support trust-anchor - Add ON_BOOT tag for skipping loader Change-Id: Ieda27eab3fef10d8bbf40aea0040fbd17c9a30b7 Signed-off-by: Junghoon Park --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 5c593ed..1d046ee 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.3.6 +Version: 0.3.7 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 006fdb05f83513a8b06adcb28d67f9c6a96606ab Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 13 Nov 2017 22:59:06 +0900 Subject: [PATCH 15/16] Fix the slot management - Adds the function to reset the slot info - Fixes the exception about adding the slot timer Change-Id: Icc810f6ba5c85d87bfd460e2fa144bd7d0272b82 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 73 +++++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index 8f51b79..5e66ce0 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -480,6 +480,19 @@ static void __set_timer(candidate_process_context_t *cpc) } } +static void __reset_slot(candidate_process_context_t *cpc) +{ + if (cpc == NULL) + return; + + cpc->send_fd = -1; + cpc->prepared = false; + cpc->pid = CANDIDATE_NONE; + cpc->source = 0; + cpc->timer = 0; + cpc->idle_checker = 0; +} + static int __send_launchpad_loader(candidate_process_context_t *cpc, app_pkt_t *pkt, const char *app_path, int clifd) { @@ -495,26 +508,17 @@ static int __send_launchpad_loader(candidate_process_context_t *cpc, cpc->pid, app_path); pid = cpc->pid; - close(cpc->send_fd); - cpc->prepared = false; - cpc->pid = CANDIDATE_NONE; - cpc->send_fd = -1; - if (cpc->source > 0) { + if (cpc->send_fd > 0) + close(cpc->send_fd); + if (cpc->source > 0) g_source_remove(cpc->source); - cpc->source = 0; - } - - if (cpc->timer > 0) { + if (cpc->timer > 0) g_source_remove(cpc->timer); - cpc->timer = 0; - } - - if (cpc->idle_checker > 0) { + if (cpc->idle_checker > 0) g_source_remove(cpc->idle_checker); - cpc->idle_checker = 0; - } + __reset_slot(cpc); __set_timer(cpc); return pid; } @@ -981,18 +985,15 @@ static gboolean __handle_loader_client_event(gpointer data) SECURE_LOGE("Type %d candidate process was " \ "(POLLHUP|POLLNVAL), pid: %d", cpc->type, cpc->pid); - close(cpc->send_fd); - - cpc->prepared = false; - cpc->pid = CANDIDATE_NONE; - cpc->send_fd = -1; - cpc->source = 0; + if (cpc->send_fd > 0) + close(cpc->send_fd); if (cpc->timer > 0) g_source_remove(cpc->timer); - cpc->timer = 0; if (cpc->idle_checker > 0) g_source_remove(cpc->idle_checker); - cpc->idle_checker = 0; + + __reset_slot(cpc); + __prepare_candidate_process(cpc->type, cpc->loader_id); return G_SOURCE_REMOVE; @@ -1057,7 +1058,7 @@ static gboolean __handle_sigchild(gpointer data) _signal_process_sigchld(&siginfo); cpc = __find_slot_from_pid(siginfo.ssi_pid); if (cpc != NULL) { - cpc->prepared = false; + __reset_slot(cpc); __prepare_candidate_process(cpc->type, cpc->loader_id); } @@ -1082,27 +1083,17 @@ static gboolean __handle_label_monitor(gpointer data) while (iter) { cpc = (candidate_process_context_t *)iter->data; if (cpc->pid > 0) { - if (cpc->source > 0) { + if (cpc->source > 0) g_source_remove(cpc->source); - cpc->source = 0; - } - - if (cpc->timer > 0) { + if (cpc->timer > 0) g_source_remove(cpc->timer); - cpc->timer = 0; - } - - if (cpc->idle_checker > 0) { + if (cpc->idle_checker > 0) g_source_remove(cpc->idle_checker); - cpc->idle_checker = 0; - } - + if (cpc->send_fd > 0) + close(cpc->send_fd); _D("Dispose candidate process %d", cpc->pid); __kill_process(cpc->pid); - close(cpc->send_fd); - cpc->prepared = false; - cpc->pid = CANDIDATE_NONE; - cpc->send_fd = -1; + __reset_slot(cpc); __prepare_candidate_process(cpc->type, cpc->loader_id); } @@ -1482,7 +1473,7 @@ static gboolean __handle_launch_event(gpointer data) _W("Launch directly %d %p", loader_id, cpc); pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL); - if (org_cpc) { + if (org_cpc && org_cpc->pid == CANDIDATE_NONE) { if (org_cpc->timer > 0) { g_source_remove(org_cpc->timer); org_cpc->timer = 0; -- 2.7.4 From 5be89ef3c067d057bb17e45392eeba8a31df703a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 14 Nov 2017 09:02:56 +0900 Subject: [PATCH 16/16] Set the environments before calling launch callback Change-Id: I909f764a61f3dd781ab4ac8c8fd7b2077d804bfc Signed-off-by: Hwankyu Jhun --- src/launchpad_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 97b8e9e..c476fb9 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -214,6 +214,9 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t *pkt, SECURE_LOGD("pkg id: %s", menu_info->pkgid); + /* Set environments */ + _set_env(menu_info, kb); + tmp_argv = _create_argc_argv(kb, &tmp_argc); __default_launch_cb(kb, menu_info->appid, app_path, @@ -226,9 +229,6 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t *pkt, menu_info->pkg_type, __loader_user_data); } - /* SET ENVIROMENT*/ - _set_env(menu_info, kb); - if (out_app_path != NULL && out_argc != NULL && out_argv != NULL) { memset(out_app_path, '\0', strlen(out_app_path)); snprintf(out_app_path, LOADER_ARG_LEN, "%s", app_path); -- 2.7.4