Skip to content

Commit 3b9cc81

Browse files
committed
Enable --incompatible_sandbox_hermetic_tmp by default
Fixes #3236 Fixes #19915
1 parent 877f845 commit 3b9cc81

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ public ImmutableSet<Path> getInaccessiblePaths(FileSystem fs) {
350350

351351
@Option(
352352
name = "incompatible_sandbox_hermetic_tmp",
353-
defaultValue = "false",
353+
defaultValue = "true",
354354
documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
355355
effectTags = {OptionEffectTag.EXECUTION},
356356
help =
357357
"If set to true, each Linux sandbox will have its own dedicated empty directory mounted"
358-
+ " as /tmp rather thansharing /tmp with the host filesystem. Use"
358+
+ " as /tmp rather than sharing /tmp with the host filesystem. Use"
359359
+ " --sandbox_add_mount_pair=/tmp to keep seeing the host's /tmp in all sandboxes.")
360360
public boolean sandboxHermeticTmp;
361361

src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ public void testEditDuringBuild() throws Exception {
4444
Path in = write("edit/in", "line1");
4545
in.setLastModifiedTime(123456789);
4646

47-
// Make in writable from sandbox (in case sandbox strategy is used).
48-
String absoluteInPath = in.getPathString();
49-
addOptions("--sandbox_writable_path=" + absoluteInPath);
47+
// Modify the actual source file, not a sandboxed copy.
48+
addOptions("--spawn_strategy=local");
5049

5150
// The "echo" effects editing of the source file during the build:
5251
write("edit/BUILD",

src/test/shell/bazel/bazel_sandboxing_networking_test.sh

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ source ${CURRENT_DIR}/remote_helpers.sh \
3636
function set_up() {
3737
add_to_bazelrc "build --spawn_strategy=sandboxed"
3838
add_to_bazelrc "build --genrule_strategy=sandboxed"
39+
# Allow the network socket to be seen in the sandbox.
40+
add_to_bazelrc "build --sandbox_add_mount_pair=/tmp"
3941

4042
sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc
4143
}

src/test/shell/integration/sandboxing_test.sh

+2
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ EOF
735735

736736
touch "${temp_dir}/file"
737737
bazel test //pkg:tmp_test \
738+
--sandbox_add_mount_pair=/tmp \
738739
--test_output=errors &>$TEST_log || fail "Expected test to pass"
739740
}
740741

@@ -812,6 +813,7 @@ EOF
812813
chmod +x pkg/tmp_test.sh
813814

814815
bazel test //pkg:tmp_test \
816+
--sandbox_add_mount_pair=/tmp \
815817
--test_output=errors &>$TEST_log || fail "Expected test to pass"
816818
[[ -f "${temp_dir}/file" ]] || fail "Expected ${temp_dir}/file to exist"
817819
}

0 commit comments

Comments
 (0)