diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-02-06 20:45:03 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-02-06 21:23:36 +0100 |
commit | ad74dfb5520414b21d2e8b057f846661e671fc2e (patch) | |
tree | 258aa3bff2b21620b3304193519ffac43c3e13ce | |
parent | d0f30c132627bdd9d02c48adc76e9bd97688bd8f (diff) | |
download | rebel-ad74dfb5520414b21d2e8b057f846661e671fc2e.tar rebel-ad74dfb5520414b21d2e8b057f846661e671fc2e.zip |
unshare: use u32 for UIDs/GIDs
libc has separate type aliases for UIDs and GIDs. Just define our own
for both.
-rw-r--r-- | src/unshare.rs | 24 |
1 files 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<libc::uid_t> { +fn parse_uid(s: &OsStr) -> Option<ID> { s.to_str().and_then(|s| s.parse().ok()) } @@ -55,19 +57,15 @@ fn read_id_ranges(filename: &Path) -> Result<Vec<SubIDRange>> { #[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<SubIDRange>, -) -> Vec<SubIDMap> { +fn generate_idmap(id: ID, mapped_id: ID, mut ranges: Vec<SubIDRange>) -> Vec<SubIDMap> { let mut map = Vec::new(); map.push(SubIDMap { |