summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon, Park <jh9216.park@samsung.com>2015-11-06 15:16:44 +0900
committerJunghoon, Park <jh9216.park@samsung.com>2015-11-06 15:23:40 +0900
commitb697f1cbbfedb8398abb4a2304abc51e5023d153 (patch)
treeaf01c2fedb22858ec55377197357070569aaaddc
parent59254a4a543a892b0723791d9175c7d5e0d1c712 (diff)
downloadlaunchpad-b697f1cbbfedb8398abb4a2304abc51e5023d153.tar.gz
launchpad-b697f1cbbfedb8398abb4a2304abc51e5023d153.tar.bz2
launchpad-b697f1cbbfedb8398abb4a2304abc51e5023d153.zip
- modify cmakefile - apply preinit window - apply preinit pkgid/appid Change-Id: I8d8a7ff0b5f6dcbd8c6c9c1fdabec89a9afc76b9 Signed-off-by: Junghoon, Park <jh9216.park@samsung.com>
-rwxr-xr-xCMakeLists.txt47
-rw-r--r--inc/launchpad_common.h6
-rw-r--r--packaging/launchpad.spec2
-rwxr-xr-xsrc/launchpad.c150
-rw-r--r--src/launchpad_common.c128
-rw-r--r--src/launchpad_loader.c16
6 files changed, 179 insertions, 170 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b36e0ba..867449e 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,10 @@
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
@@ -13,16 +12,32 @@ PKG_CHECK_MODULES(${this_target} REQUIRED
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")
@@ -48,8 +63,8 @@ SET(${LAUNCHPAD_LOADER}_SOURCE_FILES
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.
@@ -63,8 +78,8 @@ SET(${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES
)
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.
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h
index 7fa81cd..e677be7 100644
--- a/inc/launchpad_common.h
+++ b/inc/launchpad_common.h
@@ -34,6 +34,9 @@
#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
@@ -77,10 +80,7 @@ void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, i
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);
diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec
index b0ac4cc..73fad0e 100644
--- a/packaging/launchpad.spec
+++ b/packaging/launchpad.spec
@@ -12,13 +12,13 @@ Source102: launchpad-process-pool.socket
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
diff --git a/src/launchpad.c b/src/launchpad.c
index 129cc20..09d20aa 100755
--- a/src/launchpad.c
+++ b/src/launchpad.c
@@ -22,10 +22,13 @@
#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"
@@ -62,6 +65,128 @@ static candidate __candidate[LAUNCHPAD_TYPE_MAX] = {
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)
{
@@ -79,7 +204,6 @@ static int __get_launchpad_type(const char* internal_pool, const char* hwacc)
_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;
@@ -98,7 +222,7 @@ static int __get_launchpad_type(const char* internal_pool, const char* hwacc)
_D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
return LAUNCHPAD_TYPE_SW;
}
- }*/
+ }
}
_D("[launchpad] launchpad type: COMMON(%d)", LAUNCHPAD_TYPE_COMMON);
@@ -560,7 +684,7 @@ static int __init_pfds(struct pollfd *pfds, int argc, char **argv)
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);
@@ -648,19 +772,19 @@ static int __loop_begin(struct pollfd *pfds)
_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");
}
}
diff --git a/src/launchpad_common.c b/src/launchpad_common.c
index 984cc5c..6b86b45 100644
--- a/src/launchpad_common.c
+++ b/src/launchpad_common.c
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <sys/xattr.h>
#include <errno.h>
-#include <systemd/sd-daemon.h>
#include "launchpad_common.h"
#include "key.h"
@@ -40,8 +39,6 @@
#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
@@ -411,6 +408,7 @@ void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, i
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
@@ -450,70 +448,6 @@ void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, i
}
}
-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;
@@ -533,7 +467,7 @@ int _connect_to_launchpad(int 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);
+ LAUNCHPAD_LOADER_SOCKET_NAME, type);
_D("connect to %s", addr.sun_path);
while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
@@ -565,64 +499,6 @@ error:
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];
diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c
index 525b61c..b755989 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -24,19 +24,18 @@
#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
@@ -123,7 +122,7 @@ static void __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
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) {
@@ -176,14 +175,12 @@ static void __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
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);
@@ -198,8 +195,7 @@ static void __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
_E("Out of memory");
exit(-1);
}
- //aul_set_preinit_pkgid(__pkgid); //TODO
-#endif
+ aul_set_preinit_pkgid(__pkgid);
atexit(__release_appid_at_exit);
@@ -300,7 +296,6 @@ static Eina_Bool __candidate_proces_fd_handler(void* data,
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);
@@ -325,7 +320,6 @@ static void __init_window(void)
} else {
_E("[candidate] elm_win_add() failed");
}
-#endif
}
static void __init_theme(void)