-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sandbox] Run sandbox from common execroot
Make sandboxed process run under main execroot instead of unique sandboxed execroot. This way, we do not need to copy/symlink input files before execution and clean up sandbox base after execution. Summary of how it works: - `windows-sandbox` blocks all file access under current directory (main execroot). - Declared input paths will be marked readable. - Declared output paths will be marked writable. - If sandboxed process tries to open file for read/write when the path is not marked with that permission, the operation will fail (e.g. `fopen` will return `nullptr`). Closes #8849. PiperOrigin-RevId: 257408096
- Loading branch information
1 parent
4bcdb75
commit 6605b23
Showing
5 changed files
with
115 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2019 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.sandbox; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.devtools.build.lib.vfs.Path; | ||
import java.io.IOException; | ||
|
||
/** Implements detour-based sandboxed spawn. */ | ||
public class WindowsSandboxedSpawn implements SandboxedSpawn { | ||
|
||
private final Path execRoot; | ||
private final ImmutableMap<String, String> environment; | ||
private final ImmutableList<String> arguments; | ||
|
||
public WindowsSandboxedSpawn( | ||
Path execRoot, ImmutableMap<String, String> environment, ImmutableList<String> arguments) { | ||
this.execRoot = execRoot; | ||
this.environment = environment; | ||
this.arguments = arguments; | ||
} | ||
|
||
@Override | ||
public Path getSandboxExecRoot() { | ||
return execRoot; | ||
} | ||
|
||
@Override | ||
public ImmutableList<String> getArguments() { | ||
return arguments; | ||
} | ||
|
||
@Override | ||
public ImmutableMap<String, String> getEnvironment() { | ||
return environment; | ||
} | ||
|
||
@Override | ||
public void createFileSystem() throws IOException {} | ||
|
||
@Override | ||
public void copyOutputs(Path execRoot) throws IOException {} | ||
|
||
@Override | ||
public void delete() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters