Skip to main content

spawn_isolated

Function spawn_isolated 

Source
pub fn spawn_isolated(
    plugin_path: &Path,
    _cfg: &SandboxConfig,
) -> Result<SandboxedProcess>
Available on FreeBSD only.
Expand description

Spawn an isolated plugin child process.

§Steps

  1. Validate plugin_path (must be an existing file).
  2. open(plugin_path, O_RDONLY | O_CLOEXEC) — confirms readability before forking and gives the parent an fd to pass to the child.
  3. socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC) for host↔plugin IPC.
  4. pdfork(). The child closes the parent’s IPC end, dlopens the plugin (before cap_enter, while the global namespace is still reachable), restricts its IPC socket to READ | WRITE, enters capability mode, and serves the control loop. The parent closes the child’s IPC end and the plugin fd and returns the handle.

§Errors

  • PluginError::InvalidPath — missing/unreadable file or NUL in path.
  • PluginError::Sandboxsocketpair / pdfork failure.
  • (Inside the child) ABI/metadata errors cause the child to _exit(1) before responding; the parent observes this as an IPC error on the first request.

§Panics

Never. All fallible operations are propagated via Result.