Skip to content
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
23 changes: 1 addition & 22 deletions crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,35 +203,14 @@ prepare_guest_image_rootfs() {

exec_supervisor_in_newroot() {
local chroot_bin
local bootstrap="/.openshell-bootstrap"
local supervisor="${bootstrap}/opt/openshell/bin/openshell-sandbox"
local loader
local lib_path
local supervisor="/.openshell-bootstrap/opt/openshell/bin/openshell-sandbox"

for chroot_bin in /usr/sbin/chroot /usr/bin/chroot /sbin/chroot /bin/chroot; do
[ -x "$chroot_bin" ] || continue

if [ -x "/newroot${supervisor}" ]; then
for loader in \
"${bootstrap}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" \
"${bootstrap}/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" \
"${bootstrap}/lib64/ld-linux-x86-64.so.2" \
"${bootstrap}/lib/ld-linux-x86-64.so.2" \
"${bootstrap}/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1" \
"${bootstrap}/usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1" \
"${bootstrap}/lib/ld-linux-aarch64.so.1" \
"${bootstrap}/lib64/ld-linux-aarch64.so.1"; do
if [ -x "/newroot${loader}" ]; then
lib_path="${bootstrap}/lib:${bootstrap}/lib64:${bootstrap}/usr/lib:${bootstrap}/usr/lib64:${bootstrap}/lib/aarch64-linux-gnu:${bootstrap}/lib/x86_64-linux-gnu:${bootstrap}/usr/lib/aarch64-linux-gnu:${bootstrap}/usr/lib/x86_64-linux-gnu"
exec "$chroot_bin" /newroot "$loader" --library-path "$lib_path" "$supervisor" "$@"
fi
done
exec "$chroot_bin" /newroot "$supervisor" "$@"
fi

if [ -x /newroot/opt/openshell/bin/openshell-sandbox ]; then
exec "$chroot_bin" /newroot /opt/openshell/bin/openshell-sandbox "$@"
fi
done

ts "FATAL: unable to exec openshell-sandbox in guest rootfs"
Expand Down
6 changes: 6 additions & 0 deletions crates/openshell-driver-vm/src/rootfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,12 @@ mod tests {
)
);
assert!(init_script.contains("OPENSHELL_VM_SANDBOX_BOOTSTRAP"));
// The shell script is embedded verbatim in the guest rootfs, so these
// assertions pin its launch contract at the packaging boundary.
assert!(init_script.contains("exec \"$chroot_bin\" /newroot \"$supervisor\" \"$@\""));
assert!(!init_script.contains("--library-path"));
assert!(!init_script.contains("\"$loader\""));
assert!(!init_script.contains("ld-linux"));
Comment thread
alangou marked this conversation as resolved.
assert!(init_script.contains(" reconcile_sandbox_account\n setup_sandbox_workdir"));
assert!(
init_script
Expand Down
Loading