Crates.io | openbsd |
lib.rs | openbsd |
version | 0.1.2 |
source | src |
created_at | 2020-12-07 16:09:59.320778 |
updated_at | 2021-11-19 12:40:27.947694 |
description | Rust bindings for OpenBSD's pledge(2) and unveil(2). |
homepage | |
repository | https://github.com/joshua-cooper/openbsd-rs |
max_upload_size | |
id | 320534 |
size | 7,951 |
Rust bindings for OpenBSD's pledge(2) and unveil(2).
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
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
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());
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());