Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.3.0] Fix permissions on tree artifact subdirectories as needed to move them out of the sandbox. #22802

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path> entries = from.getDirectoryEntries();
for (Path entry : entries) {
if (entry.isDirectory(Symlinks.NOFOLLOW)) {
Expand Down
7 changes: 4 additions & 3 deletions src/test/shell/bazel/bazel_sandboxing_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,17 @@ 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'
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]))
Expand Down
Loading