#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
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__ */
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
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]
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
}
#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) {
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) {
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;
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);
+}
+
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);
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);
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;
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;
_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);