From ad74dfb5520414b21d2e8b057f846661e671fc2e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 6 Feb 2021 20:45:03 +0100 Subject: unshare: use u32 for UIDs/GIDs libc has separate type aliases for UIDs and GIDs. Just define our own for both. --- src/unshare.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/unshare.rs b/src/unshare.rs index 98ebe90..717bf53 100644 --- a/src/unshare.rs +++ b/src/unshare.rs @@ -12,13 +12,15 @@ use nix::unistd; // use crate::prepared_command::PreparedCommand; use crate::util::Checkable; +type ID = u32; + #[derive(Debug, Eq, Ord, PartialEq, PartialOrd)] struct SubIDRange { - start: libc::uid_t, - count: libc::uid_t, + start: ID, + count: ID, } -fn parse_uid(s: &OsStr) -> Option { +fn parse_uid(s: &OsStr) -> Option { s.to_str().and_then(|s| s.parse().ok()) } @@ -55,19 +57,15 @@ fn read_id_ranges(filename: &Path) -> Result> { #[derive(Debug)] struct SubIDMap { - lower: libc::uid_t, - upper: libc::uid_t, - count: libc::uid_t, + lower: ID, + upper: ID, + count: ID, } -pub const BUILD_UID: libc::uid_t = 800; -pub const BUILD_GID: libc::uid_t = 800; +pub const BUILD_UID: ID = 800; +pub const BUILD_GID: ID = 800; -fn generate_idmap( - id: libc::uid_t, - mapped_id: libc::uid_t, - mut ranges: Vec, -) -> Vec { +fn generate_idmap(id: ID, mapped_id: ID, mut ranges: Vec) -> Vec { let mut map = Vec::new(); map.push(SubIDMap { -- cgit v1.2.3