#sandbox #abstraction #utilities #landlock #rules #command #dev

leucite

A wrapper crate around rust-landlock that provides useful abstractions and utilities

2 unstable releases

new 0.2.0 Jan 14, 2025
0.1.0 Dec 18, 2024

#1579 in Rust patterns

Download history 124/week @ 2024-12-18 117/week @ 2025-01-08

241 downloads per month

Apache-2.0

17KB
232 lines

leucite

Crates.io Documentation Dependency status

A wrapper crate around rust-landlock that provides useful abstractions and utilities

Example

let rules = Rules::new()
    .add_read_only("/usr")
    .add_read_only("/etc")
    .add_read_only("/dev")
    .add_read_only("/bin")
    .add_read_write("/tmp/foo");

// Execute `bash -i` in the `/tmp/foo` directory using the provided rules
Command::new("bash")
    .arg("-i")
    .current_dir("/tmp/foo")
    .env_clear()
    .restrict(rules.into())
    .max_memory(MemorySize::from_mb(100))
    .spawn()?
    .wait()?;

lib.rs:

A wrapper crate around rust-landlock that provides useful abstractions and utilities

Example

let rules = Rules::new()
    .add_read_only("/usr")
    .add_read_only("/etc")
    .add_read_only("/dev")
    .add_read_only("/bin")
    .add_read_write("/tmp/foo");

// Execute `bash -i` in the `/tmp/foo` directory using the provided rules
Command::new("bash")
    .arg("-i")
    .current_dir("/tmp/foo")
    .env_clear()
    .restrict(rules.into())
    .max_memory(MemorySize::from_mb(100))
    .spawn()?
    .wait()?;

Dependencies

~0.6–9MB
~82K SLoC