Function patch_with_sandbox_scripts

Source
pub async fn patch_with_sandbox_scripts(
    scripts_dir: &Path,
    scripts: &HashMap<String, String>,
    shell_path: impl AsRef<Path>,
) -> MicrosandboxResult<()>
Expand description

Updates a rootfs by adding sandbox script files to a /.sandbox_scripts directory.

This function:

  1. Creates a .sandbox_scripts directory under the rootfs if it doesn’t exist
  2. For each script in the provided HashMap, creates a file with the given name
  3. Adds a shebang line using the provided shell path
  4. Makes the script files executable (rwxr-x—)
  5. Creates a shell script containing just the shell path

§Arguments

  • root_path - Path to the root of the filesystem to patch
  • scripts - HashMap containing script names and their contents
  • shell_path - Path to the shell binary within the rootfs (e.g. “/bin/sh”)