diff --git a/sandboxed_api/BUILD.bazel b/sandboxed_api/BUILD.bazel index ca794f0..1b94a16 100644 --- a/sandboxed_api/BUILD.bazel +++ b/sandboxed_api/BUILD.bazel @@ -173,6 +173,7 @@ cc_library( "//sandboxed_api/sandbox2:client", "//sandboxed_api/sandbox2:comms", "//sandboxed_api/sandbox2:forkingclient", + "//sandboxed_api/sandbox2:logsink", "//sandboxed_api/util:flags", "@com_google_absl//absl/strings", "@com_google_glog//:glog", diff --git a/sandboxed_api/CMakeLists.txt b/sandboxed_api/CMakeLists.txt index c2b6d2f..68b026e 100644 --- a/sandboxed_api/CMakeLists.txt +++ b/sandboxed_api/CMakeLists.txt @@ -168,6 +168,7 @@ target_link_libraries(sapi_client PRIVATE sandbox2::client sandbox2::comms sandbox2::forkingclient + sandbox2::logsink sapi::base sapi::call sapi::flags diff --git a/sandboxed_api/client.cc b/sandboxed_api/client.cc index 9d490b6..becdeb7 100644 --- a/sandboxed_api/client.cc +++ b/sandboxed_api/client.cc @@ -32,6 +32,7 @@ #include "sandboxed_api/proto_arg.pb.h" #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/forkingclient.h" +#include "sandboxed_api/sandbox2/logsink.h" #include "sandboxed_api/vars.h" #ifdef MEMORY_SANITIZER @@ -451,6 +452,11 @@ extern "C" ABSL_ATTRIBUTE_WEAK int main(int argc, char** argv) { // Child thread. s2client.SandboxMeHere(); + // Enable log forwarding if enabled by the sandboxer. + if (s2client.HasMappedFD(sandbox2::LogSink::kLogFDName)) { + s2client.SendLogsToSupervisor(); + } + // Run SAPI stub. while (true) { sapi::client::ServeRequest(&comms);