Commit 48d32d67 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Allow namespace overrides in base::LaunchProcess

Previously base::LaunchProcess didn't allow paths_to_transfer to be used
with the FDIO_SPAWN_CLONE_NAMESPACE flag. This meant that to override
directories the test launcher had to avoid FDIO_SPAWN_CLONE_NAMESPACE
flag. This is not ideal because of the added complexity in the test
launcher and also because the launcher was changing test environment
by not cloning all entries in the namespace (i.e. some tests would behave
differently when started with --single-process-tests flag). This change
updates LaunchProcess() to allow individual dirs transfer while cloning
the rest of the namespace. Also updated test launcher to use this new
feature.

This CL should unbreak the tests currently broken in
https://crrev.com/c/1341243

Change-Id: I3c30497222ffd33d6240f478523d3e767fad90f5
Reviewed-on: https://chromium-review.googlesource.com/c/1345236Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610042}
parent c22a04e7
...@@ -216,8 +216,8 @@ struct BASE_EXPORT LaunchOptions { ...@@ -216,8 +216,8 @@ struct BASE_EXPORT LaunchOptions {
std::vector<FilePath> paths_to_clone; std::vector<FilePath> paths_to_clone;
// Specifies handles which will be installed as files or directories in the // Specifies handles which will be installed as files or directories in the
// child process' namespace. Paths installed by |paths_to_clone| will be // child process' namespace. Paths installed by |paths_to_clone| or
// overridden by these entries. // FDIO_SPAWN_CLONE_NAMESPACE flag will be overridden by these entries.
std::vector<PathToTransfer> paths_to_transfer; std::vector<PathToTransfer> paths_to_transfer;
#endif // defined(OS_FUCHSIA) #endif // defined(OS_FUCHSIA)
......
...@@ -159,7 +159,10 @@ Process LaunchProcess(const std::vector<std::string>& argv, ...@@ -159,7 +159,10 @@ Process LaunchProcess(const std::vector<std::string>& argv,
// Add actions to clone handles for any specified paths into the new process' // Add actions to clone handles for any specified paths into the new process'
// namespace. // namespace.
if (!options.paths_to_clone.empty() || !options.paths_to_transfer.empty()) { if (!options.paths_to_clone.empty() || !options.paths_to_transfer.empty()) {
DCHECK((options.spawn_flags & FDIO_SPAWN_CLONE_NAMESPACE) == 0); // |paths_to_clone| doesn't make sense with FDIO_SPAWN_CLONE_NAMESPACE.
DCHECK((options.spawn_flags & FDIO_SPAWN_CLONE_NAMESPACE) == 0 ||
options.paths_to_clone.empty());
transferred_handles.reserve(transferred_handles.size() + transferred_handles.reserve(transferred_handles.size() +
options.paths_to_clone.size() + options.paths_to_clone.size() +
options.paths_to_transfer.size()); options.paths_to_transfer.size());
......
...@@ -325,15 +325,9 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line, ...@@ -325,15 +325,9 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
#elif defined(OS_FUCHSIA) #elif defined(OS_FUCHSIA)
DCHECK(!new_options.job_handle); DCHECK(!new_options.job_handle);
// Set the clone policy, deliberately omitting FDIO_SPAWN_CLONE_NAMESPACE so // Set the clone policy.
// that we can install a different /data. new_options.spawn_flags = FDIO_SPAWN_CLONE_STDIO | FDIO_SPAWN_CLONE_JOB |
new_options.spawn_flags = FDIO_SPAWN_CLONE_STDIO | FDIO_SPAWN_CLONE_JOB; FDIO_SPAWN_CLONE_NAMESPACE;
new_options.paths_to_clone.push_back(base::FilePath("/config/ssl"));
new_options.paths_to_clone.push_back(base::FilePath("/dev/null"));
new_options.paths_to_clone.push_back(base::FilePath("/dev/zero"));
new_options.paths_to_clone.push_back(base::FilePath("/pkg"));
new_options.paths_to_clone.push_back(base::FilePath("/svc"));
new_options.paths_to_clone.push_back(base::FilePath("/tmp"));
zx::job job_handle; zx::job job_handle;
zx_status_t result = zx::job::create(*GetDefaultJob(), 0, &job_handle); zx_status_t result = zx::job::create(*GetDefaultJob(), 0, &job_handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment