Skip to content

fix(images): install guest scripts without following image links - #443

Open
Floating-Y wants to merge 1 commit into
deeplethe:devfrom
Floating-Y:fix/guest-script-install
Open

Floating-Y wants to merge 1 commit into
deeplethe:devfrom
Floating-Y:fix/guest-script-install

Conversation

@Floating-Y

Copy link
Copy Markdown
Collaborator

Summary

An OCI image can supply sandstorm-init.sh or sandstorm-agent.py as a symlink. During Firecracker template creation, make_ext4 previously wrote the built-in scripts directly through those paths and changed init permissions by path, allowing writes outside the template rootfs. Confirmed against upstream dev at d27ab7c452126e3b34987b84d3c72cb41fc3fd16.

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 at 0644.

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:

Command Result
cargo test --offline --locked -p sandstorm-core --lib node::images::tests::guest_scripts -- --nocapture against the original install logic 4 failed, 1 passed as expected; both script symlink tests detected overwritten external markers
cargo test --offline --locked -p sandstorm-core --lib node::images::tests:: after the fix 21 passed
cargo fmt --all -- --check Passed
cargo clippy --offline --locked --all-targets --all-features -- -D warnings Passed
cargo test --offline --locked --all --quiet -- --test-threads=4 417 passed
git diff --check Passed

The 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 in node::tags::tests::children_arriving_together_share_one_fetch. Its isolated rerun with cargo test --offline --locked -p sandstorm-core --lib node::tags::tests::children_arriving_together_share_one_fetch -- --exact --nocapture passed, followed by the successful full run with four test threads.

KVM execution and end-to-end OCI-to-ext4 creation were not exercised.

Signed-off-by: danwood <118035379+Floating-Y@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant