6 个版本

使用旧的 Rust 2015

0.3.2 2022 年 5 月 22 日
0.3.1 2021 年 6 月 6 日
0.3.0 2021 年 1 月 10 日
0.2.1 2020 年 2 月 16 日
0.1.0 2018 年 10 月 20 日

432Unix APIs 中排名

Download history · Rust 包仓库 96/week @ 2024-04-01 · Rust 包仓库 46/week @ 2024-04-08 · Rust 包仓库 67/week @ 2024-04-15 · Rust 包仓库 62/week @ 2024-04-22 · Rust 包仓库 37/week @ 2024-04-29 · Rust 包仓库 46/week @ 2024-05-06 · Rust 包仓库 37/week @ 2024-05-13 · Rust 包仓库 50/week @ 2024-05-20 · Rust 包仓库 54/week @ 2024-05-27 · Rust 包仓库 50/week @ 2024-06-03 · Rust 包仓库 34/week @ 2024-06-10 · Rust 包仓库 44/week @ 2024-06-17 · Rust 包仓库 38/week @ 2024-06-24 · Rust 包仓库 15/week @ 2024-07-01 · Rust 包仓库 65/week @ 2024-07-08 · Rust 包仓库 46/week @ 2024-07-15 · Rust 包仓库

每月下载量 170
用于 9 crates

MIT/Apache

8KB
120 代码行数,不包括注释

unveil-rs

Crate Documentation

OpenBSD 的 unveil(2) 的 Rust 绑定。

要求

  • OpenBSD 6.4 或更高版本

用法

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());
}
  • pledge-rs - OpenBSD 的 pledge(2) 的 Rust 绑定。

依赖项

~43KB