summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-06-08 21:38:28 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-06-22 07:53:21 +0900
commit3138a868ab84feece69f4e8e12ab50e872fc1596 (patch)
tree62fa5046049c3a90624fbd8b7e732bed9f5bfa05
parentf637f0184d998bf01d6353a7d352fe39e546dc9e (diff)
downloaddebug-launchpad-accepted/tizen/tv/20160623.121631.tar.gz
debug-launchpad-accepted/tizen/tv/20160623.121631.tar.bz2
debug-launchpad-accepted/tizen/tv/20160623.121631.zip
- The debug-launchpad socket path is changed to "/run/aul/daemons/<uid>/.debug-launchpad-sock". - Requires [aul] https://review.tizen.org/gerrit/#/c/73534/ [amd] https://review.tizen.org/gerrit/#/c/73537/ Change-Id: Ied141d714591b2528559adcf64e67f0a3be558a4 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/common.h3
-rw-r--r--packaging/debug-launchpad.service4
-rw-r--r--packaging/debug-launchpad.socket2
-rw-r--r--src/common.c36
-rw-r--r--src/debug-launchpad.c4
-rw-r--r--src/signal_util.c6
6 files changed, 43 insertions, 12 deletions
diff --git a/include/common.h b/include/common.h
index b63e6c6..c01d142 100644
--- a/include/common.h
+++ b/include/common.h
@@ -34,7 +34,7 @@
#define _D(fmt, arg...) LOGD(fmt, ##arg)
#define _W(fmt, arg...) LOGW(fmt, ##arg)
-#define SOCKET_PATH "/run/user"
+#define SOCKET_PATH "/run/aul"
#define MAX_LOCAL_BUFSZ 128
#define AUL_SOCK_MAXBUFF 131071
@@ -68,6 +68,7 @@ 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);
#endif /* __COMMON_H__ */
diff --git a/packaging/debug-launchpad.service b/packaging/debug-launchpad.service
index 0b7d052..18af17f 100644
--- a/packaging/debug-launchpad.service
+++ b/packaging/debug-launchpad.service
@@ -3,4 +3,8 @@ Description=Start the debug preload/preinit daemon
After=dbus.service ac.service
[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=/usr/bin/debug_launchpad_preloading_preinitializing_daemon
diff --git a/packaging/debug-launchpad.socket b/packaging/debug-launchpad.socket
index 4c5d81f..b1b7fd4 100644
--- a/packaging/debug-launchpad.socket
+++ b/packaging/debug-launchpad.socket
@@ -2,7 +2,7 @@
Description=The debug preload/preinit daemon Socket
[Socket]
-ListenStream=/run/user/%U/.debug-launchpad-sock
+ListenStream=/run/aul/daemons/%U/.debug-launchpad-sock
DirectoryMode=0777
[Install]
diff --git a/src/common.c b/src/common.c
index faed540..6b19d93 100644
--- a/src/common.c
+++ b/src/common.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -72,12 +73,15 @@ static int __create_sock_activation(void)
}
#endif /* _APPFW_FEATURE_SOCKET_ACTIVATION */
-static int __create_server_socket(void)
+static int __create_server_socket(bool is_app)
{
struct sockaddr_un saddr;
int fd;
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (is_app)
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ else
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
/* support above version 2.6.27 */
if (fd < 0) {
if (errno == EINVAL) {
@@ -94,9 +98,16 @@ static int __create_server_socket(void)
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "%s/%d/.debug-launchpad-sock",
- SOCKET_PATH, getuid());
+
+ if (is_app) {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "%s/apps/%d/%d",
+ SOCKET_PATH, getuid(), getpid());
+ } else {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "%s/daemons/%d/.debug-launchpad-sock",
+ SOCKET_PATH, getuid());
+ }
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
@@ -131,7 +142,7 @@ int _create_server_sock(void)
fd = __create_sock_activation();
#endif /* _APPFW_FEATURE_SOCKET_ACTIAVTION */
if (fd < 0) {
- fd = __create_server_socket();
+ fd = __create_server_socket(false);
if (fd < 0) {
_E("server sock error %d", fd);
return -1;
@@ -775,3 +786,16 @@ int _proc_check_cmdline_bypid(int pid)
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);
+}
+
diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c
index e38c4e7..4bf29ad 100644
--- a/src/debug-launchpad.c
+++ b/src/debug-launchpad.c
@@ -126,6 +126,8 @@ 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);
@@ -269,7 +271,7 @@ static int __start_process(const char *appid, const char *app_path,
for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
close(iter_fd);
- snprintf(sock_path, sizeof(sock_path), "%s/%d/%d",
+ snprintf(sock_path, sizeof(sock_path), "%s/apps/%d/%d",
SOCKET_PATH, getuid(), getpid());
unlink(sock_path);
diff --git a/src/signal_util.c b/src/signal_util.c
index f1cbc8e..8b1d62f 100644
--- a/src/signal_util.c
+++ b/src/signal_util.c
@@ -44,7 +44,7 @@ static void __socket_garbage_collector(void)
struct dirent *dentry;
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%d", SOCKET_PATH, getuid());
+ snprintf(path, sizeof(path), "%s/apps/%d", SOCKET_PATH, getuid());
dp = opendir(path);
if (dp == NULL)
return;
@@ -55,7 +55,7 @@ static void __socket_garbage_collector(void)
snprintf(path, sizeof(path), "/proc/%s", dentry->d_name);
if (access(path, F_OK) != 0) { /* Flawfinder: ignore */
- snprintf(path, sizeof(path), "%s/%d/%s",
+ snprintf(path, sizeof(path), "%s/apps/%d/%s",
SOCKET_PATH, getuid(), dentry->d_name);
unlink(path);
continue;
@@ -146,7 +146,7 @@ static int __sigchild_action(pid_t dead_pid)
_send_app_dead_signal(dead_pid);
- snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d/%d",
+ snprintf(buf, MAX_LOCAL_BUFSZ, "%s/apps/%d/%d",
SOCKET_PATH, getuid(), dead_pid);
unlink(buf);