From 098ec057c65063360674e6e9f46aa290cb81cc20 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Jun 2016 14:55:34 +0900 Subject: [PATCH 01/16] Remove others permission about the user's directory Change-Id: I94dd0982485db160374090614659f2be955716a1 Signed-off-by: Hwankyu Jhun --- packaging/debug-launchpad.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/debug-launchpad.service b/packaging/debug-launchpad.service index 18af17f..0fb5989 100644 --- a/packaging/debug-launchpad.service +++ b/packaging/debug-launchpad.service @@ -6,5 +6,5 @@ After=dbus.service ac.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 +ExecStartPre=-/usr/bin/chmod 0700 /run/aul/apps/%U ExecStart=/usr/bin/debug_launchpad_preloading_preinitializing_daemon -- 2.7.4 From c0bbda2fb8bbfa29181c7636471ba16583e79809 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Jun 2016 16:12:29 +0900 Subject: [PATCH 02/16] Prevent app sockets from being deleted by attacker - Requires: https://review.tizen.org/gerrit/#/c/76214/ Change-Id: I761a86f219f0c9c7513930430c38c699d3fd1625 Signed-off-by: Hwankyu Jhun --- include/common.h | 1 + src/common.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/signal_util.c | 9 +++---- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/include/common.h b/include/common.h index c01d142..9210790 100644 --- a/include/common.h +++ b/include/common.h @@ -69,6 +69,7 @@ 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); +int _delete_sock_path(int pid, uid_t uid); #endif /* __COMMON_H__ */ diff --git a/src/common.c b/src/common.c index 6b19d93..0f14356 100644 --- a/src/common.c +++ b/src/common.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #ifdef _APPFW_FEATURE_SOCKET_ACTIVATION @@ -77,6 +78,7 @@ static int __create_server_socket(bool is_app) { struct sockaddr_un saddr; int fd; + int ret; if (is_app) fd = socket(AF_UNIX, SOCK_STREAM, 0); @@ -103,6 +105,25 @@ static int __create_server_socket(bool is_app) snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s/apps/%d/%d", SOCKET_PATH, getuid(), getpid()); + ret = mkdir(saddr.sun_path, 0700); + if (ret != 0) { + if (errno == EEXIST) { + if (access(saddr.sun_path, R_OK) != 0) { + _E("Failed to access %s directory - %d", + saddr.sun_path, errno); + close(fd); + return -1; + } + } else { + _E("Failed to create %s directory - %d", + saddr.sun_path, errno); + close(fd); + return -1; + } + } + snprintf(saddr.sun_path, sizeof(saddr.sun_path), + "%s/apps/%d/%d/.app-sock", + SOCKET_PATH, getuid(), getpid()); } else { snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s/daemons/%d/.debug-launchpad-sock", @@ -799,3 +820,53 @@ void _prepare_listen_sock(void) setenv("AUL_LISTEN_SOCK", buf, 1); } +static int __delete_dir(const char *path) +{ + DIR *dp; + struct dirent dentry; + struct dirent *result = NULL; + char buf[PATH_MAX]; + struct stat statbuf; + int ret; + + if (path == NULL) + return -1; + + dp = opendir(path); + if (dp == NULL) + return -1; + + while (readdir_r(dp, &dentry, &result) == 0 && result) { + if (!strcmp(dentry.d_name, ".") || !strcmp(dentry.d_name, "..")) + continue; + + snprintf(buf, sizeof(buf), "%s/%s", path, dentry.d_name); + ret = stat(buf, &statbuf); + if (ret == 0) { + if (S_ISDIR(statbuf.st_mode)) + __delete_dir(buf); + else + unlink(buf); + } + } + + rmdir(path); + closedir(dp); + + return 0; +} + +int _delete_sock_path(int pid, uid_t uid) +{ + char path[PATH_MAX]; + + snprintf(path, sizeof(path), "/run/aul/apps/%d/%d", uid, pid); + if (access(path, F_OK) == 0) + __delete_dir(path); + + if (access(path, F_OK) == 0) + return -1; + + return 0; +} + diff --git a/src/signal_util.c b/src/signal_util.c index 8b1d62f..f0e8dee 100644 --- a/src/signal_util.c +++ b/src/signal_util.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -55,9 +56,7 @@ static void __socket_garbage_collector(void) snprintf(path, sizeof(path), "/proc/%s", dentry->d_name); if (access(path, F_OK) != 0) { /* Flawfinder: ignore */ - snprintf(path, sizeof(path), "%s/apps/%d/%s", - SOCKET_PATH, getuid(), dentry->d_name); - unlink(path); + _delete_sock_path(atoi(dentry->d_name), getuid()); continue; } } @@ -146,9 +145,7 @@ static int __sigchild_action(pid_t dead_pid) _send_app_dead_signal(dead_pid); - snprintf(buf, MAX_LOCAL_BUFSZ, "%s/apps/%d/%d", - SOCKET_PATH, getuid(), dead_pid); - unlink(buf); + _delete_sock_path(dead_pid, getuid()); __socket_garbage_collector(); -- 2.7.4 From fc77ab4347469ef79674dc91436275873f97a7e5 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 29 Jun 2016 21:22:27 +0900 Subject: [PATCH 03/16] Remove unnecessary capability Change-Id: Ie6d5abe9adb03f6118c55bb9e78ad3541365e215 Signed-off-by: Hwankyu Jhun --- packaging/debug-launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/debug-launchpad.spec b/packaging/debug-launchpad.spec index 47517c8..2deff3e 100755 --- a/packaging/debug-launchpad.spec +++ b/packaging/debug-launchpad.spec @@ -75,7 +75,7 @@ rm -rf %{buildroot} %files %license LICENSE %manifest debug-launchpad.manifest -%caps(cap_mac_admin,cap_mac_override,cap_setgid=ei) %{_bindir}/debug_launchpad_preloading_preinitializing_daemon +%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/debug_launchpad_preloading_preinitializing_daemon %if 0%{?appfw_feature_socket_activation} %{_unitdir_user}/debug-launchpad.service %{_unitdir_user}/debug-launchpad.socket -- 2.7.4 From 9cbed95f80f830c5bf6f79f0eea54a7f8a1ddc48 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 29 Jun 2016 21:50:58 +0900 Subject: [PATCH 04/16] Remove unnecessary codes Change-Id: I6693a37e79b7ec134bcfd6bacb6131651914eaef Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 4 +- include/file_util.h | 25 ----------- include/security_util.h | 26 ------------ packaging/debug-launchpad.spec | 2 - src/debug-launchpad.c | 62 ++------------------------- src/debug_util.c | 85 ++----------------------------------- src/file_util.c | 96 ------------------------------------------ src/security_util.c | 67 ----------------------------- src/signal_util.c | 8 ---- 9 files changed, 7 insertions(+), 368 deletions(-) delete mode 100644 include/file_util.h delete mode 100644 include/security_util.h delete mode 100644 src/file_util.c delete mode 100644 src/security_util.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ddb0713..4f68928 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") # Set required packages INCLUDE(FindPkgConfig) -SET(pkgs_requires "dlog glib-2.0 gio-2.0 bundle vconf libsmack security-manager pkgmgr-info") +SET(pkgs_requires "dlog glib-2.0 gio-2.0 bundle vconf security-manager") IF(_APPFW_FEATURE_SOCKET_ACTIVATION) SET(pkgs_requires "${pkgs_requires} libsystemd-daemon") ADD_DEFINITIONS("-D_APPFW_FEATURE_SOCKET_ACTIVATION") @@ -55,9 +55,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") # debug_launchpad_preloading_preinitializing_daemon SET(DEBUG_LAUNCHPAD "debug_launchpad_preloading_preinitializing_daemon") add_executable(${DEBUG_LAUNCHPAD} - src/file_util.c src/debug_util.c - src/security_util.c src/signal_util.c src/common.c src/debug-launchpad.c diff --git a/include/file_util.h b/include/file_util.h deleted file mode 100644 index 1039401..0000000 --- a/include/file_util.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -#ifndef __FILE_UTIL_H__ -#define __FILE_UTIL_H__ - -#include - -int dlp_chmod(const char *path, mode_t mode, int recursive); - -#endif /* __FILE_UTIL_H__ */ - diff --git a/include/security_util.h b/include/security_util.h deleted file mode 100644 index 6029c59..0000000 --- a/include/security_util.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -#ifndef __SECURITY_UTIL_H__ -#define __SECURITY_UTIL_H__ - -int _set_smack_access_label(const char *path, const char *label); -int _apply_smack_rules(const char *subject, const char *object, - const char *access_type); -int _set_access(const char *appid); - -#endif /* __SECURITY_UTIL_H__ */ - diff --git a/packaging/debug-launchpad.spec b/packaging/debug-launchpad.spec index 2deff3e..2d3b388 100755 --- a/packaging/debug-launchpad.spec +++ b/packaging/debug-launchpad.spec @@ -21,8 +21,6 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(libsmack) -BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(security-manager) %if "%{?profile}" == "wearable" diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index 4bf29ad..7e706f2 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -33,11 +33,10 @@ #include #include #include +#include #include "common.h" #include "signal_util.h" -#include "security_util.h" -#include "file_util.h" #include "debug_util.h" #include "perf.h" #include "defs.h" @@ -104,8 +103,8 @@ static int __prepare_exec(const char *appid, const char *app_path, /* SET PRIVILEGES */ _D("appid: %s / pkg_type: %s / app_path: %s", appid, appinfo->pkg_type, app_path); - ret = _set_access(appid); - if (ret != 0) { + ret = security_manager_prepare_app(appid); + if (ret != SECURITY_MANAGER_SUCCESS) { _E("Failed to set privileges " "- check your package's credential: %d", ret); return -1; @@ -161,58 +160,6 @@ static int __prepare_fork(bundle *kb, const char *appid) return 0; } -static int __get_caller_pid(bundle *kb) -{ - const char *str; - int pid; - - str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID); - if (str) - goto end; - - str = bundle_get_val(kb, AUL_K_CALLER_PID); - if (str == NULL) - return -1; - -end: - pid = atoi(str); - if (pid <= 1) - return -1; - - return pid; -} - -static int __redirect_stdfds(int caller_pid) -{ - char buf[PATH_MAX]; - int fd; - int ret = 0; - - /* stdout */ - snprintf(buf, sizeof(buf), "/proc/%d/fd/1", caller_pid); - fd = open(buf, O_WRONLY); - if (fd < 0) { - _E("Failed to open caller(%d) stdout", caller_pid); - ret = 1; - } else { - dup2(fd, 1); - close(fd); - } - - /* stderr */ - snprintf(buf, sizeof(buf), "/proc/%d/fd/2", caller_pid); - fd = open(buf, O_WRONLY); - if (fd < 0) { - _E("Failed to open caller(%d) stderr", caller_pid); - ret += 2; - } else { - dup2(fd, 2); - close(fd); - } - - return ret; -} - static int __normal_fork_exec(int argc, char **argv) { _D("start real fork and exec\n"); @@ -275,9 +222,6 @@ static int __start_process(const char *appid, const char *app_path, SOCKET_PATH, getuid(), getpid()); unlink(sock_path); - if (__redirect_stdfds(__get_caller_pid(kb))) - _E("Failed to redirect caller fds"); - PERF("prepare exec - fisrt done"); _D("lock up test log(no error): prepare exec - first done"); diff --git a/src/debug_util.c b/src/debug_util.c index c71c22e..224de11 100644 --- a/src/debug_util.c +++ b/src/debug_util.c @@ -17,19 +17,13 @@ #include #include #include -#include #include #include #include "defs.h" #include "common.h" -#include "file_util.h" -#include "security_util.h" #include "debug_util.h" -#define LABEL_SDBD "sdbd" -#define LABEL_NETWORK "system::debugging_network" - #define POLL_VALGRIND_LOGFILE 0x00000001 #define POLL_VALGRIND_XMLFILE 0x00000002 #define POLL_VALGRIND_MASSIFFILE 0x00000004 @@ -59,67 +53,14 @@ int _get_valgrind_option(void) return valgrind_option; } -static int __check_pkginfo(const char *appid) -{ - int r; - bool preload = false; - char *storeclientid = NULL; - pkgmgrinfo_pkginfo_h handle; - - r = pkgmgrinfo_pkginfo_get_usr_pkginfo(appid, getuid(), &handle); - if (r != PMINFO_R_OK) { - _E("Failed to get pkginfo: %s", appid); - return -1; - } - - r = pkgmgrinfo_pkginfo_is_preload(handle, &preload); - if (r != PMINFO_R_OK) { - _E("Faield to check preload: %s", appid); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return -1; - } - - r = pkgmgrinfo_pkginfo_get_storeclientid(handle, &storeclientid); - if (r != PMINFO_R_OK) { - _E("Failed to get store client id: %s", appid); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return -1; - } - - if (preload == true || (storeclientid && storeclientid[0] != '\0')) { - _E("Debugging is not allowed"); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return -1; - } - - r = pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - if (r != PMINFO_R_OK) { - _E("Failed to destroy pkginfo: %s", appid); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - } - - return 0; -} - static int __prepare_gdbserver(bundle *kb, const char *appid) { - int r; const char *path; - r = __check_pkginfo(appid); - if (r < 0) - return -1; - path = bundle_get_val(kb, DLP_K_GDBSERVER_PATH); if (path == NULL) return -1; - r = dlp_chmod(path, S_IRUSR | S_IWUSR - | S_IXUSR | S_IRGRP | S_IXGRP - | S_IROTH | S_IXOTH, 1); - if (r != 0) - _W("Failed to set 755: %s", path); - gdbserver = true; return 0; @@ -209,44 +150,24 @@ int _prepare_debug_tool(bundle *kb, const char *appid, return 0; } -/* chmod and chsmack to read file without root privilege */ -void _change_file(const char *path) -{ - int r; - - r = dlp_chmod(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, 0); - if (r) - _E("Failed to set 644: %s", path); - - r = _set_smack_access_label(path, "*"); - if (r) - _E("Failed to set smack label %s *", path); -} - void _wait_for_valgrind_output(void) { int wait_count = 1; do { if (valgrind_option & POLL_VALGRIND_LOGFILE) { - if (access(PATH_VALGRIND_LOGFILE, F_OK) == 0) { - _change_file(PATH_VALGRIND_LOGFILE); + if (access(PATH_VALGRIND_LOGFILE, F_OK) == 0) valgrind_option &= ~POLL_VALGRIND_LOGFILE; - } } if (valgrind_option & POLL_VALGRIND_XMLFILE) { - if (access(PATH_VALGRIND_XMLFILE, F_OK) == 0) { - _change_file(PATH_VALGRIND_XMLFILE); + if (access(PATH_VALGRIND_XMLFILE, F_OK) == 0) valgrind_option &= ~POLL_VALGRIND_XMLFILE; - } } if (valgrind_option & POLL_VALGRIND_MASSIFFILE) { - if (access(PATH_VALGRIND_MASSIFFILE, F_OK) == 0) { - _change_file(PATH_VALGRIND_MASSIFFILE); + if (access(PATH_VALGRIND_MASSIFFILE, F_OK) == 0) valgrind_option &= ~POLL_VALGRIND_MASSIFFILE; - } } usleep(50 * 1000); /* 50ms */ diff --git a/src/file_util.c b/src/file_util.c deleted file mode 100644 index c391409..0000000 --- a/src/file_util.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "file_util.h" - -static int recurse(const char *path, mode_t mode, - int (*fn)(const char *, mode_t, int)) -{ - struct stat st; - char dir[PATH_MAX]; - int n; - - if (path == NULL) - return -1; - - if (lstat(path, &st) == -1) - return -1; - - if (strrchr(path, '/') != NULL) { - n = strlen(path) - strlen(strrchr(path, '/')); - if (n >= PATH_MAX) - return -1; - - strncpy(dir, path, n); - dir[n] = '\0'; - fn(dir, mode, 1); - return 0; - } - - return -1; -} - -int dlp_chmod(const char *path, mode_t mode, int recursive) -{ - int fd; - struct stat lstat_info; - struct stat fstat_info; -#ifdef HAVE_WIN32_PROC - fprintf(stderr, "error: dlp_chmod not implemented on Win32 (%s)\n", - path); - return -1; -#else - - if (lstat(path, &lstat_info) == -1) - return -1; - - fd = open(path, O_WRONLY, S_IRWXU); - if (fd == -1) - return -1; - - if (fstat(fd, &fstat_info) == -1) { - close(fd); - return -1; - } - - /* this complex check is required because of 'chmod' security issue. */ - /* otherwise hacker can change other file's permission by using race condition and symbolic link. */ - if (lstat_info.st_mode == fstat_info.st_mode - && lstat_info.st_ino == fstat_info.st_ino - && lstat_info.st_dev == fstat_info.st_dev) { - if (fchmod(fd, mode) == -1) { - close(fd); - return -1; - } - } - - close(fd); - - if (recursive) - return recurse(path, mode, dlp_chmod); - - return 0; -#endif -} - diff --git a/src/security_util.c b/src/security_util.c deleted file mode 100644 index 0bc891c..0000000 --- a/src/security_util.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include - -#include "common.h" -#include "security_util.h" - -int _set_smack_access_label(const char *path, const char *label) -{ - return smack_setlabel(path, label, SMACK_LABEL_ACCESS); -} - -int _apply_smack_rules(const char *subject, const char *object, - const char *access_type) -{ - int r; - struct smack_accesses *rules = NULL; - - _D("%s %s %s", subject, object, access_type); - - r = smack_accesses_new(&rules); - if (r != 0) { - _E("smack_accesses_new() is failed."); - return -1; - } - - r = smack_accesses_add(rules, subject, object, access_type); - if (r != 0) { - _E("smack_accesses_add() is failed."); - smack_accesses_free(rules); - return -1; - } - - r = smack_accesses_apply(rules); - if (r != 0) { - _E("smack_accesses_apply() is failed."); - smack_accesses_free(rules); - return -1; - } - - smack_accesses_free(rules); - - return 0; -} - -int _set_access(const char *appid) -{ - return security_manager_prepare_app(appid); -} - diff --git a/src/signal_util.c b/src/signal_util.c index f0e8dee..3fd5158 100644 --- a/src/signal_util.c +++ b/src/signal_util.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -27,7 +26,6 @@ #include "defs.h" #include "common.h" -#include "file_util.h" #include "debug_util.h" #include "signal_util.h" @@ -130,8 +128,6 @@ int _send_app_launch_signal(int launch_pid, const char *app_id) static int __sigchild_action(pid_t dead_pid) { - char buf[MAX_LOCAL_BUFSZ]; - if (dead_pid <= 0) return -1; @@ -139,10 +135,6 @@ static int __sigchild_action(pid_t dead_pid) if (dead_pid == _get_gdbserver_pid()) dead_pid = _get_gdbserver_app_pid(); - /* valgrind xml file */ - if (access(PATH_VALGRIND_XMLFILE, F_OK) == 0) - _change_file(PATH_VALGRIND_XMLFILE); - _send_app_dead_signal(dead_pid); _delete_sock_path(dead_pid, getuid()); -- 2.7.4 From fd431cd3c34187606206f6baa612f0aaf5d279a4 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 7 Jul 2016 10:56:06 +0900 Subject: [PATCH 05/16] Modify closing all open fds Change-Id: I5bfc97b07e6d444860da66cadadf38f8729530e7 Signed-off-by: Hwankyu Jhun --- include/common.h | 1 + src/common.c | 36 ++++++++++++++++++++++++++++++++++++ src/debug-launchpad.c | 11 ++--------- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/common.h b/include/common.h index 9210790..6488292 100644 --- a/include/common.h +++ b/include/common.h @@ -70,6 +70,7 @@ char **_create_argc_argv(bundle *kb, int *margc, const char *app_path); int _proc_check_cmdline_bypid(int pid); void _prepare_listen_sock(void); int _delete_sock_path(int pid, uid_t uid); +int _close_all_fds(void); #endif /* __COMMON_H__ */ diff --git a/src/common.c b/src/common.c index 0f14356..0df007d 100644 --- a/src/common.c +++ b/src/common.c @@ -870,3 +870,39 @@ int _delete_sock_path(int pid, uid_t uid) return 0; } +int _close_all_fds(void) +{ + DIR *dp; + struct dirent dentry; + struct dirent *result = NULL; + int fd; + int max_fd; + + dp = opendir("/proc/self/fd"); + if (dp == NULL) { + /* fallback */ + max_fd = sysconf(_SC_OPEN_MAX); + for (fd = 3; fd < max_fd; fd++) + close(fd); + + return 0; + } + + while (readdir_r(dp, &dentry, &result) == 0 && result) { + if (!isdigit(dentry.d_name[0])) + continue; + + fd = atoi(dentry.d_name); + if (fd < 3) + continue; + + if (fd == dirfd(dp)) + continue; + + close(fd); + } + closedir(dp); + + return 0; +} + diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index 7e706f2..9c58d1b 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -200,8 +200,6 @@ static int __start_process(const char *appid, const char *app_path, { char sock_path[PATH_MAX]; int pid; - int max_fd; - int iter_fd; if (__prepare_fork(kb, appinfo->debug_appid) < 0) return -1; @@ -214,13 +212,8 @@ static int __start_process(const char *appid, const char *app_path, _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, sizeof(sock_path), "%s/apps/%d/%d", - SOCKET_PATH, getuid(), getpid()); - unlink(sock_path); + _close_all_fds(); + _delete_sock_path(getpid(), getuid()); PERF("prepare exec - fisrt done"); _D("lock up test log(no error): prepare exec - first done"); -- 2.7.4 From 87a3259fbb3a6878e5343aeba99384ffe1760e4a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 7 Jul 2016 21:35:28 +0900 Subject: [PATCH 06/16] Add the appid and the pkgid to the enviornment Change-Id: I2e2f53e2a77ff105c41be719b1ceb30836429771 Signed-off-by: Hwankyu Jhun --- include/common.h | 1 + src/common.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/common.h b/include/common.h index 6488292..73dada5 100644 --- a/include/common.h +++ b/include/common.h @@ -56,6 +56,7 @@ typedef struct { char *hwacc; char *taskmanage; char *comp_type; + char *pkgid; } appinfo_t; struct ucred; diff --git a/src/common.c b/src/common.c index 0df007d..c98ad02 100644 --- a/src/common.c +++ b/src/common.c @@ -309,6 +309,9 @@ appinfo_t *_appinfo_create(bundle *kb) ptr = bundle_get_val(kb, AUL_K_COMP_TYPE); if (ptr) appinfo->comp_type = strdup(ptr); + ptr = bundle_get_val(kb, AUL_K_PKGID); + if (ptr) + appinfo->pkgid = strdup(ptr); ptr = bundle_get_val(kb, AUL_K_EXEC); if (ptr) appinfo->app_path = strdup(ptr); @@ -344,6 +347,8 @@ void _appinfo_free(appinfo_t *appinfo) free(appinfo->debug_appid); if (appinfo->comp_type) free(appinfo->comp_type); + if (appinfo->pkgid) + free(appinfo->pkgid); free(appinfo); } @@ -545,6 +550,10 @@ void _set_env(appinfo_t *appinfo, bundle *kb) setenv("HWACC", appinfo->hwacc, 1); if (appinfo->taskmanage) setenv("TASKMANAGE", appinfo->taskmanage, 1); + if (appinfo->appid) + setenv("AUL_APPID", appinfo->appid, 1); + if (appinfo->pkgid) + setenv("AUL_PKGID", appinfo->pkgid, 1); str = bundle_get_val(kb, AUL_K_WAYLAND_DISPLAY); if (str) -- 2.7.4 From 6297b39601a770d4ef84a9913cab471d7b8171c4 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 14 Jul 2016 11:18:19 +0900 Subject: [PATCH 07/16] Fix the exception about getting the file name Change-Id: Ib3ff3c69e01d7e8fbbbfc080078fbc122cce5070 Signed-off-by: Hwankyu Jhun --- src/debug-launchpad.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index 9c58d1b..f7b7f46 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -119,8 +119,14 @@ static int __prepare_exec(const char *appid, const char *app_path, return -1; } - file_name = strrchr(app_path, '/') + 1; + file_name = strrchr(app_path, '/'); if (file_name == NULL) { + _D("file_name is NULL"); + return -1; + } + + file_name++; + if (*file_name == '\0') { _D("can't locate file name to execute"); return -1; } -- 2.7.4 From c02676bec6dfe4584f73f941d210a25b5707e12c Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 15 Jul 2016 17:46:11 +0900 Subject: [PATCH 08/16] Change exec label to System::Privileged Change-Id: I9a79ff4334ce4b4e7516a0b8449e2d125816c498 Signed-off-by: Junghoon Park --- debug-launchpad.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug-launchpad.manifest b/debug-launchpad.manifest index 5874aa8..0a54005 100644 --- a/debug-launchpad.manifest +++ b/debug-launchpad.manifest @@ -3,6 +3,6 @@ - + -- 2.7.4 From 2a526f1ad55774df1f056a4681932471022982e2 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 22 Jul 2016 14:32:10 +0900 Subject: [PATCH 09/16] Fix socket activation feature This feature is enabled for all profiles. Change-Id: Ib1db1f645da1f1c10f6cec5ed633db827c136315 Signed-off-by: Hwankyu Jhun --- packaging/debug-launchpad.spec | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packaging/debug-launchpad.spec b/packaging/debug-launchpad.spec index 2d3b388..b3eab40 100755 --- a/packaging/debug-launchpad.spec +++ b/packaging/debug-launchpad.spec @@ -22,20 +22,9 @@ BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(security-manager) - -%if "%{?profile}" == "wearable" -BuildRequires: pkgconfig(libsystemd-daemon) -%define appfw_feature_socket_activation 1 -%else -%if "%{?profile}" == "mobile" BuildRequires: pkgconfig(libsystemd-daemon) + %define appfw_feature_socket_activation 1 -%else -%if "%{?profile}" == "tv" -%define appfw_feature_socket_activation 0 -%endif -%endif -%endif %description Debug launchpad -- 2.7.4 From 1f8dd274ae4deee2835c6ba1356d3a0086fc0879 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 27 Jul 2016 15:25:09 +0900 Subject: [PATCH 10/16] Redirect stdout and stderr for debugging Change-Id: Ib9fc85cd9e6b4359e8e228c0bc2446705bb62d74 Signed-off-by: Hwankyu Jhun --- packaging/debug-launchpad.spec | 2 +- src/debug-launchpad.c | 54 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/packaging/debug-launchpad.spec b/packaging/debug-launchpad.spec index b3eab40..491df68 100755 --- a/packaging/debug-launchpad.spec +++ b/packaging/debug-launchpad.spec @@ -62,7 +62,7 @@ rm -rf %{buildroot} %files %license LICENSE %manifest debug-launchpad.manifest -%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/debug_launchpad_preloading_preinitializing_daemon +%caps(cap_mac_admin,cap_setgid,cap_dac_override=ei) %{_bindir}/debug_launchpad_preloading_preinitializing_daemon %if 0%{?appfw_feature_socket_activation} %{_unitdir_user}/debug-launchpad.service %{_unitdir_user}/debug-launchpad.socket diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index f7b7f46..30d5385 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -166,6 +166,56 @@ static int __prepare_fork(bundle *kb, const char *appid) return 0; } +static int __stdout_stderr_redirection(int caller_pid) +{ + char path[PATH_MAX]; + int fd; + int ret = 0; + + /* stdout */ + snprintf(path, sizeof(path), "/proc/%d/fd/1", caller_pid); + fd = open(path, O_WRONLY); + if (fd < 0) { + _E("Failed to open %s [%s]", path, strerror(errno)); + ret++; + } else { + dup2(fd, 1); + close(fd); + } + + /* stderr */ + snprintf(path, sizeof(path), "/proc/%d/fd/2", caller_pid); + fd = open(path, O_WRONLY); + if (fd < 0) { + _E("Failed to open %s [%s]", path, strerror(errno)); + ret += 2; + } else { + dup2(fd, 2); + close(fd); + } + + return ret; +} + +static int __get_caller_pid(bundle *kb) +{ + const char *pid_str; + int pid; + + pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID); + if (pid_str == NULL) + pid_str = bundle_get_val(kb, AUL_K_CALLER_PID); + + if (pid_str == NULL) + return -1; + + pid = atoi(pid_str); + if (pid <= 1) + return -1; + + return pid; +} + static int __normal_fork_exec(int argc, char **argv) { _D("start real fork and exec\n"); @@ -204,7 +254,6 @@ static void __real_launch(const char *app_path, bundle *kb) static int __start_process(const char *appid, const char *app_path, bundle *kb, appinfo_t *appinfo) { - char sock_path[PATH_MAX]; int pid; if (__prepare_fork(kb, appinfo->debug_appid) < 0) @@ -221,6 +270,9 @@ static int __start_process(const char *appid, const char *app_path, _close_all_fds(); _delete_sock_path(getpid(), getuid()); + if (__stdout_stderr_redirection(__get_caller_pid(kb))) + _E("__stdout_stderr_redirection() failed"); + PERF("prepare exec - fisrt done"); _D("lock up test log(no error): prepare exec - first done"); -- 2.7.4 From eb77501ac10aec61f1a9898cc51fd104aa92bf73 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 29 Jul 2016 12:46:55 +0900 Subject: [PATCH 11/16] Wait socket creation for stdout & stderr redirection Change-Id: I18ec250046dca0a64446ca5828649f699277d1c0 Signed-off-by: Hwankyu Jhun --- src/debug-launchpad.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index 30d5385..f1a872c 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -63,6 +63,8 @@ static int __real_send(int clifd, int ret) static void __send_result_to_caller(int clifd, int ret) { int res; + int count = 0; + char path[PATH_MAX]; _W("Check app launching"); @@ -75,6 +77,20 @@ static void __send_result_to_caller(int clifd, int ret) return; } + snprintf(path, sizeof(path), "/run/aul/apps/%d/%d/.app-sock", + getuid(), ret); + _D("socket path: %s", path); + do { + if (access(path, F_OK) == 0) { + _D("%s exists", path); + break; + } + + _D("-- now wait socket creation --"); + usleep(50 * 1000); + count++; + } while (count < 20); + res = _proc_check_cmdline_bypid(ret); if (res < 0) { _E("The app process might be terminated " @@ -264,15 +280,15 @@ static int __start_process(const char *appid, const char *app_path, PERF("fork done"); _D("lock up test log(no error): fork done"); + if (__stdout_stderr_redirection(__get_caller_pid(kb))) + _E("__stdout_stderr_redirection() failed"); + _signal_unblock_sigchld(); _signal_fini(); _close_all_fds(); _delete_sock_path(getpid(), getuid()); - if (__stdout_stderr_redirection(__get_caller_pid(kb))) - _E("__stdout_stderr_redirection() failed"); - PERF("prepare exec - fisrt done"); _D("lock up test log(no error): prepare exec - first done"); -- 2.7.4 From 56c25b836dc2b121c4c2c944484a7d0625593e85 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 29 Jul 2016 13:47:29 +0900 Subject: [PATCH 12/16] Add an exception handling Change-Id: I698ca846bfbf92bff906250020dba83de95b4763 Signed-off-by: Hwankyu Jhun --- src/common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common.c b/src/common.c index c98ad02..343e62d 100644 --- a/src/common.c +++ b/src/common.c @@ -498,6 +498,9 @@ static char *__get_libdir(const char *path) return NULL; ptr = strrchr(path_dup, '/'); + if (ptr == NULL) + return NULL; + *ptr = '\0'; snprintf(buf, sizeof(buf), "%s/../lib/", path_dup); -- 2.7.4 From 28fd55525dfaf497222cc3456feb35c10a8cdaca Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 8 Aug 2016 14:46:09 +0900 Subject: [PATCH 13/16] Remove checking socket creation Change-Id: I9c84584498a4feae91249f13152f2a06314ebe5d Signed-off-by: Hwankyu Jhun --- include/common.h | 2 -- src/common.c | 52 --------------------------------------------------- src/debug-launchpad.c | 30 +---------------------------- 3 files changed, 1 insertion(+), 83 deletions(-) diff --git a/include/common.h b/include/common.h index 73dada5..d72241c 100644 --- a/include/common.h +++ b/include/common.h @@ -68,8 +68,6 @@ void _appinfo_free(appinfo_t *appinfo); void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *appinfo, int cmd); 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); int _delete_sock_path(int pid, uid_t uid); int _close_all_fds(void); diff --git a/src/common.c b/src/common.c index 343e62d..8912352 100644 --- a/src/common.c +++ b/src/common.c @@ -780,58 +780,6 @@ char **_create_argc_argv(bundle *kb, int *margc, const char *app_path) return argv; } -static int __read_proc(const char *path, char *buf, int size) -{ - int fd; - int ret; - - if (buf == NULL || path == NULL) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - return -1; - - ret = read(fd, buf, size - 1); - if (ret <= 0) { - close(fd); - return -1; - } - - buf[ret] = 0; - close(fd); - - return ret; -} - -int _proc_check_cmdline_bypid(int pid) -{ - char buf[MAX_CMD_BUFSZ]; - int ret; - - snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid); - ret = __read_proc(buf, buf, sizeof(buf)); - if (ret <= 0) - return -1; - - _D("cmdline: %s", buf); - - 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); -} - static int __delete_dir(const char *path) { DIR *dp; diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index f1a872c..c67df3c 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -62,11 +62,7 @@ static int __real_send(int clifd, int ret) static void __send_result_to_caller(int clifd, int ret) { - int res; - int count = 0; - char path[PATH_MAX]; - - _W("Check app launching"); + _W("send result: %d", ret); if (clifd == -1) return; @@ -77,28 +73,6 @@ static void __send_result_to_caller(int clifd, int ret) return; } - snprintf(path, sizeof(path), "/run/aul/apps/%d/%d/.app-sock", - getuid(), ret); - _D("socket path: %s", path); - do { - if (access(path, F_OK) == 0) { - _D("%s exists", path); - break; - } - - _D("-- now wait socket creation --"); - usleep(50 * 1000); - count++; - } while (count < 20); - - res = _proc_check_cmdline_bypid(ret); - if (res < 0) { - _E("The app process might be terminated " - "while we are wating %d", ret); - __real_send(clifd, -1); /* abnormally launched */ - return; - } - if (__real_send(clifd, ret) < 0) { if (kill(ret, SIGKILL) == -1) _E("Failed to send SIGKILL: %d", errno); @@ -147,8 +121,6 @@ static int __prepare_exec(const char *appid, const char *app_path, 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); -- 2.7.4 From b37083a65ce189aaa3df0213bac0f7322408c245 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 18 Aug 2016 13:10:02 +0900 Subject: [PATCH 14/16] Remove unnecessary code The finalization of the gdbus connection is not required. Change-Id: I0a9d9164725b74f9bcfc69529fb93f8306ffeaf5 Signed-off-by: Hwankyu Jhun --- src/signal_util.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/signal_util.c b/src/signal_util.c index 3fd5158..8e8acb3 100644 --- a/src/signal_util.c +++ b/src/signal_util.c @@ -226,12 +226,9 @@ int _signal_unblock_sigchld(void) int _signal_fini(void) { +#ifndef PRELOAD_ACTIVATE int i; - if (bus) - g_object_unref(bus); - -#ifndef PRELOAD_ACTIVATE for (i = 0; i < _NSIG; i++) signal(i, SIG_DFL); #endif -- 2.7.4 From ce716acc1f4dc9502c479d040a0f86d36739592c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 29 Aug 2016 20:43:30 +0900 Subject: [PATCH 15/16] Adjust coding style Change-Id: Id2d1689c337fbba094553153e4440bef0f7b2b52 Signed-off-by: Hwankyu Jhun --- include/common.h | 2 -- src/common.c | 3 ++- src/debug-launchpad.c | 4 ++-- src/debug_util.c | 1 + src/signal_util.c | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/common.h b/include/common.h index d72241c..f31a4c4 100644 --- a/include/common.h +++ b/include/common.h @@ -59,8 +59,6 @@ typedef struct { char *pkgid; } appinfo_t; -struct ucred; - int _create_server_sock(void); app_pkt_t *_recv_pkt_raw(int fd, int *clifd, struct ucred *cr); appinfo_t *_appinfo_create(bundle *kb); diff --git a/src/common.c b/src/common.c index 8912352..c6b121a 100644 --- a/src/common.c +++ b/src/common.c @@ -719,7 +719,8 @@ char **_create_argc_argv(bundle *kb, int *margc, const char *app_path) if (argv[0]) free(argv[0]); snprintf(buf, sizeof(buf), "%s.exe", app_path); - /* this code is added because core app don't have '.exe' excutable */ + /* this code is added */ + /* because core app don't have '.exe' excutable */ /* if '.exe' not exist then use app_path */ if (access(buf, F_OK) != 0) argv[0] = strdup(app_path); diff --git a/src/debug-launchpad.c b/src/debug-launchpad.c index c67df3c..f8f3c30 100644 --- a/src/debug-launchpad.c +++ b/src/debug-launchpad.c @@ -95,7 +95,7 @@ static int __prepare_exec(const char *appid, const char *app_path, appid, appinfo->pkg_type, app_path); ret = security_manager_prepare_app(appid); if (ret != SECURITY_MANAGER_SUCCESS) { - _E("Failed to set privileges " + _E("Failed to set privileges " \ "- check your package's credential: %d", ret); return -1; } @@ -265,7 +265,7 @@ static int __start_process(const char *appid, const char *app_path, _D("lock up test log(no error): prepare exec - first done"); if (__prepare_exec(appid, app_path, appinfo, kb) < 0) { - _E("preparing work fail to launch " + _E("preparing work fail to launch " \ "- can not launch %s", appid); exit(-1); } diff --git a/src/debug_util.c b/src/debug_util.c index 224de11..e38c627 100644 --- a/src/debug_util.c +++ b/src/debug_util.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#define _GNU_SOURCE #include #include #include diff --git a/src/signal_util.c b/src/signal_util.c index 8e8acb3..4e69fac 100644 --- a/src/signal_util.c +++ b/src/signal_util.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#define _GNU_SOURCE #include #include #include -- 2.7.4 From ad858a57eb4a779dec58c85ec2db3ca56aa0890d Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 9 Sep 2016 16:13:57 +0900 Subject: [PATCH 16/16] Remove unnecessary macro Change-Id: Ic67d98795b3c3329de7fd1697f216f9a670853df Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 6 +----- packaging/debug-launchpad.spec | 7 ------- src/common.c | 6 ------ 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f68928..6d53dce 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") # Set required packages INCLUDE(FindPkgConfig) -SET(pkgs_requires "dlog glib-2.0 gio-2.0 bundle vconf security-manager") -IF(_APPFW_FEATURE_SOCKET_ACTIVATION) - SET(pkgs_requires "${pkgs_requires} libsystemd-daemon") - ADD_DEFINITIONS("-D_APPFW_FEATURE_SOCKET_ACTIVATION") -ENDIF(_APPFW_FEATURE_SOCKET_ACTIVATION) +SET(pkgs_requires "dlog glib-2.0 gio-2.0 bundle vconf security-manager libsystemd-daemon") pkg_check_modules(pkgs REQUIRED ${pkgs_requires}) diff --git a/packaging/debug-launchpad.spec b/packaging/debug-launchpad.spec index 491df68..6300e02 100755 --- a/packaging/debug-launchpad.spec +++ b/packaging/debug-launchpad.spec @@ -24,8 +24,6 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(security-manager) BuildRequires: pkgconfig(libsystemd-daemon) -%define appfw_feature_socket_activation 1 - %description Debug launchpad @@ -38,7 +36,6 @@ _APPFW_FEATURE_SOCKET_ACTIVATION=ON %endif cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -D_APPFW_FEATURE_SOCKET_ACTIVATION:BOOL=${_APPFW_FEATURE_SOCKET_ACTIVATION} \ . make %{?jobs:-j%jobs} @@ -47,12 +44,10 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install -%if 0%{?appfw_feature_socket_activation} mkdir -p %{buildroot}%{_unitdir_user}/sockets.target.wants install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir_user}/debug-launchpad.service install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir_user}/debug-launchpad.socket ln -s ../debug-launchpad.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/debug-launchpad.socket -%endif %clean rm -rf %{buildroot} @@ -63,8 +58,6 @@ rm -rf %{buildroot} %license LICENSE %manifest debug-launchpad.manifest %caps(cap_mac_admin,cap_setgid,cap_dac_override=ei) %{_bindir}/debug_launchpad_preloading_preinitializing_daemon -%if 0%{?appfw_feature_socket_activation} %{_unitdir_user}/debug-launchpad.service %{_unitdir_user}/debug-launchpad.socket %{_unitdir_user}/sockets.target.wants/debug-launchpad.socket -%endif diff --git a/src/common.c b/src/common.c index c6b121a..b64ea5f 100644 --- a/src/common.c +++ b/src/common.c @@ -31,9 +31,7 @@ #include #include #include -#ifdef _APPFW_FEATURE_SOCKET_ACTIVATION #include -#endif /* _APPFW_FEATURE_SOCKET_ACTIVATION */ #include "common.h" #include "debug_util.h" @@ -57,7 +55,6 @@ static void __set_sock_option(int fd, int cli) setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); } -#ifdef _APPFW_FEATURE_SOCKET_ACTIVATION static int __create_sock_activation(void) { int listen_fds; @@ -72,7 +69,6 @@ static int __create_sock_activation(void) return -1; } -#endif /* _APPFW_FEATURE_SOCKET_ACTIVATION */ static int __create_server_socket(bool is_app) { @@ -159,9 +155,7 @@ int _create_server_sock(void) { int fd = -1; -#ifdef _APPFW_FEATURE_SOCKET_ACTIVATION fd = __create_sock_activation(); -#endif /* _APPFW_FEATURE_SOCKET_ACTIAVTION */ if (fd < 0) { fd = __create_server_socket(false); if (fd < 0) { -- 2.7.4