/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
typedef void (*loader_create_cb)(bundle *extra, int type, void *user_data);
typedef int (*loader_launch_cb)(int argc, char **argv, const char *app_path,
- const char *appid, const char *pkgid, const char *pkg_type, void *user_data);
+ const char *appid, const char *pkgid, const char *pkg_type,
+ void *user_data);
typedef int (*loader_terminate_cb)(int argc, char **argv, void *user_data);
typedef void (*loader_receiver_cb)(int fd);
typedef void (*loader_loop_begin_cb)(void *user_data);
typedef void (*loader_loop_quit_cb)(void *user_data);
-typedef void (*loader_add_fd_cb)(void *user_data, int fd, loader_receiver_cb receiver);
+typedef void (*loader_add_fd_cb)(void *user_data, int fd,
+ loader_receiver_cb receiver);
typedef void (*loader_remove_fd_cb)(void *user_data, int fd);
typedef struct {
LAUNCHPAD_TYPE_MAX
};
-int launchpad_loader_main(int argc, char **argv, loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter, void *user_data);
+int launchpad_loader_main(int argc, char **argv,
+ loader_lifecycle_callback_s *callbacks,
+ loader_adapter_s *adapter, void *user_data);
#ifdef __cplusplus
}
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef __LAUNCHPAD_COMMON__
-#define __LAUNCHPAD_COMMON__
+#ifndef __LAUNCHPAD_COMMON_H__
+#define __LAUNCHPAD_COMMON_H__
#define _GNU_SOURCE
} appinfo_t;
char *_proc_get_cmdline_bypid(int pid);
-void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd);
+void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd);
int _create_server_sock(const char *name);
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 _connect_to_launchpad(int type, int id);
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);
+void _set_env(appinfo_t *menu_info, bundle *kb);
+char **_create_argc_argv(bundle *kb, int *margc);
char *_get_libdir(const char *path);
-appinfo_t* _appinfo_create(bundle *kb);
+appinfo_t *_appinfo_create(bundle *kb);
void _appinfo_free(appinfo_t *menu_info);
char *_appinfo_get_app_path(appinfo_t *menu_info);
int _proc_get_attr_by_pid(int pid, char *buf, int size);
-#endif
+#endif /* __LAUNCHPAD_COMMON_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
.tv_usec = 0
};
-#define INIT_PERF(kb)\
-do {\
- const char *tmp;\
- struct timeval tv;\
- tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
- if (tmp != NULL)\
- sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
- else\
- gettimeofday(&tv, NULL);\
- __g_base_time.tv_sec = tv.tv_sec;\
- __g_base_time.tv_usec = tv.tv_usec;\
-} while (0);
-
-#define PERF(fmt, arg...)\
-do {\
- struct timeval cur;\
- struct timeval res;\
- gettimeofday(&cur, NULL);\
- if (__g_base_time.tv_sec != 0) {\
- timersub(&cur, &__g_base_time, &res);\
- printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt" %c[0m\n",\
- 27, __FUNCTION__, __LINE__, \
- res.tv_sec, res.tv_usec/1000, ##arg, 27);\
- } \
-} while (0);
+#define INIT_PERF(kb) \
+ do { \
+ const char *tmp; \
+ struct timeval tv; \
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
+ if (tmp != NULL) \
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); \
+ else \
+ gettimeofday(&tv, NULL); \
+ __g_base_time.tv_sec = tv.tv_sec; \
+ __g_base_time.tv_usec = tv.tv_usec; \
+ } while (0)
+
+#define PERF(fmt, arg...) \
+ do { \
+ struct timeval cur; \
+ struct timeval res; \
+ gettimeofday(&cur, NULL); \
+ if (__g_base_time.tv_sec != 0) { \
+ timersub(&cur, &__g_base_time, &res); \
+ printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt \
+ " %c[0m\n", 27, __FUNCTION__, \
+ __LINE__, res.tv_sec, \
+ res.tv_usec/1000, ##arg, 27);\
+ } \
+ } while (0)
#else
#endif
-#endif
+#endif /* __PERF_H__ */
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
static inline void __preload_exec(int argc, char **argv)
{
void *handle = NULL;
- int (*dl_main) (int, char **);
+ int (*dl_main)(int, char **);
char *error = NULL;
if (!preload_initialized)
}
#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
- int res = setpriority(PRIO_PROCESS, 0, 0);
- if (res == -1)
- {
- SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
+ if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
+ SECURE_LOGE("Setting process (%d) priority to 0 failed,"
+ " errno: %d (%s)",
getpid(), errno, strerror(errno));
}
#endif
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#include <string.h>
#include <dlfcn.h>
-#define PROCESS_POOL_PRELOAD_FILE SHARE_PREFIX"/launchpad-process-pool-preload-list.txt"
+#define PROCESS_POOL_PRELOAD_FILE \
+ SHARE_PREFIX"/launchpad-process-pool-preload-list.txt"
static int g_dlopen_size = 5;
static int g_dlopen_count = 0;
-static void** g_dlopen_handle_list = NULL;
+static void **g_dlopen_handle_list = NULL;
static inline int __preload_save_dlopen_handle(void *handle)
{
+ void **tmp;
+
if (!handle)
return 1;
if (g_dlopen_count == g_dlopen_size || !g_dlopen_handle_list) {
- void** tmp =
- realloc(g_dlopen_handle_list, 2 * g_dlopen_size * sizeof(void *));
- if (NULL == tmp) {
+ tmp = realloc(g_dlopen_handle_list,
+ 2 * g_dlopen_size * sizeof(void *));
+ if (tmp == NULL) {
_E("out of memory\n");
dlclose(handle);
return 1;
static inline void __preload_fini_for_process_pool(void)
{
int i = 0;
+ void *handle;
+
if (!g_dlopen_handle_list)
return;
for (i = 0; i < g_dlopen_count; ++i) {
- void *handle = g_dlopen_handle_list[i];
+ handle = g_dlopen_handle_list[i];
if (handle) {
if (0 != dlclose(handle))
_E("dlclose failed\n");
static inline void __preload_init_for_process_pool(void)
{
- if (atexit(__preload_fini_for_process_pool) != 0)
- _E("Cannot register atexit callback. Libraries will not be unloaded");
-
void *handle = NULL;
char soname[MAX_LOCAL_BUFSZ] = { 0, };
FILE *preload_list = NULL;
+ size_t len;
+
+ if (atexit(__preload_fini_for_process_pool) != 0) {
+ _E("Cannot register atexit callback. "
+ "Libraries will not be unloaded");
+ }
preload_list = fopen(PROCESS_POOL_PRELOAD_FILE, "rt");
if (preload_list == NULL) {
}
while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > 0) {
- size_t len = strnlen(soname, MAX_LOCAL_BUFSZ);
+ len = strnlen(soname, MAX_LOCAL_BUFSZ);
if (len > 0)
soname[len - 1] = '\0';
fclose(preload_list);
}
-#endif //__PROCESS_POOL_PRELOAD_H__
+#endif /* __PROCESS_POOL_PRELOAD_H__ */
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
if (bus == NULL) {
bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (bus == NULL) {
- _E("Failed to connect to the D-BUS daemon: %s", err->message);
+ _E("Failed to connect to the D-BUS daemon: %s",
+ err->message);
g_error_free(err);
return -1;
}
return 0;
}
-static inline int __send_app_launch_signal_dbus(int launch_pid, const char *app_id)
+static inline int __send_app_launch_signal_dbus(int launch_pid,
+ const char *app_id)
{
GError *err = NULL;
+ GVariant *param;
if (bus == NULL) {
bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (bus == NULL) {
- _E("Failed to connect to the D-BUS daemon: %s", err->message);
+ _E("Failed to connect to the D-BUS daemon: %s",
+ err->message);
g_error_free(err);
return -1;
}
}
+ param = g_variant_new("(us)", launch_pid, app_id);
if (g_dbus_connection_emit_signal(bus,
NULL,
AUL_DBUS_PATH,
AUL_DBUS_SIGNAL_INTERFACE,
AUL_DBUS_APPLAUNCH_SIGNAL,
- g_variant_new("(us)", launch_pid, app_id),
+ param,
&err) == FALSE) {
_E("g_dbus_connection_emit_signal() is failed: %s",
err->message);
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
static GList *candidate_slot_list;
static int sys_hwacc = -1;
-static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path,
- const char *extra, bool enabled, int detection_method, int timeout_val);
+static candidate_process_context_t *__add_slot(int type, int loader_id,
+ int caller_pid, const char *loader_path, const char *extra,
+ bool enabled, int detection_method, int timeout_val);
static int __remove_slot(int type, int loader_id);
static int __add_default_slots();
static candidate_process_context_t *__find_slot_from_static_type(int type)
{
+ candidate_process_context_t *cpc;
GList *iter = candidate_slot_list;
- if (type == LAUNCHPAD_TYPE_DYNAMIC || type == LAUNCHPAD_TYPE_UNSUPPORTED)
+ if (type == LAUNCHPAD_TYPE_DYNAMIC ||
+ type == LAUNCHPAD_TYPE_UNSUPPORTED)
return NULL;
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+ cpc = (candidate_process_context_t *)iter->data;
if (type == cpc->type)
return cpc;
static candidate_process_context_t *__find_slot_from_pid(int pid)
{
+ candidate_process_context_t *cpc;
GList *iter = candidate_slot_list;
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+ cpc = (candidate_process_context_t *)iter->data;
if (pid == cpc->pid)
return cpc;
static candidate_process_context_t *__find_slot_from_caller_pid(int caller_pid)
{
+ candidate_process_context_t *cpc;
GList *iter = candidate_slot_list;
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+ cpc = (candidate_process_context_t *)iter->data;
if (caller_pid == cpc->caller_pid)
return cpc;
static candidate_process_context_t *__find_slot_from_loader_id(int id)
{
+ candidate_process_context_t *cpc;
GList *iter = candidate_slot_list;
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
+ cpc = (candidate_process_context_t *)iter->data;
if (id == cpc->loader_id)
return cpc;
{
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
- if (kill(pid, SIGKILL) == -1)
- _E("send SIGKILL: %s", strerror_r(errno, err_str, sizeof(err_str)));
+ if (kill(pid, SIGKILL) == -1) {
+ _E("send SIGKILL: %s",
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
}
static void __refuse_candidate_process(int server_fd)
int client_pid = 0;
int recv_ret = 0;
- if (server_fd == -1 || out_client_fd == NULL || out_client_pid == NULL) {
+ 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;
_set_sock_option(client_fd, 1);
- recv_ret = recv(client_fd, &client_pid, sizeof(client_pid), MSG_WAITALL);
-
+ recv_ret = recv(client_fd, &client_pid, sizeof(client_pid),
+ MSG_WAITALL);
if (recv_ret == -1) {
_E("recv error!");
goto error;
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", SOCKET_PATH, getuid(),
- LAUNCHPAD_LOADER_SOCKET_NAME, type, loader_id);
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+ SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
+ type, loader_id);
fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd < 0) {
return -1;
}
-static int __set_access(const char* appId)
+static int __set_access(const char *appid)
{
- return security_manager_prepare_app(appId) == SECURITY_MANAGER_SUCCESS ? 0 : -1;
+ return security_manager_prepare_app(appid);
}
-static int __get_launchpad_type(const char* internal_pool, const char* hwacc, const char *app_type)
+static int __get_launchpad_type(const char *internal_pool, const char *hwacc,
+ const char *app_type)
{
if (app_type && strcmp(app_type, "webapp") == 0) {
_D("[launchpad] launchpad type: wrt");
if (internal_pool && strcmp(internal_pool, "true") == 0 && hwacc) {
if (strcmp(hwacc, "NOT_USE") == 0) {
- _D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
+ _D("[launchpad] launchpad type: S/W(%d)",
+ LAUNCHPAD_TYPE_SW);
return LAUNCHPAD_TYPE_SW;
- }
- if (strcmp(hwacc, "USE") == 0) {
- _D("[launchpad] launchpad type: H/W(%d)", LAUNCHPAD_TYPE_HW);
+ } else if (strcmp(hwacc, "USE") == 0) {
+ _D("[launchpad] launchpad type: H/W(%d)",
+ LAUNCHPAD_TYPE_HW);
return LAUNCHPAD_TYPE_HW;
- }
- if (strcmp(hwacc, "SYS") == 0) {
+ } else if (strcmp(hwacc, "SYS") == 0) {
if (sys_hwacc == SETTING_HW_ACCELERATION_ON) {
- _D("[launchpad] launchpad type: H/W(%d)", LAUNCHPAD_TYPE_HW);
+ _D("[launchpad] launchpad type: H/W(%d)",
+ LAUNCHPAD_TYPE_HW);
return LAUNCHPAD_TYPE_HW;
} else if (sys_hwacc == SETTING_HW_ACCELERATION_OFF) {
- _D("[launchpad] launchpad type: S/W(%d)", LAUNCHPAD_TYPE_SW);
+ _D("[launchpad] launchpad type: S/W(%d)",
+ LAUNCHPAD_TYPE_SW);
return LAUNCHPAD_TYPE_SW;
}
}
return 0;
}
-static void __send_result_to_caller(int clifd, int ret, const char* app_path)
+static void __send_result_to_caller(int clifd, int ret, const char *app_path)
{
char *cmdline;
cmdline = _proc_get_cmdline_bypid(ret);
if (cmdline == NULL) {
- _E("The app process might be terminated while we are wating %d", ret);
+ _E("The app process might be terminated while we are wating %d",
+ ret);
__real_send(clifd, -1); /* abnormally launched*/
return;
}
char loader_id_str[10] = {0, };
char argbuf[LOADER_ARG_LEN];
char *argv[] = {NULL, NULL, NULL, NULL, NULL, NULL};
- candidate_process_context_t* cpt = __find_slot(type, loader_id);
+ candidate_process_context_t *cpt = __find_slot(type, loader_id);
if (cpt == NULL)
return -1;
static gboolean __handle_preparing_candidate_process(gpointer user_data)
{
- candidate_process_context_t *cpc = (candidate_process_context_t *)user_data;
+ candidate_process_context_t *cpc;
+ cpc = (candidate_process_context_t *)user_data;
__prepare_candidate_process(cpc->type, cpc->loader_id);
_D("Prepare another candidate process");
cpc->timer = 0;
if (cpc == NULL)
return;
- if (cpc->detection_method & METHOD_TIMEOUT)
+ if (cpc->detection_method & METHOD_TIMEOUT) {
cpc->timer = g_timeout_add(cpc->timeout_val,
- __handle_preparing_candidate_process, cpc);
+ __handle_preparing_candidate_process, cpc);
+ }
}
-static int __send_launchpad_loader(candidate_process_context_t *cpc, app_pkt_t *pkt,
- const char *app_path, int clifd)
+static int __send_launchpad_loader(candidate_process_context_t *cpc,
+ app_pkt_t *pkt, const char *app_path, int clifd)
{
char sock_path[PATH_MAX];
int pid = -1;
__normal_fork_exec(app_argc, app_argv);
}
-static int __prepare_exec(const char *appId, const char *app_path,
+static int __prepare_exec(const char *appid, const char *app_path,
appinfo_t *menu_info, bundle * kb)
{
char *file_name;
/* SET PRIVILEGES*/
if (bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) {
- _D("appId: %s / app_path : %s ", appId, app_path);
- if ((ret = __set_access(appId)) != 0) {
- _D("fail to set privileges - check your package's credential : %d\n", ret);
+ _D("appId: %s / app_path : %s ", appid, app_path);
+ ret = __set_access(appid);
+ if (ret != 0) {
+ _D("fail to set privileges - check "
+ "your package's credential : %d\n",
+ ret);
return -1;
}
}
}
static int __launch_directly(const char *appid, const char *app_path, int clifd,
- bundle* kb, appinfo_t *menu_info, candidate_process_context_t *cpc)
+ bundle *kb, appinfo_t *menu_info,
+ candidate_process_context_t *cpc)
{
char sock_path[PATH_MAX];
int pid = fork();
for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
close(iter_fd);
- snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d", getuid(), getpid());
+ snprintf(sock_path, sizeof(sock_path), "/run/user/%d/%d",
+ getuid(), getpid());
unlink(sock_path);
PERF("prepare exec - first done");
_D("lock up test log(no error) : prepare exec - first done");
- if (__prepare_exec(appid, app_path,
- menu_info, kb) < 0) {
+ if (__prepare_exec(appid, app_path, menu_info, kb) < 0) {
SECURE_LOGE("preparing work fail to launch - "
"can not launch %s\n", appid);
exit(-1);
fd_list = src->poll_fds;
do {
tmp = (GPollFD *) fd_list->data;
- if ((tmp->revents & (G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_NVAL)))
+ if ((tmp->revents & (G_IO_IN | G_IO_PRI | G_IO_HUP |
+ G_IO_NVAL)))
return TRUE;
fd_list = fd_list->next;
} while (fd_list);
.finalize = __glib_finalize
};
-static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type, int loader_id)
+static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type,
+ int loader_id)
{
int r;
GPollFD *gpollfd;
int type = lc->type;
int loader_id = lc->loader_id;
gushort revents = lc->gpollfd->revents;
-
candidate_process_context_t *cpc = __find_slot(type, loader_id);
if (cpc == NULL)
return G_SOURCE_REMOVE;
if (revents & (G_IO_HUP | G_IO_NVAL)) {
- SECURE_LOGE("Type %d candidate process was (POLLHUP|POLLNVAL), pid: %d", cpc->type,
- cpc->pid);
+ SECURE_LOGE("Type %d candidate process was (POLLHUP|POLLNVAL), "
+ "pid: %d", cpc->type, cpc->pid);
close(cpc->send_fd);
cpc->prepared = false;
int loader_id = lc->loader_id;
int client_fd;
int client_pid;
+ int ret;
candidate_process_context_t *cpc = __find_slot(type, loader_id);
return G_SOURCE_REMOVE;
if (!cpc->prepared) {
- if (__accept_candidate_process(fd, &client_fd, &client_pid) >= 0) {
+ ret = __accept_candidate_process(fd, &client_fd, &client_pid);
+ if (ret >= 0) {
cpc->prepared = true;
cpc->send_fd = client_fd;
- SECURE_LOGD("Type %d candidate process was connected, pid: %d", type,
- cpc->pid);
-
+ SECURE_LOGD("Type %d candidate process was connected, "
+ "pid: %d", type, cpc->pid);
cpc->source = __poll_fd(client_fd, G_IO_IN | G_IO_HUP,
- (GSourceFunc)__handle_loader_client_event, type, loader_id);
+ __handle_loader_client_event, type,
+ loader_id);
if (cpc->source == 0)
close(client_fd);
}
static gboolean __handle_sigchild(gpointer data)
{
+ candidate_process_context_t *cpc;
loader_context_t *lc = (loader_context_t *) data;
int fd = lc->gpollfd->fd;
struct signalfd_siginfo siginfo;
break;
}
__launchpad_process_sigchld(&siginfo);
- candidate_process_context_t *cpc = __find_slot_from_pid(siginfo.ssi_pid);
-
+ cpc = __find_slot_from_pid(siginfo.ssi_pid);
if (cpc != NULL) {
cpc->prepared = false;
__prepare_candidate_process(cpc->type, cpc->loader_id);
__remove_slot(LAUNCHPAD_TYPE_DYNAMIC, cpc->loader_id);
cpc = __find_slot_from_caller_pid(siginfo.ssi_pid);
}
-
} while (s > 0);
return G_SOURCE_CONTINUE;
static int __dispatch_cmd_hint(bundle *kb, int detection_method)
{
+ candidate_process_context_t *cpc;
GList *iter = candidate_slot_list;
_W("cmd hint %d", detection_method);
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
-
+ cpc = (candidate_process_context_t *)iter->data;
if (cpc->pid == CANDIDATE_NONE &&
(cpc->detection_method & detection_method)) {
if (cpc->timer > 0) {
const char *caller_pid = NULL;
const char *extra;
int lid;
+ candidate_process_context_t *cpc;
_W("cmd add loader");
add_slot_str = bundle_get_val(kb, AUL_K_LOADER_PATH);
if (add_slot_str && caller_pid) {
lid = __make_loader_id();
- candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid,
- atoi(caller_pid), add_slot_str, extra, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 2000);
+ cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid),
+ add_slot_str, extra, true,
+ METHOD_TIMEOUT | METHOD_VISIBILITY, 2000);
__set_timer(cpc);
return lid;
}
app_pkt_t *pkt = NULL;
appinfo_t *menu_info = NULL;
candidate_process_context_t *cpc;
-
const char *app_path = NULL;
int pid = -1;
int clifd = -1;
SECURE_LOGD("pkg_type : %s\n", menu_info->pkg_type);
if ((loader_id = __get_loader_id(kb)) <= PAD_LOADER_ID_STATIC) {
- type = __get_launchpad_type(menu_info->internal_pool, menu_info->hwacc,
- menu_info->app_type);
+ type = __get_launchpad_type(menu_info->internal_pool,
+ menu_info->hwacc, menu_info->app_type);
if (type < 0) {
_E("failed to get launchpad type");
goto end;
}
- if (menu_info->comp_type && strcmp(menu_info->comp_type, "svcapp") == 0)
+ if (menu_info->comp_type &&
+ strcmp(menu_info->comp_type, "svcapp") == 0)
loader_id = PAD_LOADER_ID_DIRECT;
else
loader_id = PAD_LOADER_ID_STATIC;
if (loader_id == PAD_LOADER_ID_DIRECT ||
(cpc = __find_slot(type, loader_id)) == NULL) {
_W("Launch directly");
- pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL);
+ pid = __launch_directly(menu_info->appid, app_path, clifd, kb,
+ menu_info, NULL);
} else {
if (cpc->prepared) {
_W("Launch %d type process", type);
- pid = __send_launchpad_loader(cpc, pkt, app_path, clifd);
- } else if (cpc->type == LAUNCHPAD_TYPE_SW || cpc->type == LAUNCHPAD_TYPE_HW) {
- cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, loader_id);
- if (cpc != NULL && cpc->prepared) {
- _W("Launch common type process");
- pid = __send_launchpad_loader(cpc, pkt, app_path, clifd);
- } else {
- _W("Launch directly");
- pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL);
- }
+ pid = __send_launchpad_loader(cpc, pkt, app_path,
+ clifd);
+ } else if (cpc->type == LAUNCHPAD_TYPE_SW ||
+ cpc->type == LAUNCHPAD_TYPE_HW) {
+ cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, loader_id);
+ if (cpc != NULL && cpc->prepared) {
+ _W("Launch common type process");
+ pid = __send_launchpad_loader(cpc, pkt,
+ app_path, clifd);
+ } else {
+ _W("Launch directly");
+ pid = __launch_directly(menu_info->appid,
+ app_path, clifd, kb, menu_info,
+ NULL);
+ }
} else {
_W("Launch directly");
- pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, cpc);
+ pid = __launch_directly(menu_info->appid, app_path,
+ clifd, kb, menu_info, cpc);
}
}
return G_SOURCE_CONTINUE;
}
-static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path,
- const char *loader_extra, bool enabled, int detection_method, int timeout_val)
+static candidate_process_context_t *__add_slot(int type, int loader_id,
+ int caller_pid, const char *loader_path,
+ const char *loader_extra, bool enabled, int detection_method,
+ int timeout_val)
{
candidate_process_context_t *cpc;
int fd = -1;
+ guint pollfd;
if (__find_slot(type, loader_id) != NULL)
return NULL;
- cpc = (candidate_process_context_t *)malloc(sizeof(candidate_process_context_t));
+ cpc = (candidate_process_context_t *)malloc(
+ sizeof(candidate_process_context_t));
if (cpc == NULL)
return NULL;
fd = __listen_candidate_process(cpc->type, cpc->loader_id);
if (fd == -1) {
- _E("[launchpad] Listening the socket to the type %d candidate process failed.",
- cpc->type);
+ _E("[launchpad] Listening the socket to "
+ "the type %d candidate process failed.",
+ cpc->type);
free(cpc);
return NULL;
}
- if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event, cpc->type, cpc->loader_id) == 0) {
+ pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event,
+ cpc->type, cpc->loader_id);
+ if (pollfd == 0) {
close(fd);
free(cpc);
return NULL;
static int __remove_slot(int type, int loader_id)
{
+ candidate_process_context_t *cpc;
GList *iter;
iter = candidate_slot_list;
while (iter) {
- candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data;
-
+ cpc = (candidate_process_context_t *)iter->data;
if (type == cpc->type && loader_id == cpc->loader_id) {
if (cpc->pid > 0)
__kill_process(cpc->pid);
if (cpc->source > 0)
g_source_remove(cpc->source);
- candidate_slot_list = g_list_delete_link(candidate_slot_list, iter);
+ candidate_slot_list = g_list_delete_link(
+ candidate_slot_list, iter);
free(cpc->loader_path);
if (cpc->loader_extra)
free(cpc->loader_extra);
static int __init_launchpad_fd(int argc, char **argv)
{
int fd = -1;
+ guint pollfd;
fd = __launchpad_pre_init(argc, argv);
if (fd < 0) {
return -1;
}
- if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_launch_event, 0, 0) == 0) {
+ pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_launch_event, 0,
+ 0);
+ if (pollfd == 0) {
close(fd);
return -1;
}
static int __init_sigchild_fd(void)
{
int fd = -1;
+ guint pollfd;
fd = __signal_get_sigchld_fd();
if (fd < 0) {
return -1;
}
- if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_sigchild, 0, 0) == 0) {
+ pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_sigchild, 0, 0);
+ if (pollfd == 0) {
close(fd);
return -1;
}
return 0;
}
-static int __add_default_slots()
+static int __add_default_slots(void)
{
- if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
- NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+ candidate_process_context_t *cpc;
+ int ret;
+
+ cpc = __add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0,
+ LOADER_PATH_DEFAULT, NULL, true,
+ METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+ if (cpc == NULL)
return -1;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC) != 0)
+
+ ret = __prepare_candidate_process(LAUNCHPAD_TYPE_COMMON,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return -1;
- if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
- NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+ cpc = __add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0,
+ LOADER_PATH_DEFAULT, NULL, true,
+ METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+ if (cpc == NULL)
return -1;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC) != 0)
+
+ ret = __prepare_candidate_process(LAUNCHPAD_TYPE_SW,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return -1;
- if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT,
- NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+ cpc = __add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0,
+ LOADER_PATH_DEFAULT, NULL, true,
+ METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+ if (cpc == NULL)
return -1;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC) != 0)
+
+ ret = __prepare_candidate_process(LAUNCHPAD_TYPE_HW,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return -1;
if (access(LOADER_PATH_WRT, F_OK | X_OK) == 0) {
#ifdef _APPFW_FEATURE_LAZY_LOADER
- if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT,
- NULL, false, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL)
+ cpc = __add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0,
+ LOADER_PATH_WRT, NULL, false,
+ METHOD_TIMEOUT | METHOD_DEMAND, 5000);
+ if (cpc == NULL)
return -1;
#else
- if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT,
- NULL, true, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL)
+ cpc = __add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0,
+ LOADER_PATH_WRT, NULL, true,
+ METHOD_TIMEOUT | METHOD_DEMAND, 5000);
+ if (cpc == NULL)
return -1;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC) != 0)
+
+ ret = __prepare_candidate_process(LAUNCHPAD_TYPE_WRT,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return -1;
#endif
}
if (access(LOADER_PATH_JS_NATIVE, F_OK | X_OK) == 0) {
- if (__add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_JS_NATIVE,
- NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL)
+ cpc = __add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC,
+ 0, LOADER_PATH_JS_NATIVE, NULL, true,
+ METHOD_TIMEOUT | METHOD_VISIBILITY, 5000);
+ if (cpc == NULL)
return -1;
- if (__prepare_candidate_process(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC) != 0)
+
+ ret = __prepare_candidate_process(LAUNCHPAD_TYPE_JS_NATIVE,
+ PAD_LOADER_ID_STATIC);
+ if (ret != 0)
return -1;
}
static int __before_loop(int argc, char **argv)
{
- if (__init_sigchild_fd() != 0) {
+ int ret;
+
+ ret = __init_sigchild_fd();
+ if (ret != 0) {
_E("__init_sigchild_fd() failed");
return -1;
}
- if (__init_launchpad_fd(argc, argv) != 0) {
+ ret = __init_launchpad_fd(argc, argv);
+ if (ret != 0) {
_E("__init_launchpad_fd() failed");
return -1;
}
- if (vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &sys_hwacc) != VCONF_OK)
- _E("Failed to get vconf int: %s", VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+ ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &sys_hwacc);
+ if (ret != VCONF_OK) {
+ _E("Failed to get vconf int: %s",
+ VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+ }
SECURE_LOGD("sys hwacc: %d", sys_hwacc);
- if (vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, __vconf_cb, NULL) != 0)
- _E("Failed to register callback for %s", VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+ ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
+ __vconf_cb, NULL);
+ if (ret != 0) {
+ _E("Failed to register callback for %s",
+ VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
+ }
return 0;
}
static void __set_priority(void)
{
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
- int res = setpriority(PRIO_PROCESS, 0, -12);
+ int res;
- if (res == -1)
- SECURE_LOGE("Setting process (%d) priority to -12 failed, errno: %d (%s)",
- getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+ res = setpriority(PRIO_PROCESS, 0, -12);
+ if (res == -1) {
+ SECURE_LOGE("Setting process (%d) priority to -12 failed, "
+ "errno: %d (%s)", getpid(), errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
}
#endif
mainloop = g_main_loop_new(NULL, FALSE);
if (!mainloop) {
- _E("failed to create glib main loop");
+ _E("Failed to create glib main loop");
return -1;
}
return -1;
}
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%s", getuid(), name);
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/user/%d/%s",
+ getuid(), name);
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
char buf[MAX_CMD_BUFSZ];
int ret;
char *ptr;
+ int len;
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
ret = __read_proc(buf, buf, sizeof(buf));
return strdup(ptr);
} else if (strncmp(buf, BASH_NAME, BASH_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME, OPROFILE_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2], OPTION_VALGRIND_NAME,
- OPTION_VALGRIND_SIZE) == 0) {
- return strdup(&buf[BASH_SIZE + OPROFILE_SIZE + OPTION_VALGRIND_SIZE + 3]);
+ if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME,
+ OPROFILE_SIZE) == 0) {
+ if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2],
+ OPTION_VALGRIND_NAME,
+ OPTION_VALGRIND_SIZE) == 0) {
+ len = BASH_SIZE + OPROFILE_SIZE +
+ OPTION_VALGRIND_SIZE + 3;
+ return strdup(&buf[len]);
}
}
}
return strdup(buf);
}
-appinfo_t* _appinfo_create(bundle *kb)
+appinfo_t *_appinfo_create(bundle *kb)
{
appinfo_t *menu_info;
const char *ptr = NULL;
free(menu_info);
}
-void _modify_bundle(bundle * kb, int caller_pid, appinfo_t *menu_info, int cmd)
+void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd)
{
char *ptr;
char exe[MAX_PATH_LEN];
break;
ptr += flag;
- flag = __parse_app_path(ptr, value, sizeof(value));
+ flag = __parse_app_path(ptr, value,
+ sizeof(value));
if (flag < 0)
break;
ptr += flag;
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", SOCKET_PATH, getuid(),
- LAUNCHPAD_LOADER_SOCKET_NAME, type, id);
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%d/%s%d-%d",
+ SOCKET_PATH, getuid(), LAUNCHPAD_LOADER_SOCKET_NAME,
+ type, id);
_D("connect to %s", addr.sun_path);
while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
return -1;
}
-void _set_env(appinfo_t *menu_info, bundle * kb)
+void _set_env(appinfo_t *menu_info, bundle *kb)
{
const char *str;
setenv("TIZEN_API_VERSION", str, 1);
}
-char** _create_argc_argv(bundle * kb, int *margc)
+char **_create_argc_argv(bundle *kb, int *margc)
{
char **argv;
int argc;
+/*
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
free(__root_path);
}
-static int __set_access(const char* appId, const char* pkg_type,
- const char* app_path)
+static int __set_access(const char *appid, const char *pkg_type,
+ const char *app_path)
{
- return security_manager_prepare_app(appId) == SECURITY_MANAGER_SUCCESS ? 0 : -1;
+ return security_manager_prepare_app(appid);
}
static int __prepare_exec(const char *appid, const char *app_path,
{
const char *file_name = NULL;
char process_name[AUL_PR_NAME] = { 0, };
- int ret = 0;
+ int ret;
__preexec_run(pkg_type, appid, app_path);
/* SET PRIVILEGES*/
SECURE_LOGD("[candidata] appid : %s / pkg_type : %s / app_path : %s",
appid, pkg_type, app_path);
- if ((ret = __set_access(appid, pkg_type, app_path)) < 0) {
- _D("fail to set privileges - check your package's credential : %d\n", ret);
+ ret = __set_access(appid, pkg_type, app_path);
+ if (ret < 0) {
+ _D("fail to set privileges - check your package's credential: "
+ "%d\n", ret);
return -1;
}
/*
* SET DUMPABLE - for coredump
- * This dumpable flag should be set after calling perm_app_set_privilege()
+ * This dumpable flag should be set after
+ * calling perm_app_set_privilege().
*/
prctl(PR_SET_DUMPABLE, 1);
}
static int __default_launch_cb(bundle *kb, const char *appid,
- const char *app_path, const char *pkg_type, int loader_type)
+ const char *app_path, const char *pkg_type, int loader_type)
{
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
#ifdef _APPFW_FEATURE_PRIORITY_CHANGE
_D("high_priority: %s", high_priority);
if (strncmp(high_priority, "true", 4) == 0) {
res = setpriority(PRIO_PROCESS, 0, -10);
- if (res == -1)
- SECURE_LOGE("Setting process (%d) priority to -10 failed, errno: %d (%s)",
- getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+ if (res == -1) {
+ SECURE_LOGE("Setting process (%d) priority "
+ "to -10 failed, errno: %d (%s)",
+ getpid(), errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
}
bundle_del(kb, AUL_K_HIGHPRIORITY);
#endif
if (__prepare_exec(appid, app_path, pkg_type, loader_type) < 0) {
_E("__candidate_process_prepare_exec() failed");
- if (access(app_path, F_OK | R_OK))
- SECURE_LOGE("access() failed for file: \"%s\", error: %d (%s)",
- app_path, errno, strerror_r(errno, err_str, sizeof(err_str)));
-
+ if (access(app_path, F_OK | R_OK)) {
+ SECURE_LOGE("access() failed for file: \"%s\", "
+ "error: %d (%s)", app_path, errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
exit(-1);
}
return 0;
}
-static int __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
- char* out_app_path, int* out_argc, char ***out_argv, int type)
+static int __candidate_process_launchpad_main_loop(app_pkt_t *pkt,
+ char *out_app_path, int *out_argc, char ***out_argv, int type)
{
- bundle *kb = NULL;
+ bundle *kb;
appinfo_t *menu_info = NULL;
const char *app_path = NULL;
int tmp_argc = 0;
exit(-1);
}
- _modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd);
+ _modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info,
+ pkt->cmd);
__appid = strdup(menu_info->appid);
if (__appid == NULL) {
__default_launch_cb(kb, __appid, app_path, menu_info->pkg_type, type);
if (__loader_callbacks->launch) {
- ret = __loader_callbacks->launch(tmp_argc, tmp_argv, app_path, __appid, __pkgid,
- menu_info->pkg_type, __loader_user_data);
+ ret = __loader_callbacks->launch(tmp_argc, tmp_argv, app_path,
+ __appid, __pkgid, menu_info->pkg_type,
+ __loader_user_data);
}
/* SET ENVIROMENT*/
*out_argc = tmp_argc;
(*out_argv)[0] = out_app_path;
- for (i = 0; i < *out_argc; i++)
- SECURE_LOGD("input argument %d : %s##", i, (*out_argv)[i]);
- } else
+ for (i = 0; i < *out_argc; i++) {
+ SECURE_LOGD("input argument %d : %s##", i,
+ (*out_argv)[i]);
+ }
+ } else {
exit(-1);
+ }
if (menu_info != NULL)
_appinfo_free(menu_info);
app_pkt_t *pkt;
_D("[candidate] ECORE_FD_READ");
- pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ pkt = (app_pkt_t *)malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
if (!pkt) {
_D("[candidate] out of memory1");
exit(-1);
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
- if (res == -1)
- SECURE_LOGE("Setting process (%d) priority to %d failed, errno: %d (%s)",
- getpid(), LOWEST_PRIO, errno, strerror_r(errno, err_str, sizeof(err_str)));
+ if (res == -1) {
+ SECURE_LOGE("Setting process (%d) priority to %d failed, "
+ "errno: %d (%s)", getpid(), LOWEST_PRIO, errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
#endif
__preexec_init(argc, argv);
/* TODO : should be add to check permission in the kernel*/
setsid();
- if (argc > 3)
- extra = bundle_decode((const bundle_raw *)argv[3], strlen(argv[3]));
+ if (argc > 3) {
+ extra = bundle_decode((bundle_raw *)argv[3],
+ strlen(argv[3]));
+ }
if (__loader_callbacks->create) {
- __loader_callbacks->create(extra, __loader_type, __loader_user_data);
+ __loader_callbacks->create(extra, __loader_type,
+ __loader_user_data);
ret = 0;
}
#ifdef _APPFW_FEATURE_LOADER_PRIORITY
res = setpriority(PRIO_PGRP, 0, 0);
- if (res == -1)
- SECURE_LOGE("Setting process (%d) priority to 0 failed, errno: %d (%s)",
- getpid(), errno, strerror_r(errno, err_str, sizeof(err_str)));
+ if (res == -1) {
+ SECURE_LOGE("Setting process (%d) priority to 0 failed, "
+ "errno: %d (%s)", getpid(), errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
#endif
client_fd = _connect_to_launchpad(__loader_type, __loader_id);
if (client_fd == -1) {
static int __after_loop(void)
{
- if (__loader_callbacks->terminate)
- return __loader_callbacks->terminate(__argc, __argv, __loader_user_data);
+ if (__loader_callbacks->terminate) {
+ return __loader_callbacks->terminate(__argc, __argv,
+ __loader_user_data);
+ }
return -1;
}
API int launchpad_loader_main(int argc, char **argv,
- loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter,
- void *user_data)
+ loader_lifecycle_callback_s *callbacks,
+ loader_adapter_s *adapter, void *user_data)
{
if (argc < 3) {
_E("too few argument.");
return __after_loop();
}
+
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
static loader_receiver_cb __receiver;
static int __argc;
-static char** __argv;
+static char **__argv;
static void __init_window(void)
{
- Evas_Object *win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
- if (win) {
- elm_win_precreated_object_set(win);
-
- Evas_Object *bg = elm_bg_add(win);
- if (bg) {
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, bg);
- elm_bg_precreated_object_set(bg);
- } else {
- _E("[candidate] elm_bg_add() failed");
- }
+ Evas_Object *win;
+ Evas_Object *bg;
+ Evas_Object *conform;
- Evas_Object *conform = elm_conformant_add(win);
- if (conform) {
- evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, conform);
- elm_conformant_precreated_object_set(conform);
- } else {
- _E("elm_conformant_add() failed");
- }
- } else {
+ win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
+ if (win == NULL) {
_E("[candidate] elm_win_add() failed");
+ return;
+ }
+
+ elm_win_precreated_object_set(win);
+
+ bg = elm_bg_add(win);
+ if (bg) {
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bg);
+ elm_bg_precreated_object_set(bg);
+ } else {
+ _E("[candidate] elm_bg_add() failed");
+ }
+
+ conform = elm_conformant_add(win);
+ if (conform) {
+ evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, conform);
+ elm_conformant_precreated_object_set(conform);
+ } else {
+ _E("elm_conformant_add() failed");
}
}
static void __init_theme(void)
{
char *theme = elm_theme_list_item_path_get(eina_list_data_get(
- elm_theme_list_get(NULL)), NULL);
+ elm_theme_list_get(NULL)), NULL);
Eina_Bool is_exist = edje_file_group_exists(theme, "*");
if (!is_exist)
_D("theme path: %s", theme);
}
static int __loader_launch_cb(int argc, char **argv, const char *app_path,
- const char *appid, const char *pkgid, const char *pkg_type, void *user_data)
+ const char *appid, const char *pkgid, const char *pkg_type,
+ void *user_data)
{
return 0;
}
do_dlopen:
handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
if (handle == NULL) {
- _E("dlopen failed(%s). Please complile with -fPIE and link with -pie flag",
- dlerror());
+ _E("dlopen failed(%s). Please complile with -fPIE and "
+ "link with -pie flag", dlerror());
goto do_exec;
}
dl_main = dlsym(handle, "main");
if (dl_main == NULL) {
- _E("dlsym not founded(%s). Please export 'main' function", dlerror());
+ _E("dlsym not founded(%s). Please export 'main' function",
+ dlerror());
dlclose(handle);
goto do_exec;
}
do_exec:
if (access(argv[0], F_OK | R_OK)) {
SECURE_LOGE("access() failed for file: \"%s\", error: %d (%s)",
- argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
+ argv[0], errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
} else {
SECURE_LOGD("[candidate] Exec application (%s)", __argv[0]);
if (libdir)
setenv("LD_LIBRARY_PATH", libdir, 1);
free(libdir);
- if (execv(argv[0], argv) < 0)
- SECURE_LOGE("execv() failed for file: \"%s\", error: %d (%s)",
- argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
+ if (execv(argv[0], argv) < 0) {
+ SECURE_LOGE("execv() failed for file: \"%s\", "
+ "error: %d (%s)", argv[0], errno,
+ strerror_r(errno, err_str, sizeof(err_str)));
+ }
}
return -1;
-
}
-static Eina_Bool __process_fd_handler(void* data, Ecore_Fd_Handler *handler)
+static Eina_Bool __process_fd_handler(void *data, Ecore_Fd_Handler *handler)
{
- int fd = ecore_main_fd_handler_fd_get(handler);
+ int fd;
+ fd = ecore_main_fd_handler_fd_get(handler);
if (fd == -1) {
_D("[candidate] ECORE_FD_GET");
exit(-1);
loader_receiver_cb receiver)
{
__fd_handler = ecore_main_fd_handler_add(fd,
- (Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_ERROR),
- __process_fd_handler, NULL, NULL, NULL);
+ ECORE_FD_READ | ECORE_FD_ERROR, __process_fd_handler,
+ NULL, NULL, NULL);
if (__fd_handler == NULL) {
_D("fd_handler is NULL");
close(fd);
return launchpad_loader_main(argc, argv, &callbacks, &adapter, NULL);
}
+