%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
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");
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)
_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");