From b67f9e7e9a31a6b2ff4f2867d2c63edd9fda7209 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 29 Jun 2022 16:26:30 +0900 Subject: [PATCH 01/16] Add cpu priority inheritance To improve performance in case of IPC call, the cpu priority is inherited from caller process. When calling register_cpu_inheritance_destination(), it can be inherited cpu priority from caller. Requires: - https://review.tizen.org/gerrit/c/platform/core/appfw/amd/+/276948 Change-Id: Ie4ed308f299efc0f76db465d3b824adeec6c1555 Signed-off-by: Changgyu Choi --- CMakeLists.txt | 1 + packaging/launchpad.spec | 2 +- src/launchpad-process-pool/CMakeLists.txt | 1 + src/launchpad-process-pool/src/launchpad.c | 38 ++++++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb3d5ca..267df09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,5 +70,6 @@ PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager) PKG_CHECK_MODULES(TANCHOR_DEPS REQUIRED tanchor) PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace) PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf) +PKG_CHECK_MODULES(CAPI_SYSTEM_RESOURCE_DEPS REQUIRED capi-system-resource) ADD_SUBDIRECTORY(src) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 5548027..a788059 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -33,6 +33,7 @@ BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(pkgmgr-installer) +BuildRequires: pkgconfig(capi-system-resource) Requires(post): /sbin/ldconfig Requires(post): /usr/bin/systemctl @@ -191,4 +192,3 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %{_libdir}/*.so %{_libdir}/pkgconfig/liblaunchpad.pc %{_libdir}/pkgconfig/liblaunchpad-hydra.pc - diff --git a/src/launchpad-process-pool/CMakeLists.txt b/src/launchpad-process-pool/CMakeLists.txt index b0af4fe..caec083 100644 --- a/src/launchpad-process-pool/CMakeLists.txt +++ b/src/launchpad-process-pool/CMakeLists.txt @@ -39,6 +39,7 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC TANCHOR_DEPS TTRACE_DEPS VCONF_DEPS + CAPI_SYSTEM_RESOURCE_DEPS ) TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC "-lm -ldl") diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 37fd7a3..5b7eb5a 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -15,6 +15,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -72,6 +73,7 @@ #define LOADERS_PATH "loaders" #define APP_DEFINED_LOADER_INFO_PATH OPT_SHARE_PATH "/" LOADERS_PATH #define COMMON_LOADER_NAME "common-loader1" +#define LAUNCHPAD_PROCESS_NAME "launchpad-process-pool" #define LAUNCHER_INFO_PATH LOADER_INFO_PATH #define REGULAR_UID_MIN 5000 @@ -784,6 +786,13 @@ static int __fork_app_process(int (*child_fn)(void *), void *arg) } if (pid == 0) { + resource_pid_t resource_st = { + pid = getpid(), + }; + ret = resource_clear_cpu_boosting(resource_st); + if (ret != 0) + _E("Failed to clear cpu boosting. error(%d)", ret); + _W("security_manager_prepare_app_candidate ++"); ret = security_manager_prepare_app_candidate(); _W("security_manager_prepare_app_candidate --"); @@ -2772,11 +2781,11 @@ static void __get_app_type_string(loader_info_t *info, char buf[], int size) strncpy(ptr, app_type, size); ptr += len; size -= len; - if (iter) { + if (iter) { (*ptr++) = ' '; size--; } - } + } } static void __add_slot_from_info(gpointer data, gpointer user_data) @@ -2834,12 +2843,12 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) info->type = LAUNCHPAD_LOADER_TYPE_USER + user_slot_offset; user_slot_offset++; - __get_app_type_string(info, buf, sizeof(buf)); - _I("candidate slot. app-type(%s) loader-type(%d)", + __get_app_type_string(info, buf, sizeof(buf)); + _I("candidate slot. app-type(%s) loader-type(%d)", buf, info->type); _print_hwc_log("candidate slot. app-type(%s) loader-type(%d)", buf, info->type); - } + } } static int __add_default_slots(void) @@ -3156,6 +3165,9 @@ static gboolean __launchpad_recovery_cb(gpointer data) static int __before_loop(int argc, char **argv) { int ret; + resource_pid_t resource_st = { + .pid = getpid(), + }; _print_hwc_log("%s(%d): START", __FUNCTION__, __LINE__); ret = __sequencer_init(); @@ -3227,11 +3239,27 @@ static int __before_loop(int argc, char **argv) _log_init(); _print_hwc_log("%s(%d): END", __FUNCTION__, __LINE__); + ret = resource_register_cpu_inheritance_destination( + LAUNCHPAD_PROCESS_NAME, resource_st); + if (ret != 0) { + _E("Failed to register cpu inheritance destination. error(%d)", + ret); + } + return 0; } static void __after_loop(void) { + int ret; + + ret = resource_unregister_cpu_inheritance_destination( + LAUNCHPAD_PROCESS_NAME); + if (ret != 0) { + _E("Failed to unregister cpu inheritance destination. " + "error(%d)", ret); + } + _log_fini(); _memory_monitor_fini(); __unregister_vconf_events(); -- 2.7.4 From c3e3665f899d1e73faabd3731d530b0983fcfa52 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Fri, 1 Jul 2022 13:10:36 +0900 Subject: [PATCH 02/16] Release version 0.18.10 Changes: - Add cpu priority inheritance Change-Id: Ie3ad6cfa3bd10cb1051bea4d9d9e319aca4fb004 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index a788059..d61b5c6 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.9 +Version: 0.18.10 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From fa72a5a868c941ec5237183bd6d7a5bf0d7f98bd Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 4 Jul 2022 19:10:30 +0900 Subject: [PATCH 03/16] Apply type converstions The dest_process parameter of resource_register_cpu_inheritance_destination() and resource_unregister_cpu_inheritance_destination() was char* type. This patch adds forced type conversions to convert to char* type. Change-Id: I2dfa722e3a1397e19e483e0e3d5950c3758599ff Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/src/launchpad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 5b7eb5a..745ffa4 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -3240,7 +3240,7 @@ static int __before_loop(int argc, char **argv) _print_hwc_log("%s(%d): END", __FUNCTION__, __LINE__); ret = resource_register_cpu_inheritance_destination( - LAUNCHPAD_PROCESS_NAME, resource_st); + (char*)LAUNCHPAD_PROCESS_NAME, resource_st); if (ret != 0) { _E("Failed to register cpu inheritance destination. error(%d)", ret); @@ -3254,7 +3254,7 @@ static void __after_loop(void) int ret; ret = resource_unregister_cpu_inheritance_destination( - LAUNCHPAD_PROCESS_NAME); + (char*)LAUNCHPAD_PROCESS_NAME); if (ret != 0) { _E("Failed to unregister cpu inheritance destination. " "error(%d)", ret); -- 2.7.4 From 877e3292dc2e75125707b919aca16157928cb885 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 5 Jul 2022 08:44:32 +0900 Subject: [PATCH 04/16] Release version 0.18.11 Changes: - Apply type converstions Change-Id: I46ea4236057c4f137a7323ecdbc7c21121151300 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 d61b5c6..3254e80 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.10 +Version: 0.18.11 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 67527db567db540f9dccab0726653ed9424da90d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 14 Jul 2022 13:23:49 +0900 Subject: [PATCH 05/16] Add a new environemtn variable Before executing an application, the process sets GCOV_PREFIX="/tmp" for code coverage measurement. Change-Id: Ifbdc216f7fb507a522ad4cbe631c2b81af3bb5c1 Signed-off-by: Hwankyu Jhun --- src/lib/common/src/launchpad_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/common/src/launchpad_common.c b/src/lib/common/src/launchpad_common.c index 4286a74..0717c95 100644 --- a/src/lib/common/src/launchpad_common.c +++ b/src/lib/common/src/launchpad_common.c @@ -794,6 +794,8 @@ void _set_env(appinfo_t *menu_info, bundle *kb) #ifdef TIZEN_FEATURE_SET_PERSONALITY_32 __set_execution_domain(); #endif /* TIZEN_FEATURE_SET_PERSONALITY_32 */ + + setenv("GCOV_PREFIX", "/tmp", 1); } char **_create_argc_argv(bundle *kb, int *margc) -- 2.7.4 From 734051cd151271c31d8fb5532355b021b333db9c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 14 Jul 2022 15:40:18 +0900 Subject: [PATCH 06/16] Release version 0.18.12 Changes: - Add a new environemtn variable Change-Id: I83a4a7a3b151bea2910f59c69f184637b1219c84 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 3254e80..001dcc0 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.11 +Version: 0.18.12 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From a6844133bfc3786f279dd7bdab165e723dd88f17 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 25 Jul 2022 10:45:27 +0900 Subject: [PATCH 07/16] Revert "Add cpu priority inheritance" This reverts commit b67f9e7e9a31a6b2ff4f2867d2c63edd9fda7209. Change-Id: I80317085c0a8b60ce463ab855313716f27d8709f Signed-off-by: Changgyu Choi --- CMakeLists.txt | 1 - packaging/launchpad.spec | 2 +- src/launchpad-process-pool/CMakeLists.txt | 1 - src/launchpad-process-pool/src/launchpad.c | 28 ---------------------------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 267df09..fb3d5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,5 @@ PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager) PKG_CHECK_MODULES(TANCHOR_DEPS REQUIRED tanchor) PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace) PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf) -PKG_CHECK_MODULES(CAPI_SYSTEM_RESOURCE_DEPS REQUIRED capi-system-resource) ADD_SUBDIRECTORY(src) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 001dcc0..aeb02df 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -33,7 +33,6 @@ BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(pkgmgr-installer) -BuildRequires: pkgconfig(capi-system-resource) Requires(post): /sbin/ldconfig Requires(post): /usr/bin/systemctl @@ -192,3 +191,4 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %{_libdir}/*.so %{_libdir}/pkgconfig/liblaunchpad.pc %{_libdir}/pkgconfig/liblaunchpad-hydra.pc + diff --git a/src/launchpad-process-pool/CMakeLists.txt b/src/launchpad-process-pool/CMakeLists.txt index caec083..b0af4fe 100644 --- a/src/launchpad-process-pool/CMakeLists.txt +++ b/src/launchpad-process-pool/CMakeLists.txt @@ -39,7 +39,6 @@ APPLY_PKG_CONFIG(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC TANCHOR_DEPS TTRACE_DEPS VCONF_DEPS - CAPI_SYSTEM_RESOURCE_DEPS ) TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_PROCESS_POOL} PUBLIC "-lm -ldl") diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 745ffa4..79bc219 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -15,7 +15,6 @@ */ #define _GNU_SOURCE -#include #include #include #include @@ -73,7 +72,6 @@ #define LOADERS_PATH "loaders" #define APP_DEFINED_LOADER_INFO_PATH OPT_SHARE_PATH "/" LOADERS_PATH #define COMMON_LOADER_NAME "common-loader1" -#define LAUNCHPAD_PROCESS_NAME "launchpad-process-pool" #define LAUNCHER_INFO_PATH LOADER_INFO_PATH #define REGULAR_UID_MIN 5000 @@ -786,13 +784,6 @@ static int __fork_app_process(int (*child_fn)(void *), void *arg) } if (pid == 0) { - resource_pid_t resource_st = { - pid = getpid(), - }; - ret = resource_clear_cpu_boosting(resource_st); - if (ret != 0) - _E("Failed to clear cpu boosting. error(%d)", ret); - _W("security_manager_prepare_app_candidate ++"); ret = security_manager_prepare_app_candidate(); _W("security_manager_prepare_app_candidate --"); @@ -3165,9 +3156,6 @@ static gboolean __launchpad_recovery_cb(gpointer data) static int __before_loop(int argc, char **argv) { int ret; - resource_pid_t resource_st = { - .pid = getpid(), - }; _print_hwc_log("%s(%d): START", __FUNCTION__, __LINE__); ret = __sequencer_init(); @@ -3239,27 +3227,11 @@ static int __before_loop(int argc, char **argv) _log_init(); _print_hwc_log("%s(%d): END", __FUNCTION__, __LINE__); - ret = resource_register_cpu_inheritance_destination( - (char*)LAUNCHPAD_PROCESS_NAME, resource_st); - if (ret != 0) { - _E("Failed to register cpu inheritance destination. error(%d)", - ret); - } - return 0; } static void __after_loop(void) { - int ret; - - ret = resource_unregister_cpu_inheritance_destination( - (char*)LAUNCHPAD_PROCESS_NAME); - if (ret != 0) { - _E("Failed to unregister cpu inheritance destination. " - "error(%d)", ret); - } - _log_fini(); _memory_monitor_fini(); __unregister_vconf_events(); -- 2.7.4 From 7d2a342559db65e37c749ce749ef22d69a03de41 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 25 Jul 2022 11:41:06 +0900 Subject: [PATCH 08/16] Release version 0.18.13 Changes: - Revert "Add cpu priority inheritance" Change-Id: I70f6b48c13e553bba15b980cff572b5e46fc98b2 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index aeb02df..8fc68bf 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.12 +Version: 0.18.13 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 293aabbf9a36260b1f0187fa6820ac35d0006376 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 25 Jul 2022 14:36:00 +0900 Subject: [PATCH 09/16] Send and receive candidate process ID The hydra loader sends a launched candidate process ID to launchpad-process-pool. When disposing the candidate process, launchpad-process-pool checks whether the candidate process is running or not to send SIGKILL signal. In the provious implementation, there is a problem that the candidate process was not terminated while it's executing. Change-Id: I88fe989f80007d9c5b6f4bb381c5ad2d863be4e8 Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/src/launchpad.c | 14 ++++++++++++++ src/lib/launchpad-hydra/src/launchpad_hydra.c | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 79bc219..85e3c7a 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -1451,6 +1451,8 @@ static bool __handle_hydra_client_event(int fd, io_condition_e cond, void *data) { candidate_process_context_t *cpc = data; + int recv_pid = -1; + int ret; if (cpc == NULL) return false; @@ -1464,6 +1466,18 @@ static bool __handle_hydra_client_event(int fd, io_condition_e cond, return false; } + if (cond & IO_IN) { + ret = recv(cpc->hydra_fd, &recv_pid, sizeof(recv_pid), + MSG_WAITALL); + if (ret == -1) { + _E("recv() is failed. errno(%d)", errno); + } else { + _W("candidate process: %d", recv_pid); + if (recv_pid > 1) + cpc->pid = recv_pid; + } + } + return true; } diff --git a/src/lib/launchpad-hydra/src/launchpad_hydra.c b/src/lib/launchpad-hydra/src/launchpad_hydra.c index aa737fd..ba385db 100644 --- a/src/lib/launchpad-hydra/src/launchpad_hydra.c +++ b/src/lib/launchpad-hydra/src/launchpad_hydra.c @@ -202,6 +202,10 @@ retry_recv: __context.candidate_pid = __fork_process(__run_loader, NULL); _D("[__HYDRA__] candidate process(%d)", __context.candidate_pid); + len = send(fd, &__context.candidate_pid, + sizeof(__context.candidate_pid), MSG_NOSIGNAL); + if (len == -1) + _E("[__HYDRA__] send() is failed. errno(%d)", errno); return 0; err: @@ -437,6 +441,10 @@ API int launchpad_hydra_main(int argc, char **argv, __context.candidate_pid = __fork_process(__run_loader, NULL); _D("[__HYDRA__] candidate process(%d)", __context.candidate_pid); + if (send(__context.client_fd, &__context.candidate_pid, + sizeof(__context.candidate_pid), + MSG_NOSIGNAL) == -1) + _E("[__HYDRA__] send() is failed. errno(%d)", errno); __run_loop(); -- 2.7.4 From 548c72467ab53340443b48d4ea4f03131f500667 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 25 Jul 2022 15:17:42 +0900 Subject: [PATCH 10/16] Release version 0.18.14 Changes: - Send and receive candidate process ID Change-Id: I619a48d0f237aebf3f2a3511c533ffb9fcd95919 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 8fc68bf..91785ee 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.13 +Version: 0.18.14 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From e88b06163982ade242e336e4d93a748b756af0ba Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 19 Jul 2022 15:43:17 +0900 Subject: [PATCH 11/16] Implement launch of light user application Change-Id: I9ab41fe9e0dca4e2b40051a741182067a20f99f9 Signed-off-by: Ilho Kim --- src/launchpad-process-pool/src/launchpad.c | 8 +++++--- src/lib/common/inc/key.h | 1 + src/lib/launchpad/src/launchpad_lib.c | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 85e3c7a..1ba060b 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -1230,6 +1230,7 @@ static int __prepare_exec(const char *appid, const char *app_path, appinfo_t *menu_info, bundle *kb) { char *file_name; + const char *enabled_light_user; char process_name[AUL_PR_NAME]; int ret; @@ -1267,9 +1268,10 @@ static int __prepare_exec(const char *appid, const char *app_path, _debug_change_mount_namespace(); /* SET PRIVILEGES*/ - _W("security_manager_prepare_app ++"); - ret = security_manager_prepare_app(appid); - _W("security_manager_prepare_app --"); + enabled_light_user = bundle_get_val(kb, AUL_K_ENABLED_LIGHT_USER); + _W("security_manager_prepare_app2 ++"); + ret = security_manager_prepare_app2(appid, enabled_light_user); + _W("security_manager_prepare_app2 --"); if (ret != SECURITY_MANAGER_SUCCESS) return PAD_ERR_REJECTED; diff --git a/src/lib/common/inc/key.h b/src/lib/common/inc/key.h index 19493c6..8889cca 100644 --- a/src/lib/common/inc/key.h +++ b/src/lib/common/inc/key.h @@ -51,6 +51,7 @@ extern "C" { #define AUL_K_INSTALLED_STORAGE "__AUL_INSTALLED_STORAGE__" #define AUL_K_MOUNT_GLOBAL_RES_DIR "__AUL_MOUNT_GLOBAL_RES_DIR__" #define AUL_K_MOUNT_ALLOWED_RES_DIR "__AUL_MOUNT_ALLOWED_RES_DIR__" +#define AUL_K_ENABLED_LIGHT_USER "__AUL_ENABLED_LIGHT_USER__" #ifdef __cplusplus } diff --git a/src/lib/launchpad/src/launchpad_lib.c b/src/lib/launchpad/src/launchpad_lib.c index e14894f..437dbbe 100644 --- a/src/lib/launchpad/src/launchpad_lib.c +++ b/src/lib/launchpad/src/launchpad_lib.c @@ -65,6 +65,7 @@ static int __prepare_exec(const char *appid, const char *app_path, const char *root_path, bool global, bundle *kb) { const char *file_name = NULL; + const char *enabled_light_user; char process_name[AUL_PR_NAME] = { 0, }; int ret; struct buxton_client *bxt_cli; @@ -94,9 +95,10 @@ static int __prepare_exec(const char *appid, const char *app_path, if (ret < 0) return -1; - _W("security_manager_prepare_app ++"); - ret = security_manager_prepare_app(appid); - _W("security_manager_prepare_app --"); + enabled_light_user = bundle_get_val(kb, AUL_K_ENABLED_LIGHT_USER); + _W("security_manager_prepare_app2 ++"); + ret = security_manager_prepare_app2(appid, enabled_light_user); + _W("security_manager_prepare_app2 --"); if (ret != SECURITY_MANAGER_SUCCESS) { _E("Failed to set privileges %s:%d", appid, ret); return -1; -- 2.7.4 From 03ae0ef0750fef5422a3b29233fe31a967105436 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Fri, 5 Aug 2022 10:27:17 +0900 Subject: [PATCH 12/16] Release version 0.19.0 Changes: - Implement launch of light user application Change-Id: I090af4f7c74ff05a8fee7d1ea82df059a8a42dc7 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 91785ee..0525399 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.18.14 +Version: 0.19.0 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From ab8d49d2fdf501ced10464e69275c8de86eced5f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 19 Sep 2022 07:45:29 +0000 Subject: [PATCH 13/16] Fix resource leak The allocated memory has to be released. The xmlGetProp() returns the allocated value. It should be released using xmlFree(). Change-Id: I031d76c587ad8dcab9141c585d732893d916eea9 Signed-off-by: Hwankyu Jhun --- src/launchpad-parser/launchpad_parser_plugin.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/launchpad-parser/launchpad_parser_plugin.cc b/src/launchpad-parser/launchpad_parser_plugin.cc index f873673..d8b23c0 100644 --- a/src/launchpad-parser/launchpad_parser_plugin.cc +++ b/src/launchpad-parser/launchpad_parser_plugin.cc @@ -103,15 +103,21 @@ int LaunchpadParser::Install(xmlDocPtr doc, std::string pkgid) { continue; xmlChar* val = xmlGetProp(node, reinterpret_cast("id")); + if (val == nullptr) + continue; + std::shared_ptr info = std::make_shared(std::string(reinterpret_cast(val))); + xmlFree(val); if (!IsValidId(info->GetId(), pkgid)) return -1; xmlChar* ttl = xmlGetProp(node, reinterpret_cast("time-to-live")); - if (ttl) + if (ttl) { info->SetTimeToLive(std::stoi(std::string(reinterpret_cast(ttl)))); + xmlFree(ttl); + } for (xmlNode* iter = node->children; iter; iter = iter->next) { if (!iter->name) @@ -120,10 +126,11 @@ int LaunchpadParser::Install(xmlDocPtr doc, std::string pkgid) { std::string(reinterpret_cast(iter->name)); if (child_name == "preload-library") { xmlChar* libname = xmlGetProp(iter, - reinterpret_cast("name")); + reinterpret_cast("name")); if (!libname) continue; info->AddPreloadLib(std::string(reinterpret_cast(libname))); + xmlFree(libname); } } loader_list_.push_back(info); @@ -158,6 +165,7 @@ int LaunchpadParser::UnInstall(xmlDocPtr doc, std::string pkgid) { return -1; std::string id = std::string(reinterpret_cast(val)); + xmlFree(val); if (!IsValidId(id, pkgid)) return -1; remove(GetFilePath(id).c_str()); -- 2.7.4 From bbedcfaa2bbe9e8971a4f3688117f3167850481e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 19 Sep 2022 07:57:12 +0000 Subject: [PATCH 14/16] Release version 0.19.1 Changes: - Fix resource leak Change-Id: Idc73789582823bab17303215ca0d10b31b59bc3b 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 0525399..9ce9f6c 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.19.0 +Version: 0.19.1 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 9a607a8212db01af57616c36eb55ba4b4887b454 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 17 Oct 2022 12:12:25 +0900 Subject: [PATCH 15/16] Fix static analysis issues Change-Id: I6ef67f0f1b6423756955a94370fbcee51b1d81ee Signed-off-by: Changgyu Choi --- src/launchpad-process-pool/src/launchpad.c | 6 ++-- src/lib/common/src/launchpad_common.c | 8 ++--- src/lib/common/src/launchpad_socket.c | 58 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index 1ba060b..83e1d21 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -93,7 +93,7 @@ typedef struct { int type; bool prepared; int pid; /* for hydra this pid is not the pid of hydra itself */ - /* but pid of non-hydra candidate, which was forked from hydra */ + /* but pid of non-hydra candidate, which was forked from hydra */ int hydra_pid; int loader_id; int caller_pid; @@ -627,7 +627,7 @@ static int __accept_candidate_process(int server_fd, int *out_client_fd, goto error; } - len = sizeof(cred); + len = (socklen_t)sizeof(cred); ret = getsockopt(client_fd, SOL_SOCKET, SO_PEERCRED, &cred, &len); if (ret < 0) { _E("getsockopt error"); @@ -847,7 +847,7 @@ static void __set_live_timer(candidate_process_context_t *cpc) static int __hydra_send_request(int fd, enum hydra_cmd cmd) { int sent = 0; - int size = sizeof(cmd); + int size = (int)sizeof(cmd); int send_ret = 0; while (sent != size) { diff --git a/src/lib/common/src/launchpad_common.c b/src/lib/common/src/launchpad_common.c index 0717c95..0db3125 100644 --- a/src/lib/common/src/launchpad_common.c +++ b/src/lib/common/src/launchpad_common.c @@ -415,12 +415,10 @@ retry_recv: app_pkt_t *_accept_recv_pkt_raw(int fd, int *clifd, struct ucred *cr) { struct sockaddr_un aul_addr = { 0, }; - int sun_size; + int sun_size = (int)sizeof(struct sockaddr_un); app_pkt_t *pkt; int newfd; - int cl = sizeof(struct ucred); - - sun_size = sizeof(struct sockaddr_un); + int cl = (int)sizeof(struct ucred); newfd = accept(fd, (struct sockaddr *)&aul_addr, (socklen_t *) &sun_size); @@ -1513,7 +1511,7 @@ void _print_hwc_log(const char *format, ...) static int __get_mount_opt(const char *srcs[], size_t srcs_len, const char *dest, char *opt, size_t opt_len) { - int i; + size_t i; char buf[PATH_MAX]; int ret; diff --git a/src/lib/common/src/launchpad_socket.c b/src/lib/common/src/launchpad_socket.c index a79905b..16241f7 100644 --- a/src/lib/common/src/launchpad_socket.c +++ b/src/lib/common/src/launchpad_socket.c @@ -42,26 +42,26 @@ struct socket_s { static int __set_socket_option(int fd, bool client) { - struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */ - int size = LAUNCHPAD_SOCKET_MAX_BUFF; - int flag; - int ret; + struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */ + int size = LAUNCHPAD_SOCKET_MAX_BUFF; + int flag; + int ret; - ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); - if (ret < 0) { + ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); + if (ret < 0) { ret = -errno; _E("setsockopt(SO_SNDBUF) is failed. fd(%d), errno(%d)", fd, errno); - return ret; - } + return ret; + } - ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); - if (ret < 0) { + ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + if (ret < 0) { ret = -errno; _E("setsockopt(SO_RCVBUF) is failed. fd(%d), errno(%d)", fd, errno); - return ret; - } + return ret; + } if (!client) return 0; @@ -83,7 +83,7 @@ static int __set_socket_option(int fd, bool client) return ret; } - return 0; + return 0; } static int __create_server_socket(const char *path) @@ -136,27 +136,27 @@ static int __create_client_socket(const char *path) int fd; fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (fd < 0) { + if (fd < 0) { ret = -errno; _E("socket() is failed. path(%s), errno(%d)", path, errno); - return ret; - } + return ret; + } - addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path); - while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - if (errno != ETIMEDOUT || retry <= 0) { + addr.sun_family = AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path); + while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (errno != ETIMEDOUT || retry <= 0) { ret = -errno; _E("connect() is failed. path(%s), errno(%d)", path, errno); - close(fd); - return ret; - } + close(fd); + return ret; + } - usleep(LAUNCHPAD_SOCKET_RETRY_TIME); - retry--; - _W("Retry(%d) to connect to %s", retry, path); - } + usleep(LAUNCHPAD_SOCKET_RETRY_TIME); + retry--; + _W("Retry(%d) to connect to %s", retry, path); + } ret = __set_socket_option(fd, true); if (ret < 0) { @@ -273,8 +273,8 @@ int _socket_accept(socket_h handle, socket_h *client_socket) struct socket_s *sock; struct sockaddr_un addr = { 0, }; struct ucred cred = { 0, }; - socklen_t addr_size = sizeof(struct sockaddr_un); - socklen_t cred_size = sizeof(struct ucred); + socklen_t addr_size = (socklen_t)sizeof(struct sockaddr_un); + socklen_t cred_size = (socklen_t)sizeof(struct ucred); int client_fd; int ret; -- 2.7.4 From 27c46a599f0ff9df93cd29f939515174a754a400 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Tue, 18 Oct 2022 11:26:24 +0900 Subject: [PATCH 16/16] Release version 0.19.2 Changes: - Fix static analysis issues Change-Id: I5fd2f82cf99c3ab8360780f98db913f81496f378 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 9ce9f6c..b4f0553 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.19.1 +Version: 0.19.2 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4