Skip to content

[3.25] Backport sandbox directory-dependency fixes - #16833

Merged
Alizter merged 14 commits into
ocaml:3.25.0-rcfrom
Alizter:backport-sandbox-stack-3.25
Oct 28, 2026
Merged

Alizter merged 14 commits into
ocaml:3.25.0-rcfrom
Alizter:backport-sandbox-stack-3.25

Conversation

@Alizter

@Alizter Alizter commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Backport #16632, #16686, #16675, #16813, #16814 and #16806 with their original regression tests.

All 14 upstream source patches are preserved, with original authorship and cherry-pick references. Replaces #16832.

Build/format and regression checks pass at every commit. Full-suite checks hit local jq-helper and bubblewrap permission failures.

punchagan and others added 14 commits October 28, 2026 16:41
This is a cram test to reproduce a bug where building a rule that runs a
binary fails with a symlink error, when the rule also has a `(deps ...)`
entry for the package that provides that binary.

(cherry picked from commit d7a5e9b)

Signed-off-by: Puneeth Chaganti <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
Compare directory-only and overlapping directory/file dependencies in
symlink, copy, and hardlink sandboxes, checking the generated input first.

(cherry picked from commit 828322b)

Signed-off-by: Ali Caglayan <[email protected]>
Check the build exit status independently of output filtering. Normalize only
the known Linux unlink/EISDIR and macOS link/EPERM diagnostics, retaining the
destination path and dependency context so unexpected failures remain visible.

(cherry picked from commit cf99e35)

Signed-off-by: Ali Caglayan <[email protected]>
Exercise directory copies with ordinary file dependencies in symlink,
copy, and hardlink sandbox modes. Record the symlink-mode rejection of
sandbox file links before the action-copy fix.

Also compare original input symlinks and an action-created link with the
sandbox target text at another path across all three modes.

(cherry picked from commit f7a22eb)

Signed-off-by: Ali Caglayan <[email protected]>
Allow Io.copy_file to choose if files are able to overwritten.

(cherry picked from commit 14b36d3)

Signed-off-by: Ali Caglayan <[email protected]>
…l#16685)

Extend the recursive-copy tests from ocaml#16653 with two action-created
directory symlinks: an acyclic link pointing outside the copied tree,
and a directory-link cycle.

Record their current rejection ahead of relaxing symlink handling. The
acyclic case should eventually copy successfully; the cyclic case must
continue to terminate with an error.

Tests only; no implementation changes. Related to ocaml#16675.

(cherry picked from commit c5d4f33)

Signed-off-by: Rudi Grinberg <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
Make recursive copy actions follow symlinks, matching ordinary file
copies and the existing root-path handling. Linked files and directories
are materialized at the destination rather than rejected.

This fixes recursive copies of file dependencies in symlink sandboxes
and supports the traversal change in ocaml#16675. Update the regressions from
ocaml#16653 and ocaml#16685; directory-link cycles still fail with ELOOP.

(cherry picked from commit f1a8aba)

Signed-off-by: Ali Caglayan <[email protected]>
Exercise a directory copy action with a generated directory dependency,
without Melange or package management. Record the current behavior in
symlink, copy, and hardlink sandbox modes before changing input traversal.

(cherry picked from commit 04f4c03)

Signed-off-by: Ali Caglayan <[email protected]>
Extend Puneeth’s reproducer from ocaml#16546 to cover ocaml#16547 under copy
sandboxing too. Record the overlapping-input failure and verify that
removing the explicit package dependency lets both modes succeed.

Tests only; this precedes ocaml#16675.

(cherry picked from commit ffed146)

Signed-off-by: Ali Caglayan <[email protected]>
Create real directories for copy, symlink, and hardlink sandbox inputs.
Use Tree_copy for traversal and apply the selected mode only to files.

Keep patch-back directory handling and overlap deduplication unchanged.
Copy mode continues to reject overlapping files.

Directory copy actions work under symlink sandboxing with the recursive
symlink handling from ocaml#16686.

(cherry picked from commit 42895b1)

Signed-off-by: Ali Caglayan <[email protected]>
Record the copy-mode failure with dependencies on a directory, one of its
subdirectories, and a file inside both. Include a similarly named sibling
that sorts between the directory and its descendants, and check that empty
directories are preserved.

Symlink and hardlink modes expose the expected inputs, but copy mode
reports File exists before the action starts.

(cherry picked from commit a221aee)

Signed-off-by: Ali Caglayan <[email protected]>
(cherry picked from commit d4046e7)

Signed-off-by: Ali Caglayan <[email protected]>
(cherry picked from commit 2d02f36)

Signed-off-by: Ali Caglayan <[email protected]>
Skip sandbox inputs that have an ancestor in the same dependency set.
Populating a directory already includes its descendants, so processing
those paths again duplicates work and fails in copy mode with File exists.

Reuse the ancestor check from dynamic dependency population. Keep the full
dependency set for subsequent requests and correction handling, and retain
the existing protection for action-modified files.

Turn the package dependency reproducer (ocaml#16733, issue ocaml#16547) and the
simple and nested directory-overlap tests from recorded failures into
success. This follows the shared-traversal change in ocaml#16675.

(cherry picked from commit 0883b73)

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter marked this pull request as ready for review October 28, 2026 16:05
@Alizter Alizter mentioned this pull request Oct 28, 2026
62 tasks done
@Alizter
Alizter merged commit 1fba139 into ocaml:3.25.0-rc Oct 28, 2026
50 of 63 checks passed
@Alizter
Alizter deleted the backport-sandbox-stack-3.25 branch October 28, 2026 18:14
@Alizter Alizter added this to the 3.25.0 milestone Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants