diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2018-05-03 09:18:26 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2018-05-03 14:27:00 +0900 |
commit | 1f206ee0f1a1f057937ad8a458f2f268d0ac6a6e (patch) | |
tree | 97bd97a7f86f87d86ef05de77bdb2ed3d5a36805 | |
parent | 9657e54f79eb405d206c3eb433dcbcf0f7bf186c (diff) | |
download | launchpad-1f206ee0f1a1f057937ad8a458f2f268d0ac6a6e.tar.gz launchpad-1f206ee0f1a1f057937ad8a458f2f268d0ac6a6e.tar.bz2 launchpad-1f206ee0f1a1f057937ad8a458f2f268d0ac6a6e.zip |
Add an exception handling about socket creation
If the path exists when creating a socket, the function returns
a negative error. And then, the child process is terminated.
Change-Id: I4d9c3967bdb851f791a5ec74ef73ca36113d636b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | inc/launchpad_common.h | 2 | ||||
-rwxr-xr-x | src/launchpad.c | 4 | ||||
-rw-r--r-- | src/launchpad_common.c | 20 | ||||
-rw-r--r-- | src/launchpad_lib.c | 4 |
4 files changed, 22 insertions, 8 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index d0a33b2..c43108a 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -126,7 +126,7 @@ void _get_cpu_idle(unsigned long long *total, unsigned long long *idle); int _setup_stdio(const char *ident); int _set_priority(int prio); int _wait_tep_mount(bundle *b); -void _prepare_app_socket(void); +int _prepare_app_socket(void); #endif /* __LAUNCHPAD_COMMON_H__ */ diff --git a/src/launchpad.c b/src/launchpad.c index 6f81c77..b5ff446 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -854,7 +854,9 @@ static int __prepare_exec(const char *appid, const char *app_path, if (ret < 0) return PAD_ERR_FAILED; - _prepare_app_socket(); + ret = _prepare_app_socket(); + if (ret < 0) + return PAD_ERR_FAILED; return 0; } diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 8cefb4c..7888427 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -802,13 +802,21 @@ static int __delete_dir(const char *path) int _delete_sock_path(int pid, uid_t uid) { char path[PATH_MAX]; + int r; snprintf(path, sizeof(path), "/run/aul/apps/%d/%d", uid, pid); - if (access(path, F_OK) == 0) + r = access(path, F_OK); + if (r != 0) { + if (errno != ENOENT) + _E("Failed to access %s. errno(%d)", path, errno); + } else { __delete_dir(path); + } - if (access(path, F_OK) == 0) + if (access(path, F_OK) == 0) { + _E("Failed to delete %s", path); return -1; + } return 0; } @@ -1054,7 +1062,7 @@ static int __create_app_socket(int pid, uid_t uid) _E("Failed to access %s. errno(%d)", path, errno); close(fd); - return -1; + return -errno; } } else { _E("Failed to access %s. errno(%d)", path, errno); @@ -1084,15 +1092,17 @@ static int __create_app_socket(int pid, uid_t uid) return fd; } -void _prepare_app_socket(void) +int _prepare_app_socket(void) { int fd; char buf[12]; fd = __create_app_socket(getpid(), getuid()); if (fd < 0) - return; + return fd; snprintf(buf, sizeof(buf), "%d", fd); setenv("AUL_LISTEN_FD", buf, 1); + + return 0; } diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index 60f6dac..6c225de 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -135,7 +135,9 @@ static int __prepare_exec(const char *appid, const char *app_path, if (ret < 0) return -1; - _prepare_app_socket(); + ret = _prepare_app_socket(); + if (ret < 0) + return -1; return 0; } |