Clearer logs on execveat failures

Drive-by: remove redundant log prefix (PLOG prepends filename and line)
PiperOrigin-RevId: 557367980
Change-Id: Id7cc945969e0ae06a451ca3dd0f3e288402b9136
This commit is contained in:
Wiktor Garbacz 2023-08-15 23:30:02 -07:00 committed by Copybara-Service
parent ae3d334cc2
commit 1c2596785b

View File

@ -657,20 +657,22 @@ void ForkServer::ExecuteProcess(int execve_fd, const char* const* argv,
internal::kExecveMagic); internal::kExecveMagic);
int saved_errno = errno; int saved_errno = errno;
SAPI_RAW_PLOG(ERROR, "sandbox2::ForkServer: execveat failed"); SAPI_RAW_PLOG(ERROR, "execveat failed");
if (argv[0]) {
SAPI_RAW_LOG(ERROR, "argv[0]=%s", argv[0]);
}
if (saved_errno == ENOSYS) { if (saved_errno == ENOSYS) {
SAPI_RAW_LOG(ERROR, SAPI_RAW_LOG(ERROR,
"sandbox2::ForkServer: This is likely caused by running" "This is likely caused by running on a kernel that is too old."
" sandbox2 on too old a kernel."
); );
} else if (saved_errno == ENOENT && execve_fd >= 0) { } else if (saved_errno == ENOENT && execve_fd >= 0) {
// Since we know the file exists, it must be that the file is dynamically // Since we know the file exists, it must be that the file is dynamically
// linked and the ELF interpreter is what's actually missing. // linked and the ELF interpreter is what's actually missing.
SAPI_RAW_LOG(ERROR, SAPI_RAW_LOG(
"sandbox2::ForkServer: This is likely caused by running" ERROR,
" dynamically-linked sandboxee without calling" "This is likely caused by running dynamically-linked sandboxee without "
" .AddLibrariesForBinary() on the policy builder."); "calling .AddLibrariesForBinary() on the policy builder.");
} }
util::Syscall(__NR_exit_group, EXIT_FAILURE); util::Syscall(__NR_exit_group, EXIT_FAILURE);