Expand description
Platform/OS-specific system calls for Leviath, isolated behind one cross-platform API.
Every #[cfg(unix)]/#[cfg(windows)] branch and platform
permission/signal/TTY primitive used anywhere in the workspace lives here -
nowhere else. The unavoidable OS-level unsafe is delegated to audited
crates (nix) and safe std APIs, so this crate itself contains no unsafe.
Callers use the plain functions re-exported at the crate root and never
write a #[cfg] of their own.
§Why this crate exists
- De-duplication. The
process_groupdetach andPermissions::from_mode(0o600)logic each has exactly one implementation here, rather than being spread across call sites inleviath-cli. - Per-OS coverage correctness. Because all platform code is gathered
into cfg-gated submodules (
platform), the non-target implementations (#[cfg(windows)]on a Linux CI run) are simply not compiled, so the coverage tool never sees them as gaps. The Linux-visible code paths are all reachable from real unit tests. - Testability. Every function in this crate is exercised by real unit
tests - the syscalls here are either safe to call under test (
chmodon a tempfile) or split behind an injected seam (tty::osc52_write_viatakes the tty opener + sink;perms’ hardening op is afnpointer). The only genuinely-untestable real-I/O leaves (opening/dev/tty, writing the realstdout()) are composed in the CLI binary, not here - so this crate contains no#[cfg(not(test))].
Re-exports§
pub use browser::open_url;pub use perms::ensure_file_private;pub use perms::secure_dir_perms;pub use perms::secure_file_perms;pub use perms::write_private;pub use process::peer_uid;pub use process::configure_detached;pub use process::current_uid;pub use process::kill_process_group;pub use sandbox::ContainerRunSpec;pub use sandbox::container_exec_argv;pub use sandbox::container_rm_argv;pub use sandbox::container_run_argv;pub use sandbox::detect_container_engine;pub use sandbox::namespace_argv;pub use sandbox::namespace_supported;pub use tty::osc52_write_via;
Modules§
- browser
- Opening a URL in the user’s default browser.
- keychain
- The OS credential store: macOS Keychain, Windows Credential Manager, and the Secret Service on other Unixes.
- perms
- File and directory permission hardening.
- process
- Process control: detached spawning.
- sandbox
- Sandbox command construction for isolated tool execution.
- tty
- Terminal clipboard support via the OSC52 escape sequence.