openbsd

Crates.ioopenbsd
lib.rsopenbsd
version0.1.2
sourcesrc
created_at2020-12-07 16:09:59.320778
updated_at2021-11-19 12:40:27.947694
descriptionRust bindings for OpenBSD's pledge(2) and unveil(2).
homepage
repositoryhttps://github.com/joshua-cooper/openbsd-rs
max_upload_size
id320534
size7,951
Josh Cooper (joshua-cooper)

documentation

README

openbsd

Rust bindings for OpenBSD's pledge(2) and unveil(2).

Usage

Pledge

Macro syntax

use openbsd::pledge;

pledge!("stdio rpath exec")?; // only make promises
pledge!(_, "stdio rpath")?; // only make execpromises
pledge!("stdio", "stdio")?; // make both

assert!(pledge!("wpath").is_err()); // cannot increase permissions

Function syntax

use openbsd::pledge::{pledge, pledge_promises, pledge_execpromises};

pledge_promises("stdio rpath exec")?; // only make promises
pledge_execpromises("stdio rpath")?; // only make execpromises
pledge("stdio", "stdio")?; // make both

assert!(pledge_promises("wpath").is_err()); // cannot increase permissions

Unveil

Macro syntax

use openbsd::unveil;

unveil!("/path/to/file", "rw")?;
unveil!("/path/to/another/file", "r")?;

unveil!(); // disable further calls to unveil
assert!(unveil!("/", "rwxc").is_err());

Function syntax

use openbsd::unveil;

unveil("/path/to/file", "rw")?;
unveil("/path/to/another/file", "r")?;

unveil::disable(); // disable further calls to unveil
assert!(unveil("/", "rwxc").is_err());
Commit count: 3

cargo fmt