Use new sandbox2::Comms ctor for default connection params

This change allows Sandbox2 to change how the default FD for comms is chosen.

PiperOrigin-RevId: 479526309
Change-Id: I69add85a244bc0385eaa164ab0ea3b036503c6d3
This commit is contained in:
Christian Blichmann 2022-10-07 02:07:33 -07:00 committed by Copybara-Service
parent 859e282d3b
commit b9c2830ebc
10 changed files with 11 additions and 11 deletions

View File

@ -48,7 +48,7 @@ int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
// Set-up the sandbox2::Client object, using a file descriptor (1023).
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::Client sandbox2_client(&comms);
// Enable sandboxing from here.
sandbox2_client.SandboxMeHere();

View File

@ -44,7 +44,7 @@ int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
// Instantiate Comms channel with the parent Executor
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::ForkingClient s2client(&comms);
for (;;) {

View File

@ -62,7 +62,7 @@ static bool CommunicationTest(int sock) {
int main(int argc, char* argv[]) {
// Set-up the sandbox2::Client object, using a file descriptor (1023).
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::Client sandbox2_client(&comms);
// Enable sandboxing from here.
sandbox2_client.SandboxMeHere();

View File

@ -108,7 +108,7 @@ int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
// Set-up the sandbox2::Client object, using a file descriptor (1023).
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::Client sandbox2_client(&comms);
// Enable sandboxing from here.

View File

@ -346,7 +346,7 @@ void ForkServer::LaunchChild(const ForkRequest& request, int execve_fd,
// Create a Comms object here and not above, as we know we will execve and
// therefore not call the Comms destructor, which would otherwise close the
// comms file descriptor, which we do not want for the general case.
Comms client_comms(Comms::kSandbox2ClientCommsFD);
Comms client_comms(Comms::kDefaultConnection);
Client c(&client_comms);
// The following client calls are basically SandboxMeHere. We split it so

View File

@ -59,7 +59,7 @@ int main() {
SAPI_RAW_PLOG(WARNING, "sigaction(SIGTERM, sa_handler=SIG_IGN)");
}
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::ForkServer fork_server(&comms);
while (true) {

View File

@ -46,7 +46,7 @@ int main(int argc, char* argv[]) {
}
case 2: { // Send and receive FD
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
int fd;
if (!comms.RecvFD(&fd)) {
return EXIT_FAILURE;

View File

@ -30,8 +30,8 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
sandbox2::Comms sb_comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Client client(&sb_comms);
sandbox2::Comms default_comms(sandbox2::Comms::kDefaultConnection);
sandbox2::Client client(&default_comms);
int testno;
SAPI_RAW_CHECK(absl::SimpleAtoi(argv[1], &testno), "testno is not a number");

View File

@ -19,7 +19,7 @@
#include "sandboxed_api/util/raw_logging.h"
int main(int argc, char* argv[]) {
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
// Exchange data with sandbox sandbox (parent) before sandboxing is enabled.
SAPI_RAW_CHECK(comms.SendBool(true), "Sending data to the executor");

View File

@ -51,7 +51,7 @@ int main(int argc, char* argv[]) {
// Wait to make sure that the sleepy-thread is up and running.
pthread_barrier_wait(&g_barrier);
sandbox2::Comms comms(sandbox2::Comms::kSandbox2ClientCommsFD);
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::Client sandbox2_client(&comms);
sandbox2_client.SandboxMeHere();