priv_sep

Privilege separation library.
git clone https://git.philomathiclife.com/repos/priv_sep
Log | Files | Refs | README

commit 210dc8897be1454f42e44d41095a2061f34a5877
parent f743e91856c60e488f06fdc7415c75e2dc374d23
Author: Zack Newman <zack@philomathiclife.com>
Date:   Tue, 25 Jul 2023 16:23:16 -0600

change target_os into feature so doc.rs renders better docs

Diffstat:
MCargo.toml | 21++++++++++++++++-----
MREADME.md | 4++--
Abuild.rs | 12++++++++++++
Msrc/lib.rs | 2+-
4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -2,21 +2,32 @@ authors = ["Zack Newman <zack@philomathiclife.com>"] categories = ["development-tools::ffi", "external-ffi-bindings", "os"] description = "FFI for pledge(2) and unveil(2) on OpenBSD." -documentation = "https://crates.io/crates/priv_sep" +documentation = "https://docs.rs/priv_sep" edition = "2021" keywords = ["ffi", "openbsd", "privsep", "security"] license = "MIT OR Apache-2.0" name = "priv_sep" readme = "README.md" repository = "https://git.philomathiclife.com/repos/priv_sep/" -version = "0.1.0" +version = "0.2.0" [lib] name = "priv_sep" path = "src/lib.rs" -[target.'cfg(openbsd)'.dependencies] -libc = { version = "0.2.147", default-features = false, features = ["std"] } +[dependencies] +libc = { version = "0.2.147", default-features = false, features = ["std"], optional = true } + +[build-dependencies] +rustc_version = "0.4.0" + +[features] +openbsd = ["dep:libc"] +default = ["openbsd"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] [badges] maintenance = { status = "actively-developed" } @@ -24,4 +35,4 @@ maintenance = { status = "actively-developed" } [profile.release] lto = true panic = 'abort' -strip = 'symbols' +strip = true diff --git a/README.md b/README.md @@ -8,14 +8,14 @@ but in the future may contain functionality for Linux's ## Pledge -It is very rare to use the `execpromises` parameter, so [`pledge`] only relies on [`Promise`]s. +It is very rare to use the `execpromises` parameter, so [`pledge`](https://docs.rs/priv_sep/latest/priv_sep/fn.pledge.html) only relies on [`Promise`](https://docs.rs/priv_sep/latest/priv_sep/enum.Promise.html)s. Additionally this function cannot be used to invoke `pledge(2)` with a `promises` value of `""`. ## Unveil Unlike `pledge(2)` which allows a large quantity of duplicate `promises` to be provided, `unveil(2)` allows a maximum of four `permissions` to be passed. For this reason, there are dedicated functions for each quantity of -[`Permission`]s. +[`Permission`](https://docs.rs/priv_sep/latest/priv_sep/enum.Permission.html)s. ## Errors diff --git a/build.rs b/build.rs @@ -0,0 +1,12 @@ +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + let channel = match version_meta().unwrap().channel { + Channel::Stable => "CHANNEL_STABLE", + Channel::Beta => "CHANNEL_BETA", + Channel::Nightly => "CHANNEL_NIGHTLY", + Channel::Dev => "CHANNEL_DEV", + }; + println!("cargo:rustc-cfg={}", channel) +} diff --git a/src/lib.rs b/src/lib.rs @@ -44,7 +44,7 @@ clippy::missing_trait_methods, clippy::unseparated_literal_suffix )] -#![cfg(target_os = "openbsd")] +#![cfg(feature = "openbsd")] extern crate alloc; use alloc::ffi::{CString, NulError}; use core::ffi::{c_char, c_int};