Repository navigation
fix(images): install guest scripts without following image links - #443
Open
Floating-Y wants to merge 1 commit into
Open
Floating-Y wants to merge 1 commit into
Floating-Y wants to merge 1 commit into
Conversation
Signed-off-by: danwood <118035379+Floating-Y@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An OCI image can supply
sandstorm-init.shorsandstorm-agent.pyas a symlink. During Firecracker template creation,make_ext4previously wrote the built-in scripts directly through those paths and changed init permissions by path, allowing writes outside the template rootfs. Confirmed against upstreamdevatd27ab7c452126e3b34987b84d3c72cb41fc3fd16.Install both scripts through exclusively created temporary regular files in the rootfs directory. Write contents and set permissions using the open file handle, then rename over the final directory entry. This replaces symlinks, hard links, and regular files without rewriting an existing inode. Init stays
0755; the Python agent is readable at0644.Directory targets are rejected without deleting their contents. Write, permission, or rename failures remove the temporary file and propagate the original error before disk creation. Changes are limited to the script-install path and its existing test file; no dependencies were added.
Validation
Executed in Linux/WSL Ubuntu:
cargo test --offline --locked -p sandstorm-core --lib node::images::tests::guest_scripts -- --nocaptureagainst the original install logiccargo test --offline --locked -p sandstorm-core --lib node::images::tests::after the fixcargo fmt --all -- --checkcargo clippy --offline --locked --all-targets --all-features -- -D warningscargo test --offline --locked --all --quiet -- --test-threads=4git diff --checkThe five new Linux tests cover both script names, absolute and relative symlinks, unchanged external marker contents and permissions, regular-file replacement with new inodes, hard links, and empty/nonempty directory rejection with no temporary-file leftovers or disk creation. The original logic was extracted unchanged before the regression run.
The initial full-suite command,
cargo test --offline --locked --all --quiet, had 309 passing library tests and one timeout innode::tags::tests::children_arriving_together_share_one_fetch. Its isolated rerun withcargo test --offline --locked -p sandstorm-core --lib node::tags::tests::children_arriving_together_share_one_fetch -- --exact --nocapturepassed, followed by the successful full run with four test threads.KVM execution and end-to-end OCI-to-ext4 creation were not exercised.