diff --git a/sandboxed_api/sandbox2/buffer_test.cc b/sandboxed_api/sandbox2/buffer_test.cc index fa9f067..22a8674 100644 --- a/sandboxed_api/sandbox2/buffer_test.cc +++ b/sandboxed_api/sandbox2/buffer_test.cc @@ -141,12 +141,10 @@ TEST(BufferTest, TestWithSandboxeeSendRecv) { const std::string path = GetTestSourcePath("sandbox2/testcases/buffer"); std::vector args = {path, "2"}; auto executor = absl::make_unique(path, args); - auto* comms = executor->ipc()->comms(); - auto policy = BufferTestcasePolicy(); - - Sandbox2 s2(std::move(executor), std::move(policy)); + Sandbox2 s2(std::move(executor), BufferTestcasePolicy()); ASSERT_THAT(s2.RunAsync(), IsTrue()); + Comms* comms = s2.comms(); SAPI_ASSERT_OK_AND_ASSIGN(auto buffer, Buffer::CreateWithSize(1ULL << 20 /* 1MiB */)); diff --git a/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc b/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc index 326434d..c3bbbf6 100644 --- a/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc +++ b/sandboxed_api/sandbox2/examples/crc4/crc4sandbox.cc @@ -116,10 +116,7 @@ int main(int argc, char** argv) { .set_rlimit_cpu(60) // The CPU time limit in seconds. .set_walltime_limit(absl::Seconds(5)); - auto* comms = executor->ipc()->comms(); - auto policy = GetPolicy(); - - sandbox2::Sandbox2 s2(std::move(executor), std::move(policy)); + sandbox2::Sandbox2 s2(std::move(executor), GetPolicy()); // Let the sandboxee run. if (!s2.RunAsync()) { @@ -128,6 +125,8 @@ int main(int argc, char** argv) { return 2; } + sandbox2::Comms* comms = s2.comms(); + uint32_t crc4; if (!SandboxedCRC4(comms, &crc4)) { LOG(ERROR) << "GetCRC4 failed"; diff --git a/sandboxed_api/sandbox2/ipc.h b/sandboxed_api/sandbox2/ipc.h index 69f8421..18c19dc 100644 --- a/sandboxed_api/sandbox2/ipc.h +++ b/sandboxed_api/sandbox2/ipc.h @@ -37,6 +37,7 @@ class IPC final { ~IPC() { InternalCleanupFdMap(); } + ABSL_DEPRECATED("Use Sandbox2::comms() instead") Comms* comms() const { return comms_.get(); } // Marks local_fd so that it should be sent to the remote process (sandboxee), diff --git a/sandboxed_api/sandbox2/stack_trace.cc b/sandboxed_api/sandbox2/stack_trace.cc index d9eb8fc..c1eeb7b 100644 --- a/sandboxed_api/sandbox2/stack_trace.cc +++ b/sandboxed_api/sandbox2/stack_trace.cc @@ -241,11 +241,11 @@ bool StackTracePeer::LaunchLibunwindSandbox(const Regs* regs, if (!policy) { return false; } - auto* comms = executor->ipc()->comms(); Sandbox2 sandbox(std::move(executor), std::move(policy)); VLOG(1) << "Running libunwind sandbox"; sandbox.RunAsync(); + Comms* comms = sandbox.comms(); UnwindSetup msg; msg.set_pid(pid);