CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET (this_target launchpad)
+SET (this_target_pool launchpad_pool)
+SET (this_target_loader launchpad_loader)
INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(${this_target} REQUIRED
+PKG_CHECK_MODULES(${this_target_pool} REQUIRED
dlog
- ecore
- elementary
libsystemd-daemon
dbus-glib-1
vconf
bundle
)
-FOREACH(flag ${${this_target}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+FOREACH(flag ${${this_target_pool}_CFLAGS})
+ SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+PKG_CHECK_MODULES(${this_target_loader} REQUIRED
+ dlog
+ ecore
+ elementary
+ security-manager
+ bundle
+ aul
+ )
+
+FOREACH(flag ${${this_target_loader}_CFLAGS})
+ SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fvisibility=hidden")
+SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fPIE")
+SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -D_FILE_OFFSET_BITS=64")
+
+SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${EXTRA_CFLAGS_common}")
+SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${EXTRA_CFLAGS_common}")
+
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_EXECUTABLE(${LAUNCHPAD_LOADER} ${${LAUNCHPAD_LOADER}_SOURCE_FILES})
TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} "-ldl")
-TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target}_LDFLAGS} "-pie")
-
+TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target_loader}_LDFLAGS} "-pie")
+SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_loader})
SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER}
PROPERTIES SKIP_BUILD_RPATH TRUE
) # remove rpath option that is automatically generated by cmake.
)
ADD_EXECUTABLE(${LAUNCHPAD_PROCESS_POOL} ${${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES})
-TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target}_LDFLAGS} "-pie")
-
+TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target_pool}_LDFLAGS} "-pie")
+SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_pool})
SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL}
PROPERTIES SKIP_BUILD_RPATH TRUE
) # remove rpath option that is automatically generated by cmake.
#define LOG_TAG "LAUNCHPAD"
#endif
+#define SOCKET_PATH "/run/user"
+#define LAUNCHPAD_LOADER_SOCKET_NAME ".launchpad-type"
+#define MAX_PENDING_CONNECTIONS 10
#define MAX_LOCAL_BUFSZ 128
#define AUL_SOCK_MAXBUFF 65535
int _create_server_sock(int pid);
app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
int _send_pkt_raw(int client_fd, app_pkt_t *pkt);
-int _listen_candidate_process(int type);
int _connect_to_launchpad(int type);
-int _accept_candidate_process(int server_fd, int* out_client_fd, int* out_client_pid);
-void _refuse_candidate_process(int server_fd);
void _set_oom(void);
void _set_env(app_info_from_db * menu_info, bundle * kb);
char** _create_argc_argv(bundle * kb, int *margc);
BuildRequires: cmake
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(libsystemd-daemon)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(security-manager)
+BuildRequires: pkgconfig(aul)
Requires(post): /sbin/ldconfig
Requires(post): /usr/bin/systemctl
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <malloc.h>
#include <bundle_internal.h>
#include <security-manager.h>
#include <time.h>
+#include <vconf.h>
+#include <systemd/sd-daemon.h>
#include "perf.h"
#include "launchpad_common.h"
static int launchpad_fd = -1;
static int pool_fd[LAUNCHPAD_TYPE_MAX] = { -1, -1, -1 };
+static void __refuse_candidate_process(int server_fd)
+{
+ int client_fd = -1;
+
+ if (server_fd == -1) {
+ _E("arguments error!");
+ goto error;
+ }
+
+ client_fd = accept(server_fd, NULL, NULL);
+ if (client_fd == -1) {
+ _E("accept error!");
+ goto error;
+ }
+
+ close(client_fd);
+ _D("refuse connection!");
+
+error:
+ return;
+}
+
+static int __accept_candidate_process(int server_fd, int* out_client_fd,
+ int* out_client_pid)
+{
+ int client_fd = -1, client_pid = 0, recv_ret = 0;
+
+ if (server_fd == -1 || out_client_fd == NULL || out_client_pid == NULL) {
+ _E("arguments error!");
+ goto error;
+ }
+
+ client_fd = accept(server_fd, NULL, NULL);
+
+ if (client_fd == -1) {
+ _E("accept error!");
+ goto error;
+ }
+
+ recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL);
+
+ if (recv_ret == -1) {
+ _E("recv error!");
+ goto error;
+ }
+
+ *out_client_fd = client_fd;
+ *out_client_pid = client_pid;
+
+ return *out_client_fd;
+
+error:
+ if (client_fd != -1)
+ close(client_fd);
+
+ return -1;
+}
+
+static int __listen_candidate_process(int type)
+{
+ struct sockaddr_un addr;
+ int fd = -1;
+ int listen_fds = 0;
+ int i;
+
+ _D("[launchpad] enter, type: %d", type);
+
+ memset(&addr, 0x00, sizeof(struct sockaddr_un));
+ addr.sun_family = AF_UNIX;
+ snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%d/%s%d", SOCKET_PATH, getuid(),
+ LAUNCHPAD_LOADER_SOCKET_NAME, type);
+
+ listen_fds = sd_listen_fds(0);
+ if (listen_fds < 0) {
+ _E("Invalid systemd environment");
+ return -1;
+ } else if (listen_fds > 0) {
+ for (i = 0; i < listen_fds; i++) {
+ fd = SD_LISTEN_FDS_START + i;
+ if (sd_is_socket_unix(fd, SOCK_STREAM, 1, addr.sun_path, 0))
+ return fd;
+ }
+ _E("Socket not found: %s", addr.sun_path);
+ return -1;
+ }
+
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (fd < 0) {
+ _E("Socket error");
+ goto error;
+ }
+
+ unlink(addr.sun_path);
+
+ _D("bind to %s", addr.sun_path);
+ if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ _E("bind error");
+ goto error;
+ }
+
+ _D("chmod %s", addr.sun_path);
+ if (chmod(addr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ _E("chmod error");
+ goto error;
+ }
+
+ _D("listen to %s", addr.sun_path);
+ if (listen(fd, MAX_PENDING_CONNECTIONS) == -1) {
+ _E("listen error");
+ goto error;
+ }
+
+ SECURE_LOGD("[launchpad] done, listen fd: %d", fd);
+ return fd;
+
+error:
+ if (fd != -1)
+ close(fd);
+
+ return -1;
+}
+
static int __set_access(const char* appId, const char* pkg_type,
const char* app_path)
{
_D("[launchpad] launchpad type: H/W(%d)", LAUNCHPAD_TYPE_HW);
return LAUNCHPAD_TYPE_HW;
}
- /* TODO: FIXME
if (strncmp(hwacc, "SYS", 3) == 0) {
int r;
int sys_hwacc = -1;
_D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
return LAUNCHPAD_TYPE_SW;
}
- }*/
+ }
}
_D("[launchpad] launchpad type: COMMON(%d)", LAUNCHPAD_TYPE_COMMON);
pfds[LAUNCH_PAD].revents = 0;
for (i = 0; i < LAUNCHPAD_TYPE_MAX; ++i) {
- pool_fd[i] = _listen_candidate_process(i);
+ pool_fd[i] = __listen_candidate_process(i);
if (pool_fd[i] == -1) {
_E("[launchpad] Listening the socket to the type %d candidate process failed.",
i);
_D("pfds[POOL_TYPE + %d].revents & POLLIN", i);
if (__candidate[i].pid == CANDIDATE_NONE) {
- _accept_candidate_process(server_fd, &client_fd, &client_pid);
-
- __candidate[i].pid = client_pid;
- __candidate[i].send_fd = client_fd;
+ if (__accept_candidate_process(server_fd, &client_fd, &client_pid) >= 0) {
+ __candidate[i].pid = client_pid;
+ __candidate[i].send_fd = client_fd;
- pfds[CANDIDATE_TYPE + i].fd = client_fd;
- pfds[CANDIDATE_TYPE + i].events = POLLIN | POLLHUP;
- pfds[CANDIDATE_TYPE + i].revents = 0;
+ pfds[CANDIDATE_TYPE + i].fd = client_fd;
+ pfds[CANDIDATE_TYPE + i].events = POLLIN | POLLHUP;
+ pfds[CANDIDATE_TYPE + i].revents = 0;
- SECURE_LOGD("Type %d candidate process was connected, pid: %d", i,
- __candidate[i].pid);
+ SECURE_LOGD("Type %d candidate process was connected, pid: %d", i,
+ __candidate[i].pid);
+ }
} else {
- _refuse_candidate_process(server_fd);
+ __refuse_candidate_process(server_fd);
_E("Refused candidate process connection");
}
}
#include <stdio.h>
#include <sys/xattr.h>
#include <errno.h>
-#include <systemd/sd-daemon.h>
#include "launchpad_common.h"
#include "key.h"
#define OPTION_VALGRIND_SIZE 8
#define MAX_CMD_BUFSZ 1024
-#define SOCKET_PATH "/run/user"
-#define LAUNCHPAD_TYPE ".launchpad-type"
#define MAX_PENDING_CONNECTIONS 10
#define CONNECT_RETRY_TIME 100 * 1000
#define CONNECT_RETRY_COUNT 3
bundle_del(kb, AUL_K_PACKAGETYPE);
bundle_del(kb, AUL_K_HWACC);
bundle_del(kb, AUL_K_TASKMANAGE);
+ bundle_del(kb, AUL_K_PKGID);
/* Parse app_path to retrieve default bundle*/
if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN
}
}
-int _listen_candidate_process(int type)
-{
- struct sockaddr_un addr;
- int fd = -1;
- int listen_fds = 0;
- int i;
-
- _D("[launchpad] enter, type: %d", type);
-
- memset(&addr, 0x00, sizeof(struct sockaddr_un));
- addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%d/%s%d", SOCKET_PATH, getuid(),
- LAUNCHPAD_TYPE, type);
-
- listen_fds = sd_listen_fds(0);
- if (listen_fds < 0) {
- _E("Invalid systemd environment");
- return -1;
- } else if (listen_fds > 0) {
- for (i = 0; i < listen_fds; i++) {
- fd = SD_LISTEN_FDS_START + i;
- if (sd_is_socket_unix(fd, SOCK_STREAM, 1, addr.sun_path, 0))
- return fd;
- }
- _E("Socket not found: %s", addr.sun_path);
- return -1;
- }
-
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- if (fd < 0) {
- _E("Socket error");
- goto error;
- }
-
- unlink(addr.sun_path);
-
- _D("bind to %s", addr.sun_path);
- if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- _E("bind error");
- goto error;
- }
-
- _D("chmod %s", addr.sun_path);
- if (chmod(addr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
- _E("chmod error");
- goto error;
- }
-
- _D("listen to %s", addr.sun_path);
- if (listen(fd, MAX_PENDING_CONNECTIONS) == -1) {
- _E("listen error");
- goto error;
- }
-
- SECURE_LOGD("[launchpad] done, listen fd: %d", fd);
- return fd;
-
-error:
- if (fd != -1)
- close(fd);
-
- return -1;
-}
-
int _connect_to_launchpad(int type)
{
struct sockaddr_un addr;
memset(&addr, 0x00, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%d/%s%d", SOCKET_PATH, getuid(),
- LAUNCHPAD_TYPE, type);
+ LAUNCHPAD_LOADER_SOCKET_NAME, type);
_D("connect to %s", addr.sun_path);
while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
return -1;
}
-int _accept_candidate_process(int server_fd, int* out_client_fd,
- int* out_client_pid)
-{
- int client_fd = -1, client_pid = 0, recv_ret = 0;
-
- if (server_fd == -1 || out_client_fd == NULL || out_client_pid == NULL) {
- _E("arguments error!");
- goto error;
- }
-
- client_fd = accept(server_fd, NULL, NULL);
-
- if (client_fd == -1) {
- _E("accept error!");
- goto error;
- }
-
- recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL);
-
- if (recv_ret == -1) {
- _E("recv error!");
- goto error;
- }
-
- *out_client_fd = client_fd;
- *out_client_pid = client_pid;
-
- return *out_client_fd;
-
-error:
- if (client_fd != -1)
- close(client_fd);
-
- return -1;
-}
-
-void _refuse_candidate_process(int server_fd)
-{
- int client_fd = -1;
-
- if (server_fd == -1) {
- _E("arguments error!");
- goto error;
- }
-
- client_fd = accept(server_fd, NULL, NULL);
- if (client_fd == -1) {
- _E("accept error!");
- goto error;
- }
-
- close(client_fd);
- _D("refuse connection!");
-
-error:
- return;
-}
-
void _set_oom(void)
{
char buf[MAX_LOCAL_BUFSZ];
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
-#include <sqlite3.h>
#include <Elementary.h>
#include <Ecore.h>
#include <bundle_internal.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <security-manager.h>
+#include <aul.h>
#include "menu_db_util.h"
#include "launchpad_common.h"
#include "preload.h"
#include "process_pool_preload.h"
#include "preexec.h"
-#include "key.h"
+
#define AUL_PR_NAME 16
#define LOWEST_PRIO 20
const char *app_id = NULL;
const char *app_path = NULL;
- //const char *pkg_id = NULL;
+ const char *pkg_id = NULL;
kb = bundle_decode(pkt->data, pkt->len);
if (!kb) {
exit(-1);
}
SECURE_LOGD("app id: %s", app_id);
-#if 0
- //TODO : FIXME
__appid = strdup(app_id);
if (__appid == NULL) {
_E("Out of memory");
exit(-1);
}
- //aul_set_preinit_appid(__appid); //TODO
+ aul_set_preinit_appid(__appid);
// caching pkgid
pkg_id = _get_pkgid(menu_info);
_E("Out of memory");
exit(-1);
}
- //aul_set_preinit_pkgid(__pkgid); //TODO
-#endif
+ aul_set_preinit_pkgid(__pkgid);
atexit(__release_appid_at_exit);
static void __init_window(void)
{
-#if 0 //TODO : FIXME
Evas_Object *win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
if (win) {
aul_set_preinit_window(win);
} else {
_E("[candidate] elm_win_add() failed");
}
-#endif
}
static void __init_theme(void)