void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *appinfo, int cmd);
void _set_env(appinfo_t *app_info, bundle *kb);
char **_create_argc_argv(bundle *kb, int *margc, const char *app_path);
-int _proc_check_cmdline_bypid(int pid);
-void _prepare_listen_sock(void);
int _delete_sock_path(int pid, uid_t uid);
int _close_all_fds(void);
return argv;
}
-static int __read_proc(const char *path, char *buf, int size)
-{
- int fd;
- int ret;
-
- if (buf == NULL || path == NULL)
- return -1;
-
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -1;
-
- ret = read(fd, buf, size - 1);
- if (ret <= 0) {
- close(fd);
- return -1;
- }
-
- buf[ret] = 0;
- close(fd);
-
- return ret;
-}
-
-int _proc_check_cmdline_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- int ret;
-
- snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- return -1;
-
- _D("cmdline: %s", buf);
-
- return 0;
-}
-
-void _prepare_listen_sock(void)
-{
- int fd;
- char buf[12];
-
- fd = __create_server_socket(true);
- 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;
static void __send_result_to_caller(int clifd, int ret)
{
- int res;
- int count = 0;
- char path[PATH_MAX];
-
- _W("Check app launching");
+ _W("send result: %d", ret);
if (clifd == -1)
return;
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);
-
- res = _proc_check_cmdline_bypid(ret);
- if (res < 0) {
- _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) {
if (kill(ret, SIGKILL) == -1)
_E("Failed to send SIGKILL: %d", errno);
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);