summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-08-08 11:44:42 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-08-08 14:51:37 +0900
commit7568225b899d175c66e651290183e32c77089520 (patch)
treec5b7d4c35ebc1b657129abd3531bfd841312eb1e
parent11d2bf8c325bcb220b037df04ae9e12c98f3ac61 (diff)
downloadlaunchpad-7568225b899d175c66e651290183e32c77089520.tar.gz
launchpad-7568225b899d175c66e651290183e32c77089520.tar.bz2
launchpad-7568225b899d175c66e651290183e32c77089520.zip
Change-Id: Ife3d6350aad080fb2173935e30229e0e58a26ca9 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--inc/launchpad_common.h4
-rwxr-xr-xsrc/launchpad.c34
-rw-r--r--src/launchpad_common.c120
-rw-r--r--src/launchpad_lib.c2
-rw-r--r--src/launchpad_loader.c14
5 files changed, 12 insertions, 162 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h
index 8b70af4..5ac9977 100644
--- a/inc/launchpad_common.h
+++ b/inc/launchpad_common.h
@@ -83,7 +83,6 @@ typedef struct {
char *loader_name;
} appinfo_t;
-char *_proc_get_cmdline_bypid(int pid);
void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd);
int _create_server_sock(const char *name);
@@ -94,14 +93,13 @@ void _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);
-void _prepare_listen_sock(void);
int _delete_sock_path(int pid, uid_t uid);
appinfo_t *_appinfo_create(bundle *kb);
void _appinfo_free(appinfo_t *menu_info);
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(int except);
+int _close_all_fds(void);
void _get_cpu_idle(long long *total, long long *idle);
int _mount_legacy_app_path(const char *app_root_path,
diff --git a/src/launchpad.c b/src/launchpad.c
index 4fb2490..01c91b8 100755
--- a/src/launchpad.c
+++ b/src/launchpad.c
@@ -327,11 +327,7 @@ static int __real_send(int clifd, int ret)
static void __send_result_to_caller(int clifd, int ret, const char *app_path)
{
- char *cmdline;
- int count = 0;
- char path[PATH_MAX];
-
- _W("Check app launching");
+ _W("send result: %d", ret);
if (clifd == -1)
return;
@@ -342,28 +338,6 @@ static void __send_result_to_caller(int clifd, int ret, const char *app_path)
return;
}
- snprintf(path, sizeof(path), "/run/aul/apps/%d/%d/.app-sock",
- getuid(), ret);
- _D("socket path: %s", path);
- do {
- if (access(path, F_OK) == 0) {
- _D("%s exists", path);
- break;
- }
-
- _D("-- now wait socket creation --");
- usleep(50 * 1000);
- count++;
- } while (count < 20);
-
- cmdline = _proc_get_cmdline_bypid(ret);
- if (cmdline == NULL) {
- _E("The app process might be terminated while we are wating %d",
- ret);
- __real_send(clifd, -1); /* abnormally launched*/
- return;
- }
-
if (__real_send(clifd, ret) < 0)
__kill_process(ret);
}
@@ -402,7 +376,7 @@ static int __exec_loader_process(void *arg)
__signal_unblock_sigchld();
__signal_fini();
- _close_all_fds(0);
+ _close_all_fds();
if (execv(argv[LOADER_ARG_PATH], argv) < 0)
_E("Failed to prepare candidate_process");
@@ -591,8 +565,6 @@ static int __prepare_exec(const char *appid, const char *app_path,
if (*file_name == '\0')
return PAD_ERR_INVALID_PATH;
- _prepare_listen_sock();
-
memset(process_name, '\0', AUL_PR_NAME);
snprintf(process_name, AUL_PR_NAME, "%s", file_name);
prctl(PR_SET_NAME, process_name);
@@ -621,7 +593,7 @@ static int __exec_app_process(void *arg)
__signal_unblock_sigchld();
__signal_fini();
- _close_all_fds(0);
+ _close_all_fds();
_delete_sock_path(getpid(), getuid());
ret = _mount_legacy_app_path(launch_arg->menu_info->root_path,
diff --git a/src/launchpad_common.c b/src/launchpad_common.c
index c4ffa98..f4f6739 100644
--- a/src/launchpad_common.c
+++ b/src/launchpad_common.c
@@ -37,16 +37,6 @@
#include "key.h"
#define MAX_PATH_LEN 1024
-#define BINSH_NAME "/bin/sh"
-#define BINSH_SIZE 7
-#define VALGRIND_NAME "/home/developer/sdk_tools/valgrind/usr/bin/valgrind"
-#define VALGRIND_SIZE 51
-#define BASH_NAME "/bin/bash"
-#define BASH_SIZE 9
-#define OPROFILE_NAME "/usr/bin/oprofile_command"
-#define OPROFILE_SIZE 25
-#define OPTION_VALGRIND_NAME "valgrind"
-#define OPTION_VALGRIND_SIZE 8
#define MAX_CMD_BUFSZ 1024
#define LEGACY_APP_ROOT_PATH "/opt/usr/apps"
@@ -225,12 +215,8 @@ int _create_server_sock(const char *name)
{
struct sockaddr_un saddr;
int fd;
- int ret;
- if (name)
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- else
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
/* support above version 2.6.27*/
if (fd < 0) {
if (errno == EINVAL) {
@@ -248,34 +234,9 @@ int _create_server_sock(const char *name)
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- if (name) {
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "%s/daemons/%d/%s",
- SOCKET_PATH, getuid(), name);
- } else {
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "%s/apps/%d/%d",
- SOCKET_PATH, getuid(), getpid());
- ret = mkdir(saddr.sun_path, 0700);
- if (ret != 0) {
- if (errno == EEXIST) {
- if (access(saddr.sun_path, R_OK) != 0) {
- _E("Failed to access %s directory - %d",
- saddr.sun_path, errno);
- close(fd);
- return -1;
- }
- } else {
- _E("Failed to create %s directory - %d",
- saddr.sun_path, errno);
- close(fd);
- return -1;
- }
- }
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "%s/apps/%d/%d/.app-sock",
- SOCKET_PATH, getuid(), getpid());
- }
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "%s/daemons/%d/%s",
+ SOCKET_PATH, getuid(), name);
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
@@ -398,55 +359,6 @@ error:
return -1;
}
-char *_proc_get_cmdline_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- int ret;
- char *ptr;
- int len;
-
- snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- return NULL;
-
- /* support app launched by shell script*/
- if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
- return strdup(&buf[BINSH_SIZE + 1]);
- else if (strncmp(buf, VALGRIND_NAME, VALGRIND_SIZE) == 0) {
- ptr = buf;
-
- /* buf comes with double null-terminated string */
- while (1) {
- while (*ptr)
- ptr++;
- ptr++;
-
- if (!(*ptr))
- break;
-
- /* ignore trailing "--" */
- if (strncmp(ptr, "-", 1) != 0)
- break;
- }
-
- return strdup(ptr);
- } else if (strncmp(buf, BASH_NAME, BASH_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME,
- OPROFILE_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2],
- OPTION_VALGRIND_NAME,
- OPTION_VALGRIND_SIZE) == 0) {
- len = BASH_SIZE + OPROFILE_SIZE +
- OPTION_VALGRIND_SIZE + 3;
- return strdup(&buf[len]);
- }
- }
- }
-
- return strdup(buf);
-}
-
appinfo_t *_appinfo_create(bundle *kb)
{
appinfo_t *menu_info;
@@ -747,19 +659,6 @@ int _proc_get_attr_by_pid(int pid, char *buf, int size)
return 0;
}
-void _prepare_listen_sock(void)
-{
- int fd;
- char buf[12];
-
- fd = _create_server_sock(NULL);
- if (fd < 0)
- return;
-
- snprintf(buf, sizeof(buf), "%d", fd);
- setenv("AUL_LISTEN_SOCK", buf, 1);
-}
-
static int __delete_dir(const char *path)
{
DIR *dp;
@@ -810,7 +709,7 @@ int _delete_sock_path(int pid, uid_t uid)
return 0;
}
-int _close_all_fds(const int except)
+int _close_all_fds(void)
{
DIR *dp;
struct dirent dentry;
@@ -822,10 +721,8 @@ int _close_all_fds(const int except)
if (dp == NULL) {
/* fallback */
max_fd = sysconf(_SC_OPEN_MAX);
- for (fd = 3; fd < max_fd; fd++) {
- if (fd != except)
- close(fd);
- }
+ for (fd = 3; fd < max_fd; fd++)
+ close(fd);
return 0;
}
@@ -841,9 +738,6 @@ int _close_all_fds(const int except)
if (fd == dirfd(dp))
continue;
- if (fd == except)
- continue;
-
close(fd);
}
closedir(dp);
diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c
index f063fcc..71da029 100644
--- a/src/launchpad_lib.c
+++ b/src/launchpad_lib.c
@@ -100,8 +100,6 @@ static int __prepare_exec(const char *appid, const char *app_path,
return -1;
}
- _prepare_listen_sock();
-
memset(process_name, '\0', AUL_PR_NAME);
snprintf(process_name, AUL_PR_NAME, "%s", file_name);
prctl(PR_SET_NAME, process_name);
diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c
index 23b0cb9..0b7c3a6 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -267,18 +267,6 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path,
return 0;
}
-static void __close_fds(void)
-{
- int fd = -1;
- const char *sockfd;
-
- sockfd = getenv("AUL_LISTEN_SOCK");
- if (sockfd)
- fd = atoi(sockfd);
-
- _close_all_fds(fd);
-}
-
static int __loader_terminate_cb(int argc, char **argv, void *user_data)
{
void *handle;
@@ -345,7 +333,7 @@ do_exec:
} else {
SECURE_LOGD("[candidate] Exec application (%s)",
__argv[LOADER_ARG_PATH]);
- __close_fds();
+ _close_all_fds();
if (libdir)
setenv("LD_LIBRARY_PATH", libdir, 1);
free(libdir);