diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java index 13b1ca532dc369..9fe5d13c8deb3e 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java @@ -602,9 +602,10 @@ public static void moveTreesBelow(Path from , Path to) throws IOException { throw new IllegalArgumentException(to + " is a subdirectory of " + from); } - // Actions can make output directories non-writable, which would cause the move to fail. - from.setWritable(true); + // Actions can make output directories inaccessible, which would cause the move to fail. + from.chmod(0755); + // TODO(tjgq): Don't leave an empty directory behind. Collection entries = from.getDirectoryEntries(); for (Path entry : entries) { if (entry.isDirectory(Symlinks.NOFOLLOW)) { diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index f453de8660526c..c1ee1179b5f67c 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -258,8 +258,9 @@ EOF bazel build --test_output=streamed :a &>$TEST_log || fail "expected build to succeed" } -# Regression test for https://github.com/bazelbuild/bazel/issues/20032. -function test_read_only_tree_artifact() { +# Regression test for https://github.com/bazelbuild/bazel/issues/20032 and +# https://github.com/bazelbuild/bazel/issues/22260. +function test_permissionless_tree_artifact() { create_workspace_with_default_repos WORKSPACE cat > def.bzl <<'EOF' @@ -267,7 +268,7 @@ def _r(ctx): d = ctx.actions.declare_directory(ctx.label.name) ctx.actions.run_shell( outputs = [d], - command = "touch $1/file.txt && chmod -w $1", + command = "touch $1/file.txt && chmod 000 $1", arguments = [d.path], ) return DefaultInfo(files = depset([d]))