From 25c7cbbd495bb790690a9442cefa8f15324c6fa2 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 21 Mar 2017 17:37:48 +0900 Subject: [PATCH 01/16] Fix a typing error Change-Id: Icaa9108e59e725cab731c64f37ba63f1a2240d24 Signed-off-by: Hwankyu Jhun --- src/launchpad_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launchpad_debug.c b/src/launchpad_debug.c index da11576..5eacf14 100644 --- a/src/launchpad_debug.c +++ b/src/launchpad_debug.c @@ -321,7 +321,7 @@ static void __set_debug_env(gpointer data, gpointer user_data) break; strncat(buf, ",", sizeof(buf) - strlen(buf) - 1); - strncat(buf, str_arr[1], sizeof(buf) - strlen(buf) - 1); + strncat(buf, str_arr[i], sizeof(buf) - strlen(buf) - 1); } bundle_del(kb, key); -- 2.7.4 From 23e88cf7da0eb46fa410739f770beb23137589c4 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 22 Mar 2017 07:34:36 +0900 Subject: [PATCH 02/16] Release version 0.2.8 Changes: - Fix a typing error Change-Id: If9dc9e0f5d3e429ee4f737a4676621bfdf4eb4a8 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 42b60b4..65e7ad4 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.7 +Version: 0.2.8 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 4968f2820305111f7c278f0282433613d5ee072e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Mar 2017 10:07:13 +0900 Subject: [PATCH 03/16] Use license macro Change-Id: I7fde276824ca6a89df24d1b969fa3102b58a78b2 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 65e7ad4..f191d89 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -80,14 +80,11 @@ install -m 0644 %SOURCE102 %{buildroot}%{_unitdir_user}/launchpad-process-pool.s ln -sf ../launchpad-process-pool.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/launchpad-process-pool.socket ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.target.wants/launchpad-process-pool.service -mkdir -p %{buildroot}/usr/share/license -cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name} - %post %files %manifest launchpad.manifest -%{_prefix}/share/license/%{name} +%license LICENSE %{_prefix}/share/aul/default.debugger %{_unitdir_user}/launchpad-process-pool.service %{_unitdir_user}/launchpad-process-pool.socket @@ -103,5 +100,6 @@ cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{nam %files -n launchpad-loader %manifest %{name}.manifest +%license LICENSE %{_prefix}/share/aul/default.loader %caps(cap_setgid=ei) %{_bindir}/launchpad-loader -- 2.7.4 From ae5117b8845b510702ed4e2a81fe06f0fe156233 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Mar 2017 11:04:30 +0900 Subject: [PATCH 04/16] Release version 0.2.9 Changes: - Use license macro Change-Id: I8af9438a0771e70ad393e03468acc4a8e19a5650 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 f191d89..8b2b347 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.8 +Version: 0.2.9 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From fd8e1ee299d5a115e7362a659e8a147eed9c3df5 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Mar 2017 17:39:02 +0900 Subject: [PATCH 05/16] Send app startup signal After calling security_manager_prepare_app(), the child process sends the app startup signal to the amd. This signal is for handling privacy popup. Change-Id: I46c51bb3ffc42c8f0271815fc8bf5e0f69f011ad Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 1 + src/launchpad.c | 1 + src/launchpad_lib.c | 1 + 3 files changed, 3 insertions(+) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 0d4ef6e..68b1e93 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -48,6 +48,7 @@ #define LAUNCHPAD_LAUNCH_SIGNAL 85 #define LAUNCHPAD_DEAD_SIGNAL 61 +#define APP_STARTUP_SIGNAL 91 #define PAD_LOADER_ID_STATIC 0 #define PAD_LOADER_ID_DIRECT 1 diff --git a/src/launchpad.c b/src/launchpad.c index 4087450..5cf71de 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -714,6 +714,7 @@ static int __prepare_exec(const char *appid, const char *app_path, return PAD_ERR_REJECTED; } + _send_cmd_to_amd(APP_STARTUP_SIGNAL); if (bundle_get_type(kb, AUL_K_SDK) == BUNDLE_TYPE_NONE) _setup_stdio(basename(app_path)); diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 70a600e..927046e 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -77,6 +77,7 @@ static int __prepare_exec(const char *appid, const char *app_path, return -1; } + _send_cmd_to_amd(APP_STARTUP_SIGNAL); _setup_stdio(basename(app_path)); ret = buxton_open(&bxt_cli, NULL, NULL); -- 2.7.4 From a0819d0af100d7f615895e4c45871929a10800e6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 30 Mar 2017 18:49:11 +0900 Subject: [PATCH 06/16] Release version 0.2.10 Changes: - Send app startup signal Change-Id: I28818cfc56ff95173665d5a07fe829b5d2efc17f 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 8b2b347..e088168 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.9 +Version: 0.2.10 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 1df7e4efa7bf09a3633f440f3eecb17512cf3d51 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 31 Mar 2017 17:32:30 +0900 Subject: [PATCH 07/16] Change dbspace file mode The file mode of /run/aul/dbspace/%U is changed to 701. Change-Id: Ifb5ffe4bcba9b71c5e5b93335f34082227a69cf1 Signed-off-by: Hwankyu Jhun --- packaging/launchpad-process-pool.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad-process-pool.service b/packaging/launchpad-process-pool.service index c890e2d..5c80f02 100644 --- a/packaging/launchpad-process-pool.service +++ b/packaging/launchpad-process-pool.service @@ -14,6 +14,6 @@ ExecStartPre=-/usr/bin/chmod 0777 /run/aul/daemons/%U ExecStartPre=-/usr/bin/mkdir -p /run/aul/apps/%U ExecStartPre=-/usr/bin/chmod 0700 /run/aul/apps/%U ExecStartPre=-/usr/bin/mkdir -p /run/aul/dbspace/%U -ExecStartPre=-/usr/bin/chmod 0700 /run/aul/dbspace/%U +ExecStartPre=-/usr/bin/chmod 0701 /run/aul/dbspace/%U ExecStart=/bin/sh -l -c "/usr/bin/launchpad-process-pool" Sockets=launchpad-process-pool.socket -- 2.7.4 From df9de27ba498a618168795317e93f849a386691a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 4 Apr 2017 17:51:57 +0900 Subject: [PATCH 08/16] Release version 0.2.11 Changes: - Change dbspace file mode Change-Id: I27f422fd069bee3d60d5025f7716a2a1140b3d28 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 e088168..34490b2 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.10 +Version: 0.2.11 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From ec97ec0b1970a40bf1afa08c7efc3b3e52ab99a8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 5 Apr 2017 09:01:27 +0900 Subject: [PATCH 09/16] Check privacy before executing an application If the security_manager_prepare_app_privacy() returns an error, the launch request will be rejected. Change-Id: Iaa4f1341ff684cef33cfeea35921fa3c017bce80 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 9 ++++++++- src/launchpad_lib.c | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index 5cf71de..fef9868 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -707,8 +707,15 @@ static int __prepare_exec(const char *appid, const char *app_path, /* TODO : should be add to check permission in the kernel*/ setsid(); - /* SET PRIVILEGES*/ if (bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) { + /* CHECK PRIVACY */ + ret = security_manager_prepare_app_privacy(appid); + if (ret != SECURITY_MANAGER_SUCCESS) { + _W("Launching %s has been prohibited", appid); + return PAD_ERR_REJECTED; + } + + /* SET PRIVILEGES*/ ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) return PAD_ERR_REJECTED; diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 927046e..c73c4fd 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -67,9 +67,17 @@ static int __prepare_exec(const char *appid, const char *app_path, __preexec_run(pkg_type, appid, app_path); - /* SET PRIVILEGES*/ SECURE_LOGD("[candidata] appid : %s / pkg_type : %s / app_path : %s", appid, pkg_type, app_path); + + /* CHECK PRIVACY */ + ret = security_manager_prepare_app_privacy(appid); + if (ret != SECURITY_MANAGER_SUCCESS) { + _W("Launching %s has been prohibited", appid); + return -1; + } + + /* SET PRIVILEGES*/ ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) { _D("fail to set privileges - " \ -- 2.7.4 From bdeb0fd445c6fc5ce88eb7c37ae82d93befef3cf Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 5 Apr 2017 15:54:22 +0900 Subject: [PATCH 10/16] Fix log messages Change-Id: I0a51bd9e10e6dd5e2c4c1b50746c07606b275fd2 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 2 +- src/launchpad_lib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index fef9868..e316954 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -711,7 +711,7 @@ static int __prepare_exec(const char *appid, const char *app_path, /* CHECK PRIVACY */ ret = security_manager_prepare_app_privacy(appid); if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been prohibited", appid); + _W("Launching %s has been denied.", appid); return PAD_ERR_REJECTED; } diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index c73c4fd..ce13216 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -73,7 +73,7 @@ static int __prepare_exec(const char *appid, const char *app_path, /* CHECK PRIVACY */ ret = security_manager_prepare_app_privacy(appid); if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been prohibited", appid); + _W("Launching %s has been denied.", appid); return -1; } -- 2.7.4 From f27961e3e8e6fc83a2bb70f178c7f67d6fc09458 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 14 Apr 2017 13:17:05 +0900 Subject: [PATCH 11/16] Revert "Fix log messages" This reverts commit bdeb0fd445c6fc5ce88eb7c37ae82d93befef3cf. Change-Id: I1a176c1d26409ecc5a0b2e58b6d8622a2c70e595 --- src/launchpad.c | 2 +- src/launchpad_lib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index e316954..fef9868 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -711,7 +711,7 @@ static int __prepare_exec(const char *appid, const char *app_path, /* CHECK PRIVACY */ ret = security_manager_prepare_app_privacy(appid); if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been denied.", appid); + _W("Launching %s has been prohibited", appid); return PAD_ERR_REJECTED; } diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index ce13216..c73c4fd 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -73,7 +73,7 @@ static int __prepare_exec(const char *appid, const char *app_path, /* CHECK PRIVACY */ ret = security_manager_prepare_app_privacy(appid); if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been denied.", appid); + _W("Launching %s has been prohibited", appid); return -1; } -- 2.7.4 From fed82415b9ecd63417a9e80aa9d443e0cc4c158b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 14 Apr 2017 13:17:21 +0900 Subject: [PATCH 12/16] Revert "Check privacy before executing an application" This reverts commit ec97ec0b1970a40bf1afa08c7efc3b3e52ab99a8. Change-Id: I0568a14bbf665abfea8a8e0bae85feb58cf2de1e --- src/launchpad.c | 9 +-------- src/launchpad_lib.c | 10 +--------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index fef9868..5cf71de 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -707,15 +707,8 @@ static int __prepare_exec(const char *appid, const char *app_path, /* TODO : should be add to check permission in the kernel*/ setsid(); + /* SET PRIVILEGES*/ if (bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) { - /* CHECK PRIVACY */ - ret = security_manager_prepare_app_privacy(appid); - if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been prohibited", appid); - return PAD_ERR_REJECTED; - } - - /* SET PRIVILEGES*/ ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) return PAD_ERR_REJECTED; diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index c73c4fd..927046e 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -67,17 +67,9 @@ static int __prepare_exec(const char *appid, const char *app_path, __preexec_run(pkg_type, appid, app_path); + /* SET PRIVILEGES*/ SECURE_LOGD("[candidata] appid : %s / pkg_type : %s / app_path : %s", appid, pkg_type, app_path); - - /* CHECK PRIVACY */ - ret = security_manager_prepare_app_privacy(appid); - if (ret != SECURITY_MANAGER_SUCCESS) { - _W("Launching %s has been prohibited", appid); - return -1; - } - - /* SET PRIVILEGES*/ ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) { _D("fail to set privileges - " \ -- 2.7.4 From fc51042078803d64afa940b8c953307a5468882f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 24 Apr 2017 08:45:32 +0900 Subject: [PATCH 13/16] Fix APP_STARTUP_SIGNAL number The APP_STARTUP_SIGNAL number is changed. Change-Id: I72cc6584b3c1d924a73b4013d271d77deea8fa91 Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 68b1e93..a2a95ad 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -48,7 +48,7 @@ #define LAUNCHPAD_LAUNCH_SIGNAL 85 #define LAUNCHPAD_DEAD_SIGNAL 61 -#define APP_STARTUP_SIGNAL 91 +#define APP_STARTUP_SIGNAL 89 #define PAD_LOADER_ID_STATIC 0 #define PAD_LOADER_ID_DIRECT 1 -- 2.7.4 From 6aaaea3d418b9e7d67ade6aa93b5060a6c8f74b1 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 25 Apr 2017 12:47:45 +0900 Subject: [PATCH 14/16] Release version 0.2.12 Changes: - Fix APP_STARTUP_SIGNAL number Change-Id: I40a34edba5d8c458d626851449b9885fbfe71519 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 34490b2..b1180f6 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.11 +Version: 0.2.12 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From aea366cd4027d6a085d5c52cf143f596bb19dfc5 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 26 May 2017 16:20:52 +0900 Subject: [PATCH 15/16] Fix build dependency - Use libsystemd instead of libsystemd-daemon Change-Id: Ia61fb5e7e3322e8bd28e3ae97c0ebbe05c2cbc8a Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 4 ++-- packaging/launchpad.spec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0c208f..9c1c049 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ SET (this_target_lib launchpad) INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(${this_target_pool} REQUIRED dlog - libsystemd-daemon + libsystemd security-manager bundle gio-2.0 @@ -28,7 +28,7 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED aul vconf buxton2 - libsystemd-daemon + libsystemd ) FOREACH(flag ${${this_target_loader}_CFLAGS}) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index b1180f6..9c0baf2 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -14,7 +14,7 @@ BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(libsystemd-daemon) +BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(buxton2) -- 2.7.4 From aa42502cc5036e85227f59f5d5974b2cb46e96ad Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 29 May 2017 19:02:54 +0900 Subject: [PATCH 16/16] Fix priority change feature - Change prefix to "TIZEN_FEATURE". - Change lowest priority value to 19. (range: -20 ~ 19) - Set CAP_SYS_NICE if the feature is enabled - Add a new API to adjust scheduling priority Note: - To enable the feature, the user session systemd should have the cap_sys_nice capability(inheritable). Change-Id: I86e3d30a26ecde5bf8a70ef1cb2660fa33cc5aef Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 9 ++++++--- inc/key.h | 1 + inc/launchpad.h | 15 +++++++++++++++ inc/launchpad_common.h | 1 + packaging/launchpad.spec | 21 +++++++++++++++++---- src/launchpad.c | 19 ++----------------- src/launchpad_common.c | 15 +++++++++++++++ src/launchpad_lib.c | 43 +++++-------------------------------------- src/launchpad_loader.c | 20 +++++++++++++++++++- 9 files changed, 81 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c1c049..23a351c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,12 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"") -IF(_APPFW_FEATURE_PRIORITY_CHANGE) - ADD_DEFINITIONS("-D_APPFW_FEATURE_PRIORITY_CHANGE") -ENDIF(_APPFW_FEATURE_PRIORITY_CHANGE) +IF(_TIZEN_FEATURE_PRIORITY_CHANGE) + ADD_DEFINITIONS("-DTIZEN_FEATURE_PRIORITY_CHANGE") +ENDIF(_TIZEN_FEATURE_PRIORITY_CHANGE) +IF(_TIZEN_FEATURE_LOADER_PRIORITY) + ADD_DEFINITIONS("-DTIZEN_FEATURE_LOADER_PRIORITY") +ENDIF(_TIZEN_FEATURE_LOADER_PRIORITY) ADD_DEFINITIONS("-DLAUNCHPAD_LOG") ADD_DEFINITIONS("-DPRELOAD_ACTIVATE") diff --git a/inc/key.h b/inc/key.h index e83bb14..98647e0 100644 --- a/inc/key.h +++ b/inc/key.h @@ -45,6 +45,7 @@ extern "C" { #define AUL_K_LOADER_NAME "__AUL_LOADER_NAME__" #define AUL_K_SDK "__AUL_SDK__" #define AUL_K_ORG_CALLER_PID "__AUL_ORG_CALLER_PID__" +#define AUL_K_HIGHPRIORITY "__AUL_HIGHPRIORITY__" #ifdef __cplusplus } diff --git a/inc/launchpad.h b/inc/launchpad.h index fb2cabf..7c2cae8 100644 --- a/inc/launchpad.h +++ b/inc/launchpad.h @@ -60,6 +60,21 @@ int launchpad_loader_main(int argc, char **argv, loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter, void *user_data); +/* + * @par Description + * Set program scheduling priority. + * + * @param[in] prio The priority + * @return @c 0 on success, + * otherwise a negative error value + * + * @remarks + * The prio is a value in the range -20 to 19. + * If the prio is higher than current value, the process MUST have + * CAP_SYS_NICE capability. + */ +int launchpad_loader_set_priority(int prio); + #ifdef __cplusplus } #endif diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index a2a95ad..7a8e323 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -109,6 +109,7 @@ int _proc_get_attr_by_pid(int pid, char *buf, int size); int _close_all_fds(void); void _get_cpu_idle(unsigned long long *total, unsigned long long *idle); int _setup_stdio(const char *ident); +int _set_priority(int prio); #endif /* __LAUNCHPAD_COMMON_H__ */ diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 9c0baf2..e0f0e84 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -29,7 +29,8 @@ Requires(postun): /sbin/ldconfig Requires(postun): /usr/bin/systemctl Requires(preun): /usr/bin/systemctl -%define appfw_feature_priority_change 0 +%define tizen_feature_priority_change 0 +%define tizen_feature_loader_priority 0 %description Launchpad for launching applications @@ -58,14 +59,18 @@ export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif -%if 0%{?appfw_feature_priority_change} -_APPFW_FEATURE_PRIORITY_CHANGE=ON +%if 0%{?tizen_feature_priority_change} +_TIZEN_FEATURE_PRIORITY_CHANGE=ON +%endif +%if 0%{?tizen_feature_loader_priority} +_TIZEN_FEATURE_LOADER_PRIORITY=ON %endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake -DVERSION=%{version} \ -DMAJORVER=${MAJORVER} \ - -D_APPFW_FEATURE_PRIORITY_CHANGE:BOOL=${_APPFW_FEATURE_PRIORITY_CHANGE} \ + -D_TIZEN_FEATURE_PRIORITY_CHANGE:BOOL=${_TIZEN_FEATURE_PRIORITY_CHANGE} \ + -D_TIZEN_FEATURE_LOADER_PRIORITY:BOOL=${_TIZEN_FEATURE_LOADER_PRIORITY} \ . %__make %{?_smp_mflags} @@ -90,7 +95,11 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %{_unitdir_user}/launchpad-process-pool.socket %{_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 +%else %caps(cap_mac_admin,cap_dac_override,cap_setgid=ei) %{_bindir}/launchpad-process-pool +%endif %attr(0644,root,root) %{_libdir}/liblaunchpad.so.* %files devel @@ -102,4 +111,8 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %manifest %{name}.manifest %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 +%else %caps(cap_setgid=ei) %{_bindir}/launchpad-loader +%endif diff --git a/src/launchpad.c b/src/launchpad.c index 5cf71de..ce1a77f 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1695,21 +1695,6 @@ static void __after_loop(void) security_manager_app_labels_monitor_finish(label_monitor); } -#ifdef _APPFW_FEATURE_PRIORITY_CHANGE -static void __set_priority(void) -{ - char err_str[MAX_LOCAL_BUFSZ] = { 0, }; - int res; - - res = setpriority(PRIO_PROCESS, 0, -12); - if (res == -1) { - SECURE_LOGE("Setting process (%d) priority to -12 failed, " \ - "errno: %d (%s)", getpid(), errno, - strerror_r(errno, err_str, sizeof(err_str))); - } -} -#endif - int main(int argc, char **argv) { GMainLoop *mainloop = NULL; @@ -1725,8 +1710,8 @@ int main(int argc, char **argv) return -1; } -#ifdef _APPFW_FEATURE_PRIORITY_CHANGE - __set_priority(); +#ifdef TIZEN_FEATURE_PRIORITY_CHANGE + _set_priority(-12); #endif g_main_loop_run(mainloop); diff --git a/src/launchpad_common.c b/src/launchpad_common.c index e3d727e..7f15619 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "launchpad_common.h" #include "key.h" @@ -868,3 +870,16 @@ int _setup_stdio(const char *ident) return 0; } + +int _set_priority(int prio) +{ + int r; + + r = setpriority(PRIO_PGRP, 0, prio); + if (r < 0) { + SECURE_LOGE("Failed to set process(%d) priority(%d) - err(%d)", + getpid(), prio, errno); + } + + return r; +} diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 927046e..da0a357 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -22,10 +22,6 @@ #include #include #include -#ifdef _APPFW_FEATURE_LOADER_PRIORITY -#include -#include -#endif #include #include #include @@ -40,7 +36,6 @@ #endif #define AUL_PR_NAME 16 -#define LOWEST_PRIO 20 static loader_lifecycle_callback_s *__loader_callbacks; static loader_adapter_s *__loader_adapter; @@ -130,22 +125,6 @@ static int __default_launch_cb(bundle *kb, const char *appid, const char *pkgid, const char *pkg_type, int loader_type) { char err_str[MAX_LOCAL_BUFSZ] = { 0, }; -#ifdef _APPFW_FEATURE_PRIORITY_CHANGE - int res; - const char *high_priority = bundle_get_val(kb, AUL_K_HIGHPRIORITY); - - _D("high_priority: %s", high_priority); - if (strncmp(high_priority, "true", 4) == 0) { - res = setpriority(PRIO_PROCESS, 0, -10); - if (res == -1) { - SECURE_LOGE("Setting process (%d) priority " \ - "to -10 failed, errno: %d (%s)", - getpid(), errno, - strerror_r(errno, err_str, sizeof(err_str))); - } - } - bundle_del(kb, AUL_K_HIGHPRIORITY); -#endif if (__prepare_exec(appid, app_path, pkg_type, loader_type) < 0) { _E("__candidate_process_prepare_exec() failed"); @@ -296,16 +275,7 @@ static int __before_loop(int argc, char **argv) int client_fd; int ret = -1; bundle *extra = NULL; -#ifdef _APPFW_FEATURE_LOADER_PRIORITY - char err_str[MAX_LOCAL_BUFSZ] = { 0, }; - int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO); - if (res == -1) { - SECURE_LOGE("Setting process (%d) priority to %d failed, " \ - "errno: %d (%s)", getpid(), LOWEST_PRIO, errno, - strerror_r(errno, err_str, sizeof(err_str))); - } -#endif __preexec_init(argc, argv); /* Set new session ID & new process group ID*/ @@ -332,14 +302,7 @@ static int __before_loop(int argc, char **argv) bundle_free(extra); malloc_trim(0); -#ifdef _APPFW_FEATURE_LOADER_PRIORITY - res = setpriority(PRIO_PGRP, 0, 0); - if (res == -1) { - SECURE_LOGE("Setting process (%d) priority to 0 failed, " \ - "errno: %d (%s)", getpid(), errno, - strerror_r(errno, err_str, sizeof(err_str))); - } -#endif + client_fd = _connect_to_launchpad(__loader_type, __loader_id); if (client_fd == -1) { _D("Connecting to candidate process was failed."); @@ -414,3 +377,7 @@ API int launchpad_loader_main(int argc, char **argv, return __after_loop(); } +API int launchpad_loader_set_priority(int prio) +{ + return _set_priority(prio); +} diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index fdc60a5..01487de 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -36,7 +36,6 @@ #define LOADER_TYPE_HW "hw-loader" #define LOADER_TYPE_SW "sw-loader" - extern bundle *launchpad_loader_get_bundle(void); static Ecore_Fd_Handler *__fd_handler; @@ -181,6 +180,10 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data) return; } +#ifdef TIZEN_FEATURE_LOADER_PRIORITY + launchpad_loader_set_priority(19); +#endif + if (!strcmp(LOADER_TYPE_COMMON, ltype)) __type = TYPE_COMMON; else if (!strcmp(LOADER_TYPE_SW, ltype)) @@ -224,6 +227,9 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data) _E("Failed to register callback for %s", VCONFKEY_SETAPPL_APP_HW_ACCELERATION); } +#ifdef TIZEN_FEATURE_LOADER_PRIORITY + launchpad_loader_set_priority(0); +#endif } static loader_convertible __converter_table[MAX_LOADER_TYPE][MAX_ACC_TYPE] = { @@ -243,12 +249,24 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path, bundle *kb = launchpad_loader_get_bundle(); int acc = SW_ACC; loader_convertible convert; +#ifdef TIZEN_FEATURE_PRIORITY_CHANGE + const char *high_priority; +#endif vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, __vconf_cb); if (kb == NULL) return 0; +#ifdef TIZEN_FEATURE_PRIORITY_CHANGE + high_priority = bundle_get_val(kb, AUL_K_HIGHPRIORITY); + if (high_priority) { + if (!strcmp(high_priority, "true")) + launchpad_loader_set_priority(-12); + bundle_del(kb, AUL_K_HIGHPRIORITY); + } +#endif + hwacc = bundle_get_val(kb, AUL_K_HWACC); if (!hwacc) -- 2.7.4