app_info_from_db *_get_app_info_from_bundle_by_pkgname(const char *pkgname, bundle *kb);
void _modify_bundle(bundle * kb, int caller_pid, app_info_from_db * menu_info, int cmd);
-int _create_server_sock(int pid);
+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);
#define EXEC_CANDIDATE_WAIT 1
#define DIFF(a,b) (((a)>(b))?(a)-(b):(b)-(a))
#define CANDIDATE_NONE 0
-#define PROCESS_POOL_LAUNCHPAD_PID -5
+#define PROCESS_POOL_LAUNCHPAD_SOCK ".launchpad-process-pool-sock"
typedef struct {
int pid;
{
struct sockaddr_un addr;
int fd = -1;
- int listen_fds = 0;
- int i;
_D("[launchpad] enter, type: %d", type);
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");
{
char sock_path[UNIX_PATH_MAX] = {0,};
int pid = fork();
+ int max_fd;
+ int iter_fd;
if (pid == 0) {
PERF("fork done");
_D("lock up test log(no error) : fork done");
- close(clifd);
__signal_unblock_sigchld();
__signal_fini();
+ max_fd = sysconf(_SC_OPEN_MAX);
+ for (iter_fd = 3; iter_fd <= max_fd; iter_fd++)
+ close(iter_fd);
+
snprintf(sock_path, UNIX_PATH_MAX, "/run/user/%d/%d", getuid(), getpid());
unlink(sock_path);
}
}
+static int __create_sock_activation(void)
+{
+ int fds;
+
+ fds = sd_listen_fds(0);
+ if (fds == 1)
+ return SD_LISTEN_FDS_START;
+ else if (fds > 1)
+ _E("Too many file descriptors received.\n");
+ else
+ _D("There is no socket stream");
+
+ return -1;
+}
+
static int __launchpad_pre_init(int argc, char **argv)
{
int fd;
__signal_init();
/* create launchpad sock */
- fd = _create_server_sock(PROCESS_POOL_LAUNCHPAD_PID);
+ fd = __create_sock_activation();
if (fd < 0) {
- _E("server sock error %d", fd);
- return -1;
+ fd = _create_server_sock(PROCESS_POOL_LAUNCHPAD_SOCK);
+ if (fd < 0) {
+ _E("server sock error %d", fd);
+ return -1;
+ }
}
return fd;
return -2;
}
-int _create_server_sock(int pid)
+int _create_server_sock(const char *name)
{
struct sockaddr_un saddr;
int fd;
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d", getuid(), pid);
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%s", getuid(), name);
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
_D("[candidate] recv_ret: %d, pkt->len: %d", recv_ret, pkt->len);
__loader_adapter->remove_fd(__loader_user_data, fd);
+ close(fd);
ret = __candidate_process_launchpad_main_loop(pkt, __argv[0], &__argc, &__argv,
__loader_type);
SECURE_LOGD("[candidate] real app argv[0]: %s, real app argc: %d", __argv[0],
__argc);
- close(fd);
free(pkt);
if (ret >= 0) {