summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-06-08 20:22:30 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-06-22 08:02:15 +0900
commit689b26cd7c77473c9a62e2ae1405d9d35664ae06 (patch)
treeb6f0b1701fbbb12bcb8f5e1c01285d541f90a973
parentd1fa59bb255a323ad993dc9e01abe342aaf6291b (diff)
downloadlaunchpad-689b26cd7c77473c9a62e2ae1405d9d35664ae06.tar.gz
launchpad-689b26cd7c77473c9a62e2ae1405d9d35664ae06.tar.bz2
launchpad-689b26cd7c77473c9a62e2ae1405d9d35664ae06.zip
- The launchpad socket path are changed to "/run/aul/daemons/<uid>/". - Before executing an application, the child process creates an aul socket of the application for communication. And then, the application uses the socket. - Requires [aul] https://review.tizen.org/gerrit/#/c/73534/ [amd] https://review.tizen.org/gerrit/#/c/73537/ Change-Id: I872b5faf1681725e51a3c5647ff1195ebeaabba9 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--inc/launchpad_common.h3
-rw-r--r--inc/sigchild.h7
-rw-r--r--packaging/launchpad-process-pool.service4
-rw-r--r--packaging/launchpad-process-pool.socket4
-rwxr-xr-xsrc/launchpad.c12
-rw-r--r--src/launchpad_common.c32
-rw-r--r--src/launchpad_lib.c3
-rw-r--r--src/launchpad_loader.c14
8 files changed, 62 insertions, 17 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h
index aad42c8..dce37ed 100644
--- a/inc/launchpad_common.h
+++ b/inc/launchpad_common.h
@@ -31,7 +31,7 @@
#define LOG_TAG "LAUNCHPAD"
#endif
-#define SOCKET_PATH "/run/user"
+#define SOCKET_PATH "/run/aul"
#define LAUNCHPAD_LOADER_SOCKET_NAME ".launchpad-type"
#define MAX_PENDING_CONNECTIONS 10
#define MAX_LOCAL_BUFSZ 128
@@ -109,6 +109,7 @@ 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);
appinfo_t *_appinfo_create(bundle *kb);
void _appinfo_free(appinfo_t *menu_info);
diff --git a/inc/sigchild.h b/inc/sigchild.h
index c982fba..2ed7c62 100644
--- a/inc/sigchild.h
+++ b/inc/sigchild.h
@@ -34,7 +34,7 @@ static inline void __socket_garbage_collector(void)
struct dirent *dentry;
char tmp[MAX_LOCAL_BUFSZ];
- snprintf(tmp, sizeof(tmp), "/run/user/%d", getuid());
+ snprintf(tmp, sizeof(tmp), "/run/aul/apps/%d", getuid());
dp = opendir(tmp);
if (dp == NULL)
return;
@@ -45,7 +45,7 @@ static inline void __socket_garbage_collector(void)
snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
if (access(tmp, F_OK) < 0) { /* Flawfinder: ignore */
- snprintf(tmp, MAX_LOCAL_BUFSZ, "/run/user/%d/%s",
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "/run/aul/apps/%d/%s",
getuid(), dentry->d_name);
unlink(tmp);
continue;
@@ -145,7 +145,8 @@ static int __sigchild_action(pid_t dead_pid)
__send_app_dead_signal_dbus(dead_pid);
- snprintf(buf, MAX_LOCAL_BUFSZ, "/run/user/%d/%d", getuid(), dead_pid);
+ snprintf(buf, sizeof(buf), "/run/aul/apps/%d/%d",
+ getuid(), dead_pid);
unlink(buf);
__socket_garbage_collector();
diff --git a/packaging/launchpad-process-pool.service b/packaging/launchpad-process-pool.service
index 0667cd5..6128e1e 100644
--- a/packaging/launchpad-process-pool.service
+++ b/packaging/launchpad-process-pool.service
@@ -6,5 +6,9 @@
Description=Start the USER Access Control Agent
[Service]
+ExecStartPre=-/usr/bin/mkdir -p /run/aul/daemons/%U
+ExecStartPre=-/usr/bin/chmod 0777 /run/aul/daemons/%U
+ExecStartPre=-/usr/bin/mkdir -p /run/aul/apps/%U
+ExecStartPre=-/usr/bin/chmod 0777 /run/aul/apps/%U
ExecStart=/bin/sh -l -c "/usr/bin/launchpad-process-pool"
Sockets=launchpad-process-pool.socket
diff --git a/packaging/launchpad-process-pool.socket b/packaging/launchpad-process-pool.socket
index 6d68ff5..2306963 100644
--- a/packaging/launchpad-process-pool.socket
+++ b/packaging/launchpad-process-pool.socket
@@ -1,6 +1,6 @@
[Socket]
-ListenStream=/run/user/%U/.launchpad-process-pool-sock
-
+ListenStream=/run/aul/daemons/%U/.launchpad-process-pool-sock
+DirectoryMode=0777
Service=launchpad-process-pool.service
[Install]
diff --git a/src/launchpad.c b/src/launchpad.c
index cf7514b..a11c9b6 100755
--- a/src/launchpad.c
+++ b/src/launchpad.c
@@ -249,7 +249,7 @@ static int __listen_candidate_process(int type, int loader_id)
memset(&addr, 0x00, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/daemons/%d/%s%d-%d",
SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
type, loader_id);
@@ -414,8 +414,8 @@ static int __send_launchpad_loader(candidate_process_context_t *cpc,
char sock_path[PATH_MAX];
int pid = -1;
- snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d", getuid(),
- cpc->pid);
+ snprintf(sock_path, sizeof(sock_path), "/run/aul/apps/%d/%d",
+ getuid(), cpc->pid);
unlink(sock_path);
__candidate_process_real_launch(cpc->send_fd, pkt);
@@ -512,6 +512,7 @@ static int __prepare_exec(const char *appid, const char *app_path,
return -1;
}
}
+
/* SET DUMPABLE - for coredump*/
prctl(PR_SET_DUMPABLE, 1);
@@ -525,6 +526,9 @@ static int __prepare_exec(const char *appid, const char *app_path,
_D("can't locate file name to execute");
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);
@@ -555,7 +559,7 @@ static int __launch_directly(const char *appid, const char *app_path, int clifd,
for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
close(iter_fd);
- snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d",
+ snprintf(sock_path, sizeof(sock_path), "/run/aul/apps/%d/%d",
getuid(), getpid());
unlink(sock_path);
diff --git a/src/launchpad_common.c b/src/launchpad_common.c
index 19ad650..32a70dd 100644
--- a/src/launchpad_common.c
+++ b/src/launchpad_common.c
@@ -184,7 +184,10 @@ int _create_server_sock(const char *name)
struct sockaddr_un saddr;
int fd;
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (name)
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ else
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
/* support above version 2.6.27*/
if (fd < 0) {
if (errno == EINVAL) {
@@ -201,8 +204,16 @@ int _create_server_sock(const char *name)
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%s",
- getuid(), name);
+
+ 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());
+ }
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
@@ -557,7 +568,7 @@ int _connect_to_launchpad(int type, int id)
memset(&addr, 0x00, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/daemons/%d/%s%d-%d",
SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
type, id);
@@ -669,3 +680,16 @@ 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);
+}
+
diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c
index 378ccc0..ec2b1d2 100644
--- a/src/launchpad_lib.c
+++ b/src/launchpad_lib.c
@@ -108,6 +108,9 @@ static int __prepare_exec(const char *appid, const char *app_path,
_D("can't locate file name to execute");
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 fbde22a..2e9d18b 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -25,11 +25,11 @@
#include <linux/limits.h>
#include <Elementary.h>
#include <bundle_internal.h>
-#include <aul.h>
#include <vconf.h>
#include "launchpad_common.h"
#include "launchpad.h"
+#include "key.h"
#define KEY_LOADER_TYPE "loader_type"
#define LOADER_TYPE_COMMON "common-loader"
@@ -268,9 +268,17 @@ static void __close_fds(void)
{
int iter_fd;
int max_fd = sysconf(_SC_OPEN_MAX);
+ int fd = -1;
+ const char *sockfd;
- for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
- close(iter_fd);
+ sockfd = getenv("AUL_LISTEN_SOCK");
+ if (sockfd)
+ fd = atoi(sockfd);
+
+ for (iter_fd = 3; iter_fd <= max_fd; iter_fd++) {
+ if (iter_fd != fd)
+ close(iter_fd);
+ }
}
static int __loader_terminate_cb(int argc, char **argv, void *user_data)