From 1d852674ea00c02970c83d17bb96068f31f6b991 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 11 Jan 2019 10:27:25 +0900 Subject: [PATCH 01/16] Add exception handler Change-Id: Ifeef5d88ee8596fea184cbbf0bd7f4802baa5461 Signed-off-by: Junghoon Park --- src/loader_info.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/loader_info.c b/src/loader_info.c index 8fd9a8f..55ea192 100644 --- a/src/loader_info.c +++ b/src/loader_info.c @@ -195,6 +195,8 @@ static void __add_extra_array_from_list(bundle *b, const char *key, GList *list) len = g_list_length(list); array = malloc(sizeof(const char *) * len); + if (array == NULL) + return; cur = list; for (i = 0; i < len; i++) { -- 2.7.4 From 2f2a047f86dcd9bf93571b46e5cd8f3308e0fcc6 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 11 Jan 2019 10:37:33 +0900 Subject: [PATCH 02/16] Release version 0.5.23 Changes: - Add exception handler Change-Id: I00bad815a119a3239dd4433c527958cfa194defe 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 dc669f1..f467663 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.22 +Version: 0.5.23 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b633656811ffd4000232be633a070ca761867ec4 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Jan 2019 15:27:36 +0900 Subject: [PATCH 03/16] Fix static analysis issues - Checks return values - Checks the file descriptor Change-Id: Id9bc94e63b44e959f8c1cfeb20965b44724fa592 Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 2 +- src/launchpad.c | 10 ++++++++- src/launchpad_common.c | 56 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 3b789f5..4662d3d 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -111,7 +111,7 @@ app_pkt_t *_recv_pkt_raw(int fd); app_pkt_t *_accept_recv_pkt_raw(int fd, int *clifd, struct ucred *cr); int _send_pkt_raw(int client_fd, app_pkt_t *pkt); int _connect_to_launchpad(int type, int id); -void _set_sock_option(int fd, int cli); +int _set_sock_option(int fd, int cli); void _set_env(appinfo_t *menu_info, bundle *kb); char **_create_argc_argv(bundle *kb, int *margc); char *_get_libdir(const char *path); diff --git a/src/launchpad.c b/src/launchpad.c index 3fa9a2f..3b2592a 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -432,7 +432,10 @@ static int __accept_candidate_process(int server_fd, int *out_client_fd, goto error; } - _set_sock_option(client_fd, 1); + if (_set_sock_option(client_fd, 1) < 0) { + _E("Failed to set sock option"); + goto error; + } recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL); @@ -515,6 +518,11 @@ static int __candidate_process_real_launch(int candidate_fd, app_pkt_t *pkt) static int __real_send(int clifd, int ret) { + if (clifd < 3) { + _E("Invalid parameter. clifd(%d)", clifd); + return -1; + } + if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) { if (errno == EPIPE) { _E("send failed due to EPIPE."); diff --git a/src/launchpad_common.c b/src/launchpad_common.c index e1d22c8..da3ba04 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -134,21 +134,47 @@ void _get_cpu_idle(unsigned long long *total, unsigned long long *idle) *idle = iv; } -void _set_sock_option(int fd, int cli) +int _set_sock_option(int fd, int cli) { + struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */ int size; int flag; - struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */ + int ret; size = AUL_SOCK_MAXBUFF; - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); + if (ret < 0) { + _E("Failed to set SO_SNDBUF option on socket. errno(%d)", + errno); + return -1; + } + + ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + if (ret < 0) { + _E("Failed to set SO_RCVBUF option on socket. errno(%d)", + errno); + return -1; + } + if (cli) { - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if (ret < 0) { + _E("Failed to set SO_RCVTIMEO option on socket. " \ + "errno(%d)", errno); + return -1; + } + flag = fcntl(fd, F_GETFD); flag |= FD_CLOEXEC; - fcntl(fd, F_SETFD, flag); + ret = fcntl(fd, F_SETFD, flag); + if (ret < 0) { + _E("Failed to manipulate fd(F_SETFD), errno(%d)", + errno); + return -1; + } } + + return 0; } static int __parse_app_path(const char *arg, char *out, int out_size) @@ -322,7 +348,11 @@ int _create_server_sock(const char *name) return -1; } - _set_sock_option(fd, 0); + if (_set_sock_option(fd, 0) < 0) { + _E("Failed to set sock option"); + close(fd); + return -1; + } if (listen(fd, 128) == -1) { _E("listen error"); @@ -413,7 +443,11 @@ app_pkt_t *_accept_recv_pkt_raw(int fd, int *clifd, struct ucred *cr) return NULL; } - _set_sock_option(newfd, 1); + if (_set_sock_option(newfd, 1) < 0) { + _E("Failed to set sock option"); + close(newfd); + return NULL; + } pkt = _recv_pkt_raw(newfd); if (pkt == NULL) { @@ -1175,7 +1209,11 @@ static int __create_app_socket(int pid, uid_t uid) return -1; } - _set_sock_option(fd, 0); + if (_set_sock_option(fd, 0) < 0) { + _E("Failed to set sock option"); + close(fd); + return -1; + } if (listen(fd, 128) < 0) { _E("Failed to listen %d, errno(%d)", fd, errno); -- 2.7.4 From e059bb5362d51afb84eb4ceb9f9a0d109938d90e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Jan 2019 13:41:27 +0900 Subject: [PATCH 04/16] Prepare ID file Before executing an application, the child process creates the ID file. If's for Application Manager. Change-Id: I4e561b80071c12fb786ca89cab8a968d25e159ff Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 1 + src/launchpad.c | 4 ++++ src/launchpad_common.c | 17 +++++++++++++++++ src/launchpad_lib.c | 4 ++++ 4 files changed, 26 insertions(+) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 4662d3d..4776a44 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -129,6 +129,7 @@ int _wait_tep_mount(bundle *b); int _prepare_app_socket(void); int _enable_external_pkg(bundle *b, const char *pkgid, uid_t pkg_uid); int _verify_proc_caps(void); +int _prepare_id_file(void); #endif /* __LAUNCHPAD_COMMON_H__ */ diff --git a/src/launchpad.c b/src/launchpad.c index 3b2592a..f6d5301 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1005,6 +1005,10 @@ static int __prepare_exec(const char *appid, const char *app_path, ret = _prepare_app_socket(); if (ret < 0) return PAD_ERR_FAILED; + + ret = _prepare_id_file(); + if (ret < 0) + return PAD_ERR_FAILED; } return 0; diff --git a/src/launchpad_common.c b/src/launchpad_common.c index da3ba04..21cb409 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -1353,3 +1353,20 @@ int _verify_proc_caps(void) return 0; } + +int _prepare_id_file(void) +{ + char path[PATH_MAX]; + int fd; + + snprintf(path, sizeof(path), "/run/aul/apps/%u/%d/%s", + getuid(), getpid(), getenv("AUL_APPID")); + fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0600); + if (fd < 0) { + _E("Failed to create %s. errno(%d)", path, errno); + return -1; + } + close(fd); + + return 0; +} diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index dd7620a..4041141 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -145,6 +145,10 @@ static int __prepare_exec(const char *appid, const char *app_path, if (ret < 0) return -1; + ret = _prepare_id_file(); + if (ret < 0) + return -1; + return 0; } -- 2.7.4 From 9418989c30aa2fb4295541bed45bf3d096a589f6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 18 Jan 2019 11:45:14 +0900 Subject: [PATCH 05/16] Release version 0.5.24 Changes: - Fix static analysis issues - Prepare ID file Change-Id: I6c70eae7bc35fdc1f32df7a5633be8ebfa8182b7 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 f467663..5280a9e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.23 +Version: 0.5.24 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From e35854c0404fe5c3945a2ddb8365c9725482bd8f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 31 Jan 2019 09:21:47 +0900 Subject: [PATCH 06/16] Fix a bug about handling loader info If there is a loader that has not been used even once, it can be executed with the wrong loader at re-run. Because, the default value of the type is zero and the first loader is also zero. This patch changes the reference value. Change-Id: I2df4d632cb1e8a3268ef0edf53a65b8cfe475513 Signed-off-by: Hwankyu Jhun --- inc/launchpad.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/launchpad.h b/inc/launchpad.h index 7c2cae8..b5a11db 100644 --- a/inc/launchpad.h +++ b/inc/launchpad.h @@ -51,7 +51,7 @@ typedef struct { enum LAUNCHPAD_TYPE { LAUNCHPAD_TYPE_UNSUPPORTED = -1, - LAUNCHPAD_TYPE_USER, + LAUNCHPAD_TYPE_USER = 1, LAUNCHPAD_TYPE_DYNAMIC = 100, LAUNCHPAD_TYPE_MAX }; -- 2.7.4 From 52fedae37733b880f04a0c1702691adc6550d38d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 31 Jan 2019 10:00:46 +0900 Subject: [PATCH 07/16] Release version 0.5.25 Changes: - Fix a bug about handling loader info Change-Id: Ifce07a71e86a39b79a79aafc5623590920196893 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 5280a9e..b6f9392 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.24 +Version: 0.5.25 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 5920afaba67b4163a6043771763b93567d589931 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 28 Feb 2019 16:19:31 +0900 Subject: [PATCH 08/16] Add exceptions for debugging Change-Id: Iad5fccc7f0b8f88347691c6598339fc1e7c52741 Signed-off-by: Hwankyu Jhun --- src/launchpad_loader.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 2de8982..ba5e8f7 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -159,8 +159,17 @@ static void __preload_lib(bundle *b) return; for (i = 0; i < len; i++) { - handle = dlopen(so_array[i], RTLD_NOW | RTLD_NODELETE); + if (!so_array[i]) { + _E("so_array[%d] is nullptr", i); + continue; + } + if (so_array[i][0] == '\0') { + _E("so_array[%d] is empty string", i); + continue; + } + _D("preload %s# - handle : %p", so_array[i], handle); + handle = dlopen(so_array[i], RTLD_NOW | RTLD_NODELETE); if (!handle) { _E("failed to load: %s, err: %s", so_array[i], dlerror()); -- 2.7.4 From 091d1d994596ed1a3993dc19bd07b7ca589c9f8c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 5 Mar 2019 10:07:57 +0900 Subject: [PATCH 09/16] Add a logger socket for printing errors If execv() call is failed, the child process sends messages to launchpad. And then, launchpad prints the messages by secure dlog. Change-Id: I55be076dd095efb9d7addfa36b84dc2362d9daf7 Signed-off-by: Hwankyu Jhun --- inc/launchpad_common.h | 1 + src/launchpad.c | 83 ++++++++++++++++++++++++---- src/launchpad_common.c | 145 +++++++++++++++++++++++++++++++------------------ src/launchpad_loader.c | 5 +- 4 files changed, 168 insertions(+), 66 deletions(-) diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 4776a44..c4eefbc 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -105,6 +105,7 @@ typedef struct { void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd); +int _send_message_to_logger(const char *tag, const char *format, ...); int _send_cmd_to_amd(int cmd); int _create_server_sock(const char *name); app_pkt_t *_recv_pkt_raw(int fd); diff --git a/src/launchpad.c b/src/launchpad.c index f6d5301..bcb331f 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -53,6 +53,7 @@ #define DIFF(a, b) (((a) > (b)) ? (a) - (b) : (b) - (a)) #define CANDIDATE_NONE 0 #define PROCESS_POOL_LAUNCHPAD_SOCK ".launchpad-process-pool-sock" +#define LAUNCHPAD_LOGGER_SOCK ".launchpad-logger-sock" #define LOADER_PATH_DEFAULT "/usr/bin/launchpad-loader" #define LOADER_INFO_PATH "/usr/share/aul" #define LAUNCHER_INFO_PATH LOADER_INFO_PATH @@ -577,15 +578,19 @@ static int __fork_app_process(int (*child_fn)(void *), void *arg) static int __exec_loader_process(void *arg) { char **argv = arg; + char err_buf[1024]; _signal_unblock_sigchld(); _close_all_fds(); _setup_stdio(basename(argv[LOADER_ARG_PATH])); - if (execv(argv[LOADER_ARG_PATH], argv) < 0) - _E("Failed to prepare candidate_process"); - else + if (execv(argv[LOADER_ARG_PATH], argv) < 0) { + _send_message_to_logger(argv[LOADER_ARG_PATH], + "Failed to prepare candidate process. error(%d:%s)", + errno, strerror_r(errno, err_buf, sizeof(err_buf))); + } else { _D("Succeeded to prepare candidate_process"); + } return -1; } @@ -739,6 +744,7 @@ static int __send_launchpad_loader(candidate_process_context_t *cpc, static int __normal_fork_exec(int argc, char **argv, const char *app_path) { char *libdir; + char err_buf[1024]; _D("start real fork and exec"); @@ -751,13 +757,9 @@ static int __normal_fork_exec(int argc, char **argv, const char *app_path) _close_all_fds(); if (execv(argv[LOADER_ARG_PATH], argv) < 0) { /* Flawfinder: ignore */ - if (errno == EACCES) { - _E("such a file is no executable - %s", - argv[LOADER_ARG_PATH]); - } else { - _E("unknown executable error - %s", - argv[LOADER_ARG_PATH]); - } + _send_message_to_logger(argv[LOADER_ARG_PATH], + "Failed to execute a file. error(%d:%s)", + errno, strerror_r(errno, err_buf, sizeof(err_buf))); return -1; } /* never reach*/ @@ -2263,6 +2265,61 @@ static int __register_vconf_events(void) return 0; } +static gboolean __handle_logger(gpointer data) +{ + loader_context_t *lc = (loader_context_t *)data; + int fd = lc->gpollfd->fd; + app_pkt_t *pkt = NULL; + struct ucred cr; + int clifd = -1; + + pkt = _accept_recv_pkt_raw(fd, &clifd, &cr); + if (!pkt) { + _E("Failed to receive the packet"); + return G_SOURCE_CONTINUE; + } + + if (getuid() != cr.uid) { + _E("Invalid caller"); + goto end; + } + + if (pkt->len <= 0) { + _E("Invalid message"); + goto end; + } + + SECURE_LOGE("[%d] %s", cr.pid, (const char *)pkt->data); + +end: + if (clifd != -1) + close(clifd); + if (pkt) + free(pkt); + + return G_SOURCE_CONTINUE; +} + +static int __init_logger_fd(void) +{ + int fd; + guint pollfd; + + fd = _create_server_sock(LAUNCHPAD_LOGGER_SOCK); + if (fd < 0) { + _E("Failed to create logger socker"); + return -1; + } + + pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_logger, 0, 0); + if (pollfd == 0) { + close(fd); + return -1; + } + + return 0; +} + static int __before_loop(int argc, char **argv) { int ret; @@ -2285,6 +2342,12 @@ static int __before_loop(int argc, char **argv) return -1; } + ret = __init_logger_fd(); + if (ret != 0) { + _E("__init_logger_fd() failed"); + return -1; + } + ret = __init_label_monitor_fd(); if (ret != 0) _W("Failed to initialize label monitor"); diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 21cb409..13055e2 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -265,43 +265,46 @@ static int __parse_app_path(const char *arg, char *out, int out_size) return -2; } -int _send_cmd_to_amd(int cmd) +static int __create_client_socket(const char *path) { - struct sockaddr_un addr = {0,}; - int fd; - int ret; + struct sockaddr_un addr = { 0, }; int retry = CONNECT_RETRY_COUNT; - app_pkt_t pkt = {0,}; + int fd; 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; - } + _E("Failed to create socket(%s). errno(%d)", path, errno); + return -1; } addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", PATH_AMD_SOCK); + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path); while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { if (errno != ETIMEDOUT || retry <= 0) { - _E("Failed to connect error(%d)", errno); + _E("Failed to connect socket(%s). errno(%d)", + path, errno); close(fd); return -1; } usleep(CONNECT_RETRY_TIME); - --retry; - _D("re-connect to %s (%d)", addr.sun_path, retry); + retry--; + _W("Retry(%d) to connect %s", retry, path); } + return fd; +} + +int _send_cmd_to_amd(int cmd) +{ + app_pkt_t pkt = {0,}; + int ret; + int fd; + + fd = __create_client_socket(PATH_AMD_SOCK); + if (fd < 0) + return -1; + pkt.cmd = cmd; ret = send(fd, &pkt, sizeof(app_pkt_t), MSG_NOSIGNAL); if (ret <= 0) { @@ -678,54 +681,31 @@ void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd) int _connect_to_launchpad(int type, int id) { - struct sockaddr_un addr; - int fd = -1; - int retry = CONNECT_RETRY_COUNT; - int send_ret = -1; - int client_pid = getpid(); + char path[PATH_MAX]; + int client_pid; + int send_ret; + int fd; _D("[launchpad] enter, type: %d", type); - fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (fd < 0) { - _E("socket error"); - goto error; - } - - memset(&addr, 0x00, sizeof(struct sockaddr_un)); - addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/daemons/%d/%s%d-%d", + snprintf(path, sizeof(path), "%s/daemons/%d/%s%d-%d", SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME, type, id); + fd = __create_client_socket(path); + if (fd < 0) + return -1; - _D("connect to %s", addr.sun_path); - while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - if (errno != ETIMEDOUT || retry <= 0) { - _E("connect error : %d", errno); - goto error; - } - - usleep(CONNECT_RETRY_TIME); - --retry; - _D("re-connect to %s (%d)", addr.sun_path, retry); - } - + client_pid = getpid(); send_ret = send(fd, &client_pid, sizeof(client_pid), MSG_NOSIGNAL); _D("send(%d) : %d", client_pid, send_ret); - if (send_ret == -1) { _E("send error"); - goto error; + close(fd); + return -1; } SECURE_LOGD("[launchpad] done, connect fd: %d", fd); return fd; - -error: - if (fd != -1) - close(fd); - - return -1; } #ifdef TIZEN_FEATURE_SET_PERSONALITY_32 @@ -1370,3 +1350,60 @@ int _prepare_id_file(void) return 0; } + +static int __send_raw(int fd, int cmd, unsigned char *data, int datalen) +{ + app_pkt_t *pkt; + int ret; + + pkt = (app_pkt_t *)calloc(1, sizeof(app_pkt_t) + datalen); + if (!pkt) { + _E("Out of memory"); + return -ENOMEM; + } + + pkt->cmd = cmd; + pkt->len = datalen; + if (data) + memcpy(pkt->data, data, pkt->len); + + ret = _send_pkt_raw(fd, pkt); + if (ret < 0) { + free(pkt); + return -1; + } + + free(pkt); + + return 0; +} + +int _send_message_to_logger(const char *tag, const char *format, ...) +{ + char fmt[PATH_MAX]; + char buf[PATH_MAX]; + va_list ap; + int ret; + int fd; + + snprintf(buf, sizeof(buf), "%s/daemons/%u/.launchpad-logger-sock", + SOCKET_PATH, getuid()); + fd = __create_client_socket(buf); + if (fd < 0) + return -1; + + va_start(ap, format); + vsnprintf(fmt, sizeof(fmt), format, ap); + va_end(ap); + + snprintf(buf, sizeof(buf), "%s: %s", tag, fmt); + ret = __send_raw(fd, 0, (unsigned char *)buf, strlen(buf) + 1); + if (ret < 0) { + close(fd); + return -1; + } + + close(fd); + + return 0; +} diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index ba5e8f7..d9b4202 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -368,8 +368,9 @@ do_exec: unsetenv("AUL_LOADER_INIT"); unsetenv("VC_ELM_INIT"); if (execv(argv[LOADER_ARG_PATH], argv) < 0) { - SECURE_LOGE("execv() failed for file: \"%s\", " \ - "error: %d (%s)", argv[LOADER_ARG_PATH], errno, + _send_message_to_logger(argv[LOADER_ARG_PATH], + "Failed to execute a file. error(%d:%s)", + errno, strerror_r(errno, err_str, sizeof(err_str))); } } -- 2.7.4 From a7c783a7a355588b08ba5d3687cea438c1c01dd8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 8 Mar 2019 15:34:49 +0900 Subject: [PATCH 10/16] Release version 0.5.26 Changes: - Add exceptions for debugging - Add a logger socket for printing errors Change-Id: Iecf6e71d2faea67fbfcdef66f6cc097290e4b452 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 b6f9392..a98d906 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.25 +Version: 0.5.26 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From f99c6ceb2b01f16b77f5bb6876512c6502d8b0da Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 29 Mar 2019 11:19:33 +0900 Subject: [PATCH 11/16] Bump up efl module version. efl version is updated to 1.22, efl module patch should be synchronized with it. Change-Id: I2894143b8e40c1d28d70296a7b81526a63e09170 --- packaging/default.loader.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/default.loader.in b/packaging/default.loader.in index 6156b99..4b3867a 100644 --- a/packaging/default.loader.in +++ b/packaging/default.loader.in @@ -10,12 +10,12 @@ EXTRA_ARRAY preload EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libappcore-efl.so.1 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libappcore-common.so.1 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libcapi-appfw-application.so.0 -EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_imf/modules/wayland/v-1.21/module.so +EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_imf/modules/wayland/v-1.22/module.so EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libdali-toolkit.so EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libcairo.so.2 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libcapi-media-player.so.0 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libcapi-media-camera.so.0 -EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_evas/engines/extn/v-1.21/module.so +EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_evas/engines/extn/v-1.22/module.so ALTERNATIVE_LOADER common-loader1 [LOADER] @@ -29,8 +29,8 @@ EXTRA_ARRAY preload EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libappcore-efl.so.1 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libappcore-common.so.1 EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/libcapi-appfw-application.so.0 -EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_imf/modules/wayland/v-1.21/module.so -EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_evas/engines/extn/v-1.21/module.so +EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_imf/modules/wayland/v-1.22/module.so +EXTRA_ARRAY_VAL @LIB_INSTALL_DIR@/ecore_evas/engines/extn/v-1.22/module.so -- 2.7.4 From 2b1e4f90080ce3a9f8b456bd492bd4da0abd6ee1 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 29 Mar 2019 17:14:13 +0900 Subject: [PATCH 12/16] Release version 0.5.27 Changes: - Bump up efl module version. Change-Id: Ie3dce2b70bfe9ba65b43f7e74873976c66a29023 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 a98d906..ded1d5a 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.26 +Version: 0.5.27 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b313ae5a62a8028fb31be684794413a64dc7ecf9 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Mon, 1 Apr 2019 11:53:35 +0900 Subject: [PATCH 13/16] Add a print for library loading start and end time Change-Id: I760bcaa3ceb2e7a745993610e5ef17d3c44ca229 Signed-off-by: Junghoon Park --- src/launchpad_loader.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index d9b4202..0fffb16 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -26,11 +26,16 @@ #include #include #include +#include #include "launchpad_common.h" #include "launchpad.h" #include "key.h" +#ifndef PR_TASK_PERF_USER_TRACE +#define PR_TASK_PERF_USER_TRACE 666 +#endif + #define KEY_LOADER_TYPE "loader_type" #define LOADER_TYPE_COMMON "common-loader" #define LOADER_TYPE_HW "hw-loader" @@ -308,6 +313,7 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data) char old_cwd[PATH_MAX]; bool restore = false; char *libdir = NULL; + char hwc_message[MAX_LOCAL_BUFSZ]; SECURE_LOGD("[candidate] Launch real application (%s)", argv[LOADER_ARG_PATH]); @@ -329,6 +335,8 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data) restore = true; do_dlopen: + snprintf(hwc_message, sizeof(hwc_message), "%d|lib loading start", getpid()); + prctl(PR_TASK_PERF_USER_TRACE, hwc_message, strlen(hwc_message)); handle = dlopen(argv[LOADER_ARG_PATH], RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE); if (handle == NULL) { @@ -337,6 +345,8 @@ do_dlopen: goto do_exec; } + snprintf(hwc_message, sizeof(hwc_message), "%d|lib loading end", getpid()); + prctl(PR_TASK_PERF_USER_TRACE, hwc_message, strlen(hwc_message)); dlerror(); if (restore && chdir(old_cwd)) -- 2.7.4 From 0e78a177b0c019e9effb029759305dcd863e05c9 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 2 Apr 2019 10:13:15 +0900 Subject: [PATCH 14/16] Release version 0.5.28 Changes: - Add a print for library loading start and end time Change-Id: Ic73ff89841c4752f5a8d14f1922d2bb9e3a8adcb 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 ded1d5a..16d4c6e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.27 +Version: 0.5.28 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 79f44e2d15a9a3460c56351169a52bcb2badd98e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 2 Apr 2019 15:13:25 +0900 Subject: [PATCH 15/16] Fix wrong log message Change-Id: I673a1d3512c3d83d560d9e89ff0adb5c9bc30bfa Signed-off-by: Hwankyu Jhun --- src/launchpad_loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 0fffb16..849b050 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -173,11 +173,12 @@ static void __preload_lib(bundle *b) continue; } - _D("preload %s# - handle : %p", so_array[i], handle); handle = dlopen(so_array[i], RTLD_NOW | RTLD_NODELETE); if (!handle) { _E("failed to load: %s, err: %s", so_array[i], dlerror()); + } else { + _D("preload %s# - handle : %p", so_array[i], handle); } } } -- 2.7.4 From 28bbcb922d1fc8de8e574bfc19f154684650423e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 5 Apr 2019 08:30:03 +0900 Subject: [PATCH 16/16] Release version 0.5.29 Changes: - Fix wrong log message Change-Id: I43518ba931bda4e7fc4f2b68e729844d2615432e 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 16d4c6e..950b9d5 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.5.28 +Version: 0.5.29 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4