Debian Codegraph @

/

debian rust-unveil 0.3.2-1debian librust-unveil-dev debian librust-unveil+default-dev debian librust-unveil-0-dev debian librust-unveil-0+default-dev debian librust-unveil-0.3-dev debian librust-unveil-0.3+default-dev debian librust-unveil-0.3.2-dev debian librust-unveil-0.3.2+default-dev cargo unveil 0.3.2 debianjsonmakefilemarkdownrustrustrust-c-abishelltoml 15 files · 83 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • rust-libc (librust-libc-0.2+default-dev)
  • cargo, debhelper-compat, libstd-rust-dev, rustc
README (full)

unveil-rs

Crate Documentation

Rust binding for OpenBSD's unveil(2).

Requirements

  • OpenBSD 6.4 or later

Usage

extern crate unveil;

use std::fs::File;
use std::io::prelude::*;
use unveil::unveil;

fn main() {
    let path = "public.txt";
    let contents = b"Hello world!";
    File::create(path).unwrap().write_all(contents).unwrap();

    // Restrict filesystem view by only allowing read operations on the specified path
    unveil(path, "r")
    .or_else(unveil::Error::ignore_platform)
    .unwrap();

    // Reading from unveiled paths will succeed
    let mut file = File::open(path).unwrap();
    let mut buffer = Vec::new();
    file.read_to_end(&mut buffer).unwrap();
    assert_eq!(contents, &buffer[..]);

    // Reading from paths which have not been unveiled will fail
    assert!(File::open("/etc/passwd").is_err());

    // Disable further calls to unveil
    unveil("", "")
    .or_else(unveil::Error::ignore_platform)
    .unwrap();

    // All calls to unveil will now fail
    assert!(unveil(path, "rw").is_err());
}

Related projects

  • pledge-rs - Rust binding for OpenBSD's pledge(2).
dir debian/
dir src/
file .cargo_vcs_info.json
file .gitignore
file Cargo.toml
file Cargo.toml.orig
file LICENSE-APACHE
file LICENSE-MIT
file README.md