From a1b5fa8463128fc84c71e06541587913a01ef781 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 5 Oct 2020 19:09:28 +0900 Subject: [PATCH] Check AUL process ID If the AUL process ID is not equal to current process ID, AUL creates a new app socket. Change-Id: Ia353ec7ff4505b8174365eb8c435b18dbb069361 Signed-off-by: Hwankyu Jhun --- src/launch.c | 25 +++++++++++++++++++++++-- src/launch.h | 4 ++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/launch.c b/src/launch.c index 5ad3a76..0d0cf66 100755 --- a/src/launch.c +++ b/src/launch.c @@ -51,7 +51,7 @@ static void *__conformant_object = NULL; static void __clear_internal_key(bundle *kb); static inline void __set_stime(bundle *kb); -int aul_is_initialized() +int aul_is_initialized(void) { return aul_initialized; } @@ -276,11 +276,32 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid return ret; } +static int __check_env_pid(void) +{ + const char *env_str; + int env_pid; + + env_str = getenv("AUL_PID"); + if (env_str && isdigit(*env_str)) { + env_pid = atoi(env_str); + if (env_pid != getpid()) { + _W("pid(%d) is not equal to AUL_PID(%d)", + getpid(), env_pid); + return -1; + } + } + + return 0; +} + static int __get_preinit_fd(void) { int fd = -1; const char *listen_fd; + if (__check_env_pid() != 0) + return fd; + listen_fd = getenv("AUL_LISTEN_FD"); if (listen_fd) { if (isdigit(*listen_fd)) @@ -291,7 +312,7 @@ static int __get_preinit_fd(void) return fd; } -int aul_initialize() +int aul_initialize(void) { int flag; diff --git a/src/launch.h b/src/launch.h index be5ca59..5a2eb61 100644 --- a/src/launch.h +++ b/src/launch.h @@ -18,8 +18,8 @@ #include -int aul_initialize(); -int aul_is_initialized(); +int aul_initialize(void); +int aul_is_initialized(void); int aul_app_register_pid(const char *appid, int pid); int app_send_cmd(int pid, int cmd, bundle *kb); -- 2.7.4