pub struct LandlockManager { /* private fields */ }Expand description
Landlock filesystem access-control manager
Implements fine-grained, path-based filesystem restrictions as an additional defense layer on top of namespaces, capabilities, and seccomp.
Properties (matching Nucleus security invariants):
- Irreversible: once restrict_self() is called, restrictions cannot be lifted
- Stackable: layered with seccomp and capability dropping
- Unprivileged: works in rootless mode
Implementations§
Source§impl LandlockManager
impl LandlockManager
pub fn new() -> Self
Sourcepub fn add_rw_path(&mut self, path: &str)
pub fn add_rw_path(&mut self, path: &str)
Register additional paths that need read+write access. Used for volume mounts that aren’t under the default allowed paths.
Sourcepub fn apply_container_policy(&mut self) -> Result<bool>
pub fn apply_container_policy(&mut self) -> Result<bool>
Apply the container Landlock policy.
Rules:
/(root): read-only traversal (ReadDir) so path resolution works/bin,/usr: read + execute (for running agent binaries)/lib,/lib64: read (shared libraries)/etc: read (config / resolv.conf / nsswitch)/dev: read (already minimal device nodes)/proc: read (already mounted read-only)/tmp: read + write + create + remove (agent scratch space)/context: read-only (pre-populated agent data)
Everything else is denied by the ruleset.
Sourcepub fn assert_minimum_abi(&self, production_mode: bool) -> Result<()>
pub fn assert_minimum_abi(&self, production_mode: bool) -> Result<()>
Assert that the kernel supports at least the minimum Landlock ABI version required for production workloads.
Returns Ok(()) if the ABI is sufficient, or Err if the kernel is too old. In best-effort mode, a too-old kernel is logged but not fatal.
Sourcepub fn apply_container_policy_with_mode(
&mut self,
best_effort: bool,
) -> Result<bool>
pub fn apply_container_policy_with_mode( &mut self, best_effort: bool, ) -> Result<bool>
Apply with configurable failure behavior.
When best_effort is true, failures (e.g. kernel without Landlock) are
logged and execution continues.
Sourcepub fn apply_execute_allowlist_policy(
&mut self,
allowed_roots: &[PathBuf],
best_effort: bool,
) -> Result<bool>
pub fn apply_execute_allowlist_policy( &mut self, allowed_roots: &[PathBuf], best_effort: bool, ) -> Result<bool>
Apply an execute-only allowlist for host-side supervisor processes.
This policy handles only LANDLOCK_ACCESS_FS_EXECUTE, leaving normal
read/write access untouched. It is intended for runtimes like gVisor
that need a narrow post-namespace executable allowlist while still
blocking arbitrary host executable and setuid-wrapper execs after the
supervisor has entered its setup namespace.
Sourcepub fn is_applied(&self) -> bool
pub fn is_applied(&self) -> bool
Check if Landlock policy has been applied