From 41eace5928ed3f152f4886130d642906a1284c02 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 14 Dec 2016 19:11:25 +0900 Subject: [PATCH 01/16] Add exception for web widget Change-Id: If81203bbb86ca059d1edcc773fe9927947cfea2a Signed-off-by: Junghoon Park --- src/launchpad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/launchpad.c b/src/launchpad.c index a1d4618..6416bc1 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1355,6 +1355,10 @@ static gboolean __handle_launch_event(gpointer data) if (menu_info->comp_type && strcmp(menu_info->comp_type, "svcapp") == 0) { loader_id = PAD_LOADER_ID_DIRECT; + } else if (menu_info->comp_type && menu_info->app_type && + strcmp(menu_info->comp_type, "widgetapp") == 0 && + strcmp(menu_info->app_type, "webapp") == 0) { + loader_id = PAD_LOADER_ID_DIRECT; } else { loader_id = __get_loader_id(kb); if (loader_id <= PAD_LOADER_ID_STATIC) { -- 2.7.4 From 2855afa7f8aa9315fbffc3629cb1fa4624843672 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Thu, 15 Dec 2016 09:24:06 +0900 Subject: [PATCH 02/16] Replace 'readdir_r' with 'readdir' 'readdir_r' is deprecated since version 2.24 glibc. By upgrading TOOLCHAIN for platform, it should be replaced by 'readdir' Change-Id: I54ad1b8291f5148e2e294cb8219ce11b32f1db6c Signed-off-by: Inkyun Kil --- src/debugger_info.c | 11 +++++------ src/launcher_info.c | 11 +++++------ src/launchpad_common.c | 18 ++++++++---------- src/launchpad_signal.c | 2 +- src/loader_info.c | 11 +++++------ 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/debugger_info.c b/src/debugger_info.c index 4af4a2d..1ba596b 100644 --- a/src/debugger_info.c +++ b/src/debugger_info.c @@ -190,8 +190,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_debugger_info_load(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -203,14 +202,14 @@ GList *_debugger_info_load(const char *path) if (dp == NULL) return NULL; - while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) { - if (dentry.d_name[0] == '.') + while ((dentry = readdir(dp)) != NULL) { + if (dentry->d_name[0] == '.') continue; - ext = strrchr(dentry.d_name, '.'); + ext = strrchr(dentry->d_name, '.'); if (ext && strcmp(ext, ".debugger") == 0) { snprintf(buf, sizeof(buf), "%s/%s", - path, dentry.d_name); + path, dentry->d_name); list = __parse_file(list, buf); } } diff --git a/src/launcher_info.c b/src/launcher_info.c index 06b46ab..bff7a12 100644 --- a/src/launcher_info.c +++ b/src/launcher_info.c @@ -169,8 +169,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_launcher_info_load(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -182,14 +181,14 @@ GList *_launcher_info_load(const char *path) if (dp == NULL) return NULL; - while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) { - if (dentry.d_name[0] == '.') + while ((dentry = readdir(dp)) != NULL) { + if (dentry->d_name[0] == '.') continue; - ext = strrchr(dentry.d_name, '.'); + ext = strrchr(dentry->d_name, '.'); if (ext && strcmp(ext, ".launcher") == 0) { snprintf(buf, sizeof(buf), "%s/%s", - path, dentry.d_name); + path, dentry->d_name); list = __parse_file(list, buf); } } diff --git a/src/launchpad_common.c b/src/launchpad_common.c index aa4b909..dbfbee4 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -659,8 +659,7 @@ int _proc_get_attr_by_pid(int pid, char *buf, int size) static int __delete_dir(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; char buf[PATH_MAX]; struct stat statbuf; int ret; @@ -672,11 +671,11 @@ static int __delete_dir(const char *path) if (dp == NULL) return -1; - while (readdir_r(dp, &dentry, &result) == 0 && result) { - if (!strcmp(dentry.d_name, ".") || !strcmp(dentry.d_name, "..")) + while ((dentry = readdir(dp)) != NULL) { + if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, "..")) continue; - snprintf(buf, sizeof(buf), "%s/%s", path, dentry.d_name); + snprintf(buf, sizeof(buf), "%s/%s", path, dentry->d_name); ret = stat(buf, &statbuf); if (ret == 0) { if (S_ISDIR(statbuf.st_mode)) @@ -709,8 +708,7 @@ int _delete_sock_path(int pid, uid_t uid) int _close_all_fds(void) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; int fd; int max_fd; @@ -724,11 +722,11 @@ int _close_all_fds(void) return 0; } - while (readdir_r(dp, &dentry, &result) == 0 && result) { - if (!isdigit(dentry.d_name[0])) + while ((dentry = readdir(dp)) != NULL) { + if (!isdigit(dentry->d_name[0])) continue; - fd = atoi(dentry.d_name); + fd = atoi(dentry->d_name); if (fd < 3) continue; diff --git a/src/launchpad_signal.c b/src/launchpad_signal.c index e802ca4..1742dcf 100644 --- a/src/launchpad_signal.c +++ b/src/launchpad_signal.c @@ -127,7 +127,7 @@ static gboolean __flush_pending_signal(gpointer data) static void __socket_garbage_collector(void) { DIR *dp; - struct dirent *dentry; + struct dirent *dentry = NULL; char tmp[MAX_LOCAL_BUFSZ]; snprintf(tmp, sizeof(tmp), "/run/aul/apps/%d", getuid()); diff --git a/src/loader_info.c b/src/loader_info.c index c0ded9f..c4ac48c 100644 --- a/src/loader_info.c +++ b/src/loader_info.c @@ -225,8 +225,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_loader_info_load(const char *path) { DIR *dir_info; - struct dirent entry; - struct dirent *result = NULL; + struct dirent *entry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -235,12 +234,12 @@ GList *_loader_info_load(const char *path) if (dir_info == NULL) return NULL; - while (readdir_r(dir_info, &entry, &result) == 0 && result != NULL) { - if (entry.d_name[0] == '.') + while ((entry = readdir(dir_info)) != NULL) { + if (entry->d_name[0] == '.') continue; - ext = strrchr(entry.d_name, '.'); + ext = strrchr(entry->d_name, '.'); if (ext && !strcmp(ext, ".loader")) { - snprintf(buf, sizeof(buf), "%s/%s", path, entry.d_name); + snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); list = __parse_file(list, buf); } } -- 2.7.4 From c60f9c884a7832f1a29ee1deb38d04ed0174c48b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 16 Dec 2016 17:05:03 +0900 Subject: [PATCH 03/16] Remove calling dlclose Change-Id: Ic7c086f9f1d517e9c3d0c672951ba4713d299981 Signed-off-by: Hwankyu Jhun --- src/launchpad_loader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 35850a9..9e6d08c 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -320,7 +320,6 @@ do_dlopen: free(libdir); res = dl_main(argc, argv); - dlclose(handle); elm_shutdown(); return res; -- 2.7.4 From 10fff8d425c3fd1296cd023b8a365d17e1d614b2 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 16 Dec 2016 18:48:22 +0900 Subject: [PATCH 04/16] Add AUL_LOADER_INIT to the environment - Requires https://review.tizen.org/gerrit/105374 Change-Id: If6a483c333f13b163b8a22b49defe1d848c4632e Signed-off-by: Hwankyu Jhun --- src/launchpad_loader.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 9e6d08c..5dfe2e1 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -195,6 +195,7 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data) elm_init_cnt = elm_init(__argc, __argv); _D("[candidate] elm init, returned: %d", elm_init_cnt); + setenv("AUL_LOADER_INIT", "1", 1); switch (__type) { case TYPE_SW: @@ -270,7 +271,6 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path, static int __loader_terminate_cb(int argc, char **argv, void *user_data) { void *handle; - int res; int (*dl_main)(int, char **); char err_str[MAX_LOCAL_BUFSZ]; char old_cwd[PATH_MAX]; @@ -319,10 +319,7 @@ do_dlopen: } free(libdir); - res = dl_main(argc, argv); - elm_shutdown(); - - return res; + return dl_main(argc, argv); do_exec: if (access(argv[LOADER_ARG_PATH], F_OK | R_OK)) { @@ -336,6 +333,7 @@ do_exec: if (libdir) setenv("LD_LIBRARY_PATH", libdir, 1); free(libdir); + unsetenv("AUL_LOADER_INIT"); if (execv(argv[LOADER_ARG_PATH], argv) < 0) { SECURE_LOGE("execv() failed for file: \"%s\", " \ "error: %d (%s)", argv[LOADER_ARG_PATH], errno, -- 2.7.4 From 93341bd35b6537e83e1335a70deddbf6a0efc9cd Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 5 Dec 2016 22:59:05 +0900 Subject: [PATCH 05/16] AMD moves to system session - Make aul directories - Send launch/dead signal to amd - Make default slots by cpu usage Change-Id: Ie41fbeb3155a14b5c382d79cad53b5c4c7393934 Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 5 +++ packaging/launchpad-process-pool.service | 4 ++ src/launchpad.c | 25 +++++++++--- src/launchpad_common.c | 67 ++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 6 deletions(-) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index f1907c1..8016469 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -44,6 +44,10 @@ #define PAD_CMD_REMOVE_LOADER 12 #define PAD_CMD_MAKE_DEFAULT_SLOTS 13 #define PAD_CMD_DEMAND 14 +#define PAD_CMD_PING 15 + +#define LAUNCHPAD_LAUNCH_SIGNAL 85 +#define LAUNCHPAD_DEAD_SIGNAL 61 #define PAD_LOADER_ID_STATIC 0 #define PAD_LOADER_ID_DIRECT 1 @@ -85,6 +89,7 @@ typedef struct { void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd); +int _send_cmd_to_amd(int cmd); int _create_server_sock(const char *name); app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr); int _send_pkt_raw(int client_fd, app_pkt_t *pkt); diff --git a/packaging/launchpad-process-pool.service b/packaging/launchpad-process-pool.service index 2d633ec..c890e2d 100644 --- a/packaging/launchpad-process-pool.service +++ b/packaging/launchpad-process-pool.service @@ -5,11 +5,15 @@ [Unit] Description=Start the USER Access Control Agent DefaultDependencies=false +Requires=enlightenment-user.service +After=enlightenment-user.service [Service] ExecStartPre=-/usr/bin/mkdir -p /run/aul/daemons/%U 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 ExecStart=/bin/sh -l -c "/usr/bin/launchpad-process-pool" Sockets=launchpad-process-pool.socket diff --git a/src/launchpad.c b/src/launchpad.c index 6416bc1..5305dc6 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1319,6 +1319,10 @@ static gboolean __handle_launch_event(gpointer data) __real_send(clifd, ret); clifd = -1; goto end; + case PAD_CMD_PING: + __real_send(clifd, 0); + clifd = -1; + goto end; } INIT_PERF(kb); @@ -1575,7 +1579,8 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) candidate_process_context_t *cpc; bundle_raw *extra = NULL; int len; - int ret; + long long total = 0; + long long idle = 0; if (!strcmp(info->exe, "null")) { cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset, @@ -1600,11 +1605,11 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) if (cpc == NULL) return; - ret = __prepare_candidate_process( - LAUNCHPAD_TYPE_USER + user_slot_offset, - PAD_LOADER_ID_STATIC); - if (ret != 0) - return; + _get_cpu_idle(&total, &idle); + cpc->cpu_idle_time = idle; + cpc->cpu_total_time = total; + cpc->idle_checker = g_timeout_add(CPU_CHECKER_TIMEOUT, + __handle_idle_checker, cpc); info->type = LAUNCHPAD_TYPE_USER + user_slot_offset; user_slot_offset++; @@ -1672,13 +1677,21 @@ static int __before_loop(int argc, char **argv) VCONFKEY_SETAPPL_APP_HW_ACCELERATION); } + __add_default_slots(); launcher_info_list = _launcher_info_load(LAUNCHER_INFO_PATH); + ret = _send_cmd_to_amd(LAUNCHPAD_LAUNCH_SIGNAL); + if (ret < 0) + _W("Failed to send cmd(%d) to amd", LAUNCHPAD_LAUNCH_SIGNAL); + return 0; } static void __after_loop(void) { + if (_send_cmd_to_amd(LAUNCHPAD_DEAD_SIGNAL) < 0) + _W("Failed to send cmd(%d) to amd", LAUNCHPAD_DEAD_SIGNAL); + _debug_fini(); _launcher_info_unload(launcher_info_list); diff --git a/src/launchpad_common.c b/src/launchpad_common.c index aa4b909..ddb4432 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -43,6 +43,7 @@ #define CONNECT_RETRY_TIME (100 * 1000) #define CONNECT_RETRY_COUNT 3 #define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int) + sizeof(int)) +#define PATH_AMD_SOCK "/run/aul/daemons/.amd-sock" static int __read_proc(const char *path, char *buf, int size) { @@ -208,6 +209,72 @@ static int __parse_app_path(const char *arg, char *out, int out_size) return -2; } +int _send_cmd_to_amd(int cmd) +{ + struct sockaddr_un addr = {0,}; + int fd; + int ret; + int res; + int retry = CONNECT_RETRY_COUNT; + app_pkt_t pkt = {0,}; + + fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + /* support above version 2.6.27*/ + if (fd < 0) { + if (errno == EINVAL) { + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + _E("second chance - socket create error"); + return -1; + } + } else { + _E("socket error"); + return -1; + } + } + + addr.sun_family = AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", PATH_AMD_SOCK); + while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (errno != ETIMEDOUT || retry <= 0) { + _E("Failed to connect error(%d)", errno); + close(fd); + return -1; + } + + usleep(CONNECT_RETRY_TIME); + --retry; + _D("re-connect to %s (%d)", addr.sun_path, retry); + } + + pkt.cmd = cmd; + ret = send(fd, &pkt, sizeof(app_pkt_t), 0); + if (ret <= 0) { + _E("Failed to send cmd(%d), errno(%d)", cmd, errno); + close(fd); + return -ECOMM; + } + +retry_recv: + ret = recv(fd, &res, sizeof(int), 0); + if (ret <= 0) { + if (errno == EAGAIN) { + _E("recv timeout"); + res = -EAGAIN; + } else if (errno == EINTR) { + _D("Interrupted system call"); + goto retry_recv; + } else { + _E("recv error(%d)", errno); + res = -ECOMM; + } + } + + close(fd); + + return res; +} + int _create_server_sock(const char *name) { struct sockaddr_un saddr; -- 2.7.4 From 1a09eaea16b76ca953793e77a3a0f1b18f647720 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 15 Dec 2016 16:02:42 +0900 Subject: [PATCH 06/16] Redirect std fds before exec stdin -> /dev/null stdout -> journal fd or /dev/null stderr -> journal fd or /dev/null Change-Id: I7346df00a668c2cb08098a93ad15db97a1e8d2f7 Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 1 + inc/launchpad_common.h | 1 + src/launchpad.c | 3 +++ src/launchpad_common.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/launchpad_lib.c | 2 ++ 5 files changed, 60 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2989bb8..15735c7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED aul vconf buxton2 + libsystemd-daemon ) FOREACH(flag ${${this_target_loader}_CFLAGS}) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 8016469..63a9de3 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -106,6 +106,7 @@ char *_appinfo_get_app_path(appinfo_t *menu_info); int _proc_get_attr_by_pid(int pid, char *buf, int size); int _close_all_fds(void); void _get_cpu_idle(long long *total, long long *idle); +int _setup_stdio(const char *ident); #endif /* __LAUNCHPAD_COMMON_H__ */ diff --git a/src/launchpad.c b/src/launchpad.c index 5305dc6..0ccd9f9 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "perf.h" #include "launchpad_common.h" @@ -387,6 +388,7 @@ static int __exec_loader_process(void *arg) _signal_fini(); _close_all_fds(); + _setup_stdio(basename(argv[LOADER_ARG_PATH])); if (execv(argv[LOADER_ARG_PATH], argv) < 0) _E("Failed to prepare candidate_process"); @@ -507,6 +509,7 @@ static int __normal_fork_exec(int argc, char **argv, const char *app_path) } _close_all_fds(); + _setup_stdio(basename(argv[LOADER_ARG_PATH])); if (execv(argv[LOADER_ARG_PATH], argv) < 0) { /* Flawfinder: ignore */ if (errno == EACCES) { _E("such a file is no executable - %s", diff --git a/src/launchpad_common.c b/src/launchpad_common.c index ddb4432..a0f6c3b 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "launchpad_common.h" #include "key.h" @@ -44,6 +46,7 @@ #define CONNECT_RETRY_COUNT 3 #define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int) + sizeof(int)) #define PATH_AMD_SOCK "/run/aul/daemons/.amd-sock" +#define PATH_DEV_NULL "/dev/null" static int __read_proc(const char *path, char *buf, int size) { @@ -809,3 +812,53 @@ int _close_all_fds(void) return 0; } +int _setup_stdio(const char *ident) +{ + int fd; + + /* stdin */ + fd = open(PATH_DEV_NULL, O_RDONLY | O_NOCTTY); + if (fd < 0) { + _W("Failed to open /dev/null - err(%d)", errno); + return -1; + } + if (dup2(fd, STDIN_FILENO) < 0) { + _W("Failed to duplicate fd - oldfd(%d), newfd(%d)", + fd, STDIN_FILENO); + } + close(fd); + + /* stdout */ + fd = sd_journal_stream_fd(ident, LOG_INFO, false); + if (fd < 0) { + _W("Failed to connect journal socket - err(%d)", errno); + fd = open(PATH_DEV_NULL, O_WRONLY | O_NOCTTY); + if (fd < 0) { + _W("Failed to open /dev/null - err(%d)", errno); + return -1; + } + } + if (dup2(fd, STDOUT_FILENO) < 0) { + _W("Failed to duplicate fd - oldfd(%d), newfd(%d)", + fd, STDOUT_FILENO); + } + close(fd); + + /* stderr */ + fd = sd_journal_stream_fd(ident, LOG_INFO, false); + if (fd < 0) { + _W("Failed to connect journal socket - err(%d)", errno); + fd = open(PATH_DEV_NULL, O_WRONLY | O_NOCTTY); + if (fd < 0) { + _W("Failed to open /dev/null - err(%d)", errno); + return -1; + } + } + if (dup2(fd, STDERR_FILENO) < 0) { + _W("Failed to duplicate fd - oldfd(%d), newfd(%d)", + fd, STDERR_FILENO); + } + close(fd); + + return 0; +} diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 6336a19..17553ba 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -77,6 +77,8 @@ static int __prepare_exec(const char *appid, const char *app_path, return -1; } + _setup_stdio(basename(app_path)); + ret = buxton_open(&bxt_cli, NULL, NULL); if (ret != 0) { _E("buxton_open() failed"); -- 2.7.4 From 7f7bbff6dc60f4a92997a71fbfd9166539058e8b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 21 Dec 2016 16:36:01 +0900 Subject: [PATCH 07/16] Fix standard I/O redirection - The child process doesn't redirect std fds when the launch request is for debugging. Change-Id: I10958679eda3ab88dd515bc6025074a5cffd0598 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index 0ccd9f9..f1c8011 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "perf.h" #include "launchpad_common.h" @@ -509,7 +508,7 @@ static int __normal_fork_exec(int argc, char **argv, const char *app_path) } _close_all_fds(); - _setup_stdio(basename(argv[LOADER_ARG_PATH])); + if (execv(argv[LOADER_ARG_PATH], argv) < 0) { /* Flawfinder: ignore */ if (errno == EACCES) { _E("such a file is no executable - %s", @@ -716,6 +715,9 @@ static int __prepare_exec(const char *appid, const char *app_path, return PAD_ERR_REJECTED; } + if (bundle_get_type(kb, AUL_K_SDK) == BUNDLE_TYPE_NONE) + _setup_stdio(basename(app_path)); + /* SET DUMPABLE - for coredump*/ prctl(PR_SET_DUMPABLE, 1); -- 2.7.4 From 6f59e47b0770f4ce5cd0a3ef3475d00b4047b4e9 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Wed, 28 Dec 2016 19:15:16 +0900 Subject: [PATCH 08/16] Do not wait response from amd for launch/dead command We don't need to wait response from amd. It may lead deadlock between launchpad and amd. Change-Id: I75767b69d404fb28ce0059385026c5107a13cc71 Signed-off-by: Semun Lee --- src/launchpad_common.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/launchpad_common.c b/src/launchpad_common.c index a0f6c3b..a440731 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -217,7 +217,6 @@ int _send_cmd_to_amd(int cmd) struct sockaddr_un addr = {0,}; int fd; int ret; - int res; int retry = CONNECT_RETRY_COUNT; app_pkt_t pkt = {0,}; @@ -258,24 +257,8 @@ int _send_cmd_to_amd(int cmd) return -ECOMM; } -retry_recv: - ret = recv(fd, &res, sizeof(int), 0); - if (ret <= 0) { - if (errno == EAGAIN) { - _E("recv timeout"); - res = -EAGAIN; - } else if (errno == EINTR) { - _D("Interrupted system call"); - goto retry_recv; - } else { - _E("recv error(%d)", errno); - res = -ECOMM; - } - } - close(fd); - - return res; + return 0; } int _create_server_sock(const char *name) -- 2.7.4 From 40d1b92e64809e7e9f3fae483957c6ce070ee936 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 4 Jan 2017 19:08:56 +0900 Subject: [PATCH 09/16] Remove permission check This patch removes the permission check for executing an application with the debug tool. Change-Id: I66a86012d197edaf120e87e6d455eca72f88c5b9 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index f1c8011..9177a5f 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1263,7 +1263,6 @@ static gboolean __handle_launch_event(gpointer data) int type = -1; int loader_id; int ret; - int caller_pid; traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "LAUNCHPAD:LAUNCH"); pkt = _recv_pkt_raw(fd, &clifd, &cr); @@ -1285,16 +1284,8 @@ static gboolean __handle_launch_event(gpointer data) goto end; } - if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) { - caller_pid = _debug_get_caller_pid(kb); - if (caller_pid > 0) { - if (__check_caller_by_pid(caller_pid) < 0) { - _E("Invalid caller pid"); - goto end; - } - } + if (bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) _debug_init(); - } switch (pkt->cmd) { case PAD_CMD_VISIBILITY: -- 2.7.4 From 51a5f2cc0d9b1b07cda190e787fc61b37139222d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 20 Jan 2017 07:51:15 +0900 Subject: [PATCH 10/16] Prevent SIGPIPE - Use MSG_NOSIGNAL option Change-Id: I62cbf54ca004b65e022f3365ee6930a92674b165 Signed-off-by: Hwankyu Jhun --- src/launchpad_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 8d6c001..5e998c5 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -250,7 +250,7 @@ int _send_cmd_to_amd(int cmd) } pkt.cmd = cmd; - ret = send(fd, &pkt, sizeof(app_pkt_t), 0); + ret = send(fd, &pkt, sizeof(app_pkt_t), MSG_NOSIGNAL); if (ret <= 0) { _E("Failed to send cmd(%d), errno(%d)", cmd, errno); close(fd); @@ -392,7 +392,7 @@ int _send_pkt_raw(int client_fd, app_pkt_t *pkt) pkt_size = AUL_PKT_HEADER_SIZE + pkt->len; - send_ret = send(client_fd, pkt, pkt_size, 0); + send_ret = send(client_fd, pkt, pkt_size, MSG_NOSIGNAL); _D("send(%d) : %d / %d", client_fd, send_ret, pkt_size); if (send_ret == -1) { @@ -609,7 +609,7 @@ int _connect_to_launchpad(int type, int id) _D("re-connect to %s (%d)", addr.sun_path, retry); } - send_ret = send(fd, &client_pid, sizeof(client_pid), 0); + send_ret = send(fd, &client_pid, sizeof(client_pid), MSG_NOSIGNAL); _D("send(%d) : %d", client_pid, send_ret); if (send_ret == -1) { -- 2.7.4 From 546a36fb7b3153e33484621c5e95a4e4ba31859e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 24 Jan 2017 07:58:10 +0900 Subject: [PATCH 11/16] Fix versioning Change-Id: I5acf92bcbb9d94d415cbe5f2f09f701503d11d53 Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 3 +-- packaging/launchpad.spec | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15735c7..e0c208f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET (this_target_pool launchpad_pool) SET (this_target_loader launchpad_loader) SET (this_target_lib launchpad) -SET (VERSION_MAJOR 0) INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(${this_target_pool} REQUIRED @@ -126,7 +125,7 @@ ADD_LIBRARY(${LAUNCHPAD_LIB} SHARED src/launchpad_lib.c src/launchpad_common.c ) -SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES VERSION ${VERSION}) SET_TARGET_PROPERTIES(${LAUNCHPAD_LIB} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_lib}) TARGET_LINK_LIBRARIES(${LAUNCHPAD_LIB} ${${this_target_lib}_LDFLAGS} "-ldl") diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 7c50db3..b3da97e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -55,7 +55,9 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" _APPFW_FEATURE_PRIORITY_CHANGE=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} \ . %__make %{?_smp_mflags} -- 2.7.4 From 4611c50ea1b10aa68fe374b17bd57996305ec71f Mon Sep 17 00:00:00 2001 From: Hawnkyu Jhun Date: Sun, 22 Jan 2017 09:43:11 +0900 Subject: [PATCH 12/16] Split the packages This patch is to remove the dependency of UI libraries. Change-Id: Ie2009fe7c35b4cb8fa3150765218350d7b5d1188 Signed-off-by: Hawnkyu Jhun --- packaging/launchpad.spec | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index b3da97e..a986990 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -42,6 +42,13 @@ Requires: %{name} = %{version}-%{release} %description devel Launchpad for launching applications (devel) +%package -n launchpad-loader +Summary: Launchpad-Loader for launching applications +Group: Application Framework/Application Launcher + +%description -n launchpad-loader +Launchpad-Loader for launching applications + %prep %setup -q @@ -81,17 +88,20 @@ cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{nam %files %manifest launchpad.manifest %{_prefix}/share/license/%{name} -%{_prefix}/share/aul/default.loader %{_prefix}/share/aul/default.debugger %{_unitdir_user}/launchpad-process-pool.service %{_unitdir_user}/launchpad-process-pool.socket %{_unitdir_user}/sockets.target.wants/launchpad-process-pool.socket %{_unitdir_user}/basic.target.wants/launchpad-process-pool.service %caps(cap_mac_admin,cap_dac_override,cap_setgid=ei) %{_bindir}/launchpad-process-pool -%caps(cap_setgid=ei) %{_bindir}/launchpad-loader %attr(0644,root,root) %{_libdir}/liblaunchpad.so.* %files devel %{_includedir}/launchpad/*.h %{_libdir}/*.so %{_libdir}/pkgconfig/*.pc + +%files -n launchpad-loader +%manifest %{name}.manifest +%{_prefix}/share/aul/default.loader +%caps(cap_setgid=ei) %{_bindir}/launchpad-loader -- 2.7.4 From 86163559ad4bef26a6f874bc4a0d91344ddce8bc Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 25 Jan 2017 13:16:58 +0900 Subject: [PATCH 13/16] Release version 0.3.0 Changes: - Split the packages - Fix versioning - Prevent SIGPIPE Change-Id: I044d588557b50c7b92cc9dd5fbf6d2ae9b89b754 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 a986990..fc4b71e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.3.14 +Version: 0.2.4 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From ca8232743d649980ab48a713d22f7c91ca21e469 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 25 Jan 2017 16:39:11 +0900 Subject: [PATCH 14/16] Remove adding the conformant object to the window object The launchpad-loader doesn't call the elm_win_resize_object_add() when creating the conformant object. Change-Id: I26476a248d7f2faceff9692e985e33a827714ac4 Signed-off-by: Hwankyu Jhun --- src/launchpad_loader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 5dfe2e1..fdc60a5 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -113,7 +113,6 @@ static void __init_window(void) if (__conform) { evas_object_size_hint_weight_set(__conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(__win, __conform); elm_conformant_precreated_object_set(__conform); } else { _E("elm_conformant_add() failed"); -- 2.7.4 From e85b65847a5904ebe3bebd1290b030066b02b5e1 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 2 Feb 2017 19:25:28 +0900 Subject: [PATCH 15/16] Add the pid to the environment When the application is launched by the debugger, the application is a child process of the debugger. The process group of the appliation is not equal to the process id of the debugger. If the process id is not equal to the process pid of the environment variable, the aul socket API will create the socket link to recevie the request. Requires: - https://review.tizen.org/gerrit/112668 Change-Id: I2f63a9cf74f13157b6cd39c8ad5d37489a37165a Signed-off-by: Hwankyu Jhun --- src/launchpad_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 5e998c5..201c3d9 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -630,6 +630,7 @@ error: void _set_env(appinfo_t *menu_info, bundle *kb) { const char *str; + char buf[MAX_LOCAL_BUFSZ]; str = bundle_get_val(kb, AUL_K_STARTTIME); if (str != NULL) @@ -657,6 +658,9 @@ void _set_env(appinfo_t *menu_info, bundle *kb) str = bundle_get_val(kb, AUL_K_API_VERSION); if (str != NULL) setenv("TIZEN_API_VERSION", str, 1); + + snprintf(buf, sizeof(buf), "%d", getpid()); + setenv("AUL_PID", buf, 1); } char **_create_argc_argv(bundle *kb, int *margc) -- 2.7.4 From 392da6610fed92d659c31689ef5b1b6188e2fe57 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 3 Feb 2017 14:35:58 +0900 Subject: [PATCH 16/16] Release version 0.2.5 Changes: - Add the pid to the environment - Remove adding the conformant object to the window object Change-Id: Iba2f198373ab63ae3390ef404482630f8964d591 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 fc4b71e..c75f4d5 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.2.4 +Version: 0.2.5 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4