diff --git a/interfaces/innerkits/dump_catcher/lite_perf.cpp b/interfaces/innerkits/dump_catcher/lite_perf.cpp index 28030d788d2b7bffb9b393857d97eb7129a95bcc..3ff21a945c6d74f3b6477a075b0d0fcb92f261b4 100644 --- a/interfaces/innerkits/dump_catcher/lite_perf.cpp +++ b/interfaces/innerkits/dump_catcher/lite_perf.cpp @@ -358,6 +358,11 @@ bool LitePerf::Impl::ExecDumpPipe(const int (&pipefd)[2], const LitePerfParam& l } close(pipefd[PIPE_WRITE]); + if (DFX_InheritCapabilities() != 0) { + DFXLOGE("Failed to inherit Capabilities from parent."); + return false; + } + DFXLOGI("execl processdump -liteperf."); execl(PROCESSDUMP_PATH, "processdump", "-liteperf", nullptr); DFXLOGE("Failed to execl processdump -liteperf, errno(%{public}d)", errno); diff --git a/interfaces/innerkits/signal_handler/dfx_dumprequest.c b/interfaces/innerkits/signal_handler/dfx_dumprequest.c index a95c74b91a59070b4897838ff7a67eec97141c2c..be28a8955b2f5776b49738e025877d27e1967a4e 100644 --- a/interfaces/innerkits/signal_handler/dfx_dumprequest.c +++ b/interfaces/innerkits/signal_handler/dfx_dumprequest.c @@ -150,7 +150,7 @@ static void FillCrashExceptionAndReport(const int err) ReportException(&exception); } -static int32_t InheritCapabilities(void) +int32_t DFX_InheritCapabilities(void) { struct __user_cap_header_struct capHeader; (void)memset_s(&capHeader, sizeof(capHeader), 0, sizeof(capHeader)); @@ -272,7 +272,7 @@ static int DFX_ExecDump(void) } syscall(SYS_close, pipefd[1]); - if (InheritCapabilities() != 0) { + if (DFX_InheritCapabilities() != 0) { DFXLOGE("Failed to inherit Capabilities from parent."); FillCrashExceptionAndReport(CRASH_SIGNAL_EINHERITCAP); return INHERIT_CAP_FAIL; diff --git a/interfaces/innerkits/signal_handler/dfx_signal_handler.c b/interfaces/innerkits/signal_handler/dfx_signal_handler.c index bde299d24222098d54593de8c2e7698543f4e7b0..85806a8e75824ccc4da8e4315c839660e33b5700 100644 --- a/interfaces/innerkits/signal_handler/dfx_signal_handler.c +++ b/interfaces/innerkits/signal_handler/dfx_signal_handler.c @@ -74,13 +74,6 @@ #define NSIG 64 #endif -#ifndef F_SETPIPE_SZ -#define F_SETPIPE_SZ 1031 -#endif - -#define NUMBER_SIXTYFOUR 64 -#define INHERITABLE_OFFSET 32 - void __attribute__((constructor)) InitHandler(void) { DFX_InstallSignalHandler(); @@ -95,13 +88,6 @@ static BOOL g_hasInit = FALSE; static int g_prevHandledSignal = SIGDUMP; static struct sigaction g_oldSigactionList[NSIG] = {}; static char g_appRunningId[MAX_APP_RUNNING_UNIQUE_ID_LEN]; -enum DumpPreparationStage { - CREATE_PIPE_FAIL = 1, - SET_PIPE_LEN_FAIL, - WRITE_PIPE_FAIL, - INHERIT_CAP_FAIL, - EXEC_FAIL, -}; const char* GetLastFatalMessage(void) __attribute__((weak)); fatal_msg_t *get_fatal_message(void) __attribute__((weak)); diff --git a/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h b/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h index 0e19989f0948333f65a4ae9ba98c21a37046333c..d3d92dee67c5ab436e2046500ac02439ebb66374 100644 --- a/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h +++ b/interfaces/innerkits/signal_handler/include/dfx_dumprequest.h @@ -23,6 +23,8 @@ extern "C" { void DfxDumpRequest(int signo, struct ProcessDumpRequest *request); +int32_t DFX_InheritCapabilities(void); + bool DFX_SetDumpableState(void); void DFX_RestoreDumpableState(void); diff --git a/interfaces/innerkits/signal_handler/libdfx_signalhandler.map b/interfaces/innerkits/signal_handler/libdfx_signalhandler.map index 9d8a0e24b20a0de321986d07c3f4ed59a5e09d8b..ac990f1df2a271f94af5877e66131c4254600480 100644 --- a/interfaces/innerkits/signal_handler/libdfx_signalhandler.map +++ b/interfaces/innerkits/signal_handler/libdfx_signalhandler.map @@ -10,6 +10,7 @@ DFX_SetCrashLogConfig; DFX_SetDumpableState; DFX_RestoreDumpableState; + DFX_InheritCapabilities; }; local: *;