pub fn spawn_isolated(
plugin_path: &Path,
_cfg: &SandboxConfig,
) -> Result<SandboxedProcess>Available on FreeBSD only.
Expand description
Spawn an isolated plugin child process.
§Steps
- Validate
plugin_path(must be an existing file). open(plugin_path, O_RDONLY | O_CLOEXEC)— confirms readability before forking and gives the parent an fd to pass to the child.socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC)for host↔plugin IPC.pdfork(). The child closes the parent’s IPC end,dlopens the plugin (beforecap_enter, while the global namespace is still reachable), restricts its IPC socket toREAD | 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::Sandbox—socketpair/pdforkfailure.- (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.