priv_sep

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

commit 660c923cd63d80d1d1ba58c9228af2a9e3ca1fcc
parent 4d9d228407d2ebc3a045af3409aa6d58dba61ef6
Author: Zack Newman <zack@philomathiclife.com>
Date:   Mon, 23 Jun 2025 12:46:35 -0600

more lints

Diffstat:
MCargo.toml | 37++++++++++++++++++++++++++++++++-----
Msrc/c.rs | 28++++++++++++++--------------
Msrc/lib.rs | 1+
3 files changed, 47 insertions(+), 19 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -10,21 +10,48 @@ name = "priv_sep" readme = "README.md" repository = "https://git.philomathiclife.com/repos/priv_sep/" rust-version = "1.86.0" -version = "3.0.0-alpha.1" +version = "3.0.0-alpha.1.1" [lints.rust] -unknown_lints = { level = "deny", priority = -1 } +ambiguous_negative_literals = { level = "deny", priority = -1 } +closure_returning_async_block = { level = "deny", priority = -1 } +deref_into_dyn_supertrait = { level = "deny", priority = -1 } +ffi_unwind_calls = { level = "deny", priority = -1 } future_incompatible = { level = "deny", priority = -1 } +impl_trait_redundant_captures = { level = "deny", priority = -1 } +keyword-idents = { level = "deny", priority = -1 } let_underscore = { level = "deny", priority = -1 } +linker_messages = { level = "deny", priority = -1 } +macro_use_extern_crate = { level = "deny", priority = -1 } +meta_variable_misuse = { level = "deny", priority = -1 } +missing_copy_implementations = { level = "deny", priority = -1 } +missing_debug_implementations = { level = "deny", priority = -1 } missing_docs = { level = "deny", priority = -1 } +non_ascii_idents = { level = "deny", priority = -1 } nonstandard_style = { level = "deny", priority = -1 } +redundant_imports = { level = "deny", priority = -1 } +redundant_lifetimes = { level = "deny", priority = -1 } refining_impl_trait = { level = "deny", priority = -1 } rust_2018_compatibility = { level = "deny", priority = -1 } rust_2018_idioms = { level = "deny", priority = -1 } rust_2021_compatibility = { level = "deny", priority = -1 } rust_2024_compatibility = { level = "deny", priority = -1 } +single_use_lifetimes = { level = "deny", priority = -1 } +trivial_casts = { level = "deny", priority = -1 } +trivial_numeric_casts = { level = "deny", priority = -1 } +unit_bindings = { level = "deny", priority = -1 } +unknown_lints = { level = "deny", priority = -1 } +unnameable_types = { level = "deny", priority = -1 } +unreachable_pub = { level = "deny", priority = -1 } unsafe_code = { level = "deny", priority = -1 } +unstable_features = { level = "deny", priority = -1 } unused = { level = "deny", priority = -1 } +unused_crate_dependencies = { level = "deny", priority = -1 } +unused_import_braces = { level = "deny", priority = -1 } +unused_lifetimes = { level = "deny", priority = -1 } +unused_qualifications = { level = "deny", priority = -1 } +unused_results = { level = "deny", priority = -1 } +variant_size_differences = { level = "deny", priority = -1 } warnings = { level = "deny", priority = -1 } [lints.clippy] @@ -46,15 +73,15 @@ exhaustive_structs = "allow" implicit_return = "allow" min_ident_chars = "allow" missing_trait_methods = "allow" +pub_with_shorthand = "allow" +redundant_pub_crate = "allow" ref_patterns = "allow" return_and_then = "allow" -single_call_fn = "allow" single_char_lifetime_names = "allow" -unseparated_literal_suffix = "allow" [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [dev-dependencies] -tokio = { version = "1.44.2", default-features = false, features = ["macros", "net", "rt"] } +tokio = { version = "1.45.1", default-features = false, features = ["macros", "net", "rt"] } diff --git a/src/c.rs b/src/c.rs @@ -3,7 +3,7 @@ use super::{Gid, Uid, UserInfo}; use core::ffi::c_ushort; use core::ffi::{c_char, c_int}; /// Error code when a libc call is successful. -pub const SUCCESS: c_int = 0; +pub(crate) const SUCCESS: c_int = 0; /// `uid_t` and `gid_t`. #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] pub type IdT = c_ushort; @@ -17,7 +17,7 @@ pub type IdT = i32; target_os = "nto", target_os = "vita" )))] -pub type IdT = u32; +pub(crate) type IdT = u32; /// `time_t`. #[cfg(all( any( @@ -45,7 +45,7 @@ type TimeT = i32; type TimeT = i64; /// [`passwd`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/pwd.h.html). #[repr(C)] -pub struct Passwd { +pub(crate) struct Passwd { /// Username. name: *mut c_char, /// User password. @@ -93,7 +93,7 @@ pub struct Passwd { } impl Passwd { /// Returns `UserInfo` based on the contained user and group IDs. - pub const fn into_user_info(self) -> UserInfo { + pub(crate) const fn into_user_info(self) -> UserInfo { UserInfo { uid: Uid(self.uid), gid: Gid(self.gid), @@ -103,23 +103,23 @@ impl Passwd { #[expect(unsafe_code, reason = "FFI requires unsafe")] unsafe extern "C" { /// [`getuid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getuid.html). - pub safe fn getuid() -> IdT; + pub(crate) safe fn getuid() -> IdT; /// [`geteuid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/geteuid.html). - pub safe fn geteuid() -> IdT; + pub(crate) safe fn geteuid() -> IdT; /// [`getgid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getgid.html). - pub safe fn getgid() -> IdT; + pub(crate) safe fn getgid() -> IdT; /// [`getegid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getegid.html). - pub safe fn getegid() -> IdT; + pub(crate) safe fn getegid() -> IdT; /// [`setresuid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/setresuid.html). - pub safe fn setresuid(ruid: IdT, euid: IdT, suid: IdT) -> c_int; + pub(crate) safe fn setresuid(ruid: IdT, euid: IdT, suid: IdT) -> c_int; /// [`setresgid`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/setresgid.html). - pub safe fn setresgid(rgid: IdT, egid: IdT, sgid: IdT) -> c_int; + pub(crate) safe fn setresgid(rgid: IdT, egid: IdT, sgid: IdT) -> c_int; /// [`chroot(2)`](https://manned.org/chroot.2). - pub fn chroot(path: *const c_char) -> c_int; + pub(crate) fn chroot(path: *const c_char) -> c_int; /// [`chdir`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/chdir.html). - pub fn chdir(path: *const c_char) -> c_int; + pub(crate) fn chdir(path: *const c_char) -> c_int; /// [`getpwnam_r`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getpwnam_r.html). - pub fn getpwnam_r( + pub(crate) fn getpwnam_r( name: *const c_char, pwd: *mut Passwd, buf: *mut c_char, @@ -127,7 +127,7 @@ unsafe extern "C" { result: *mut *mut Passwd, ) -> c_int; /// [`getpwuid_r`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/getpwuid_r.html). - pub fn getpwuid_r( + pub(crate) fn getpwuid_r( uid: IdT, pwd: *mut Passwd, buf: *mut c_char, diff --git a/src/lib.rs b/src/lib.rs @@ -938,6 +938,7 @@ mod tests { use super::{Permissions, Promise, Promises}; use core::net::{Ipv6Addr, SocketAddrV6}; use std::{fs, io::Error, net::TcpListener}; + use tokio as _; const README: &str = "README.md"; #[test] fn test_getuid() {