Skip to main content

prepare

Function prepare 

Source
pub fn prepare(
    profile: &Profile,
    identity: &Identity,
    handles: &[RawHandle],
) -> Result<SandboxProcessConfig, Error>
Expand description

STAGE 1 — control process, immediately before the spawn.

Computes the launch-time configuration for a confined worker and returns it as plain data. It does not mutate any process builder, touch any file descriptor, or call any process-creation API — the caller passes the returned SandboxProcessConfig to its platform process builder.

  • profile — the worker’s linked policy. On Linux only its launch-relevant bits are consulted here (the worker self-applies the rest in apply); on Windows its entire LPAC portion is reflected into the Windows launch preparation.
  • identity — the per-spawn identity. On Windows, its AppContainer configuration is reflected in the Windows launch preparation. Unix launches retain the spawning process’s host UID/GID.
  • handles — the handles to keep inheritable. They are echoed into SandboxProcessConfig::inherit_handles; the platform process builder closes every other descriptor except its configured standard I/O.

§Example

use sandbox::{Identity, Profile, RawHandle};

let profile = Profile::deny_all().build();
let handles = [RawHandle(3)];
let preparation = sandbox::prepare(&profile, &Identity::default(), &handles)?;

This only records the child-visible descriptor number. The process builder must map an owned source descriptor to that number and apply the preparation before spawning; the worker must still call apply.