Skip to content
Permalink
Browse files

Make tests "pass" on NetBSD

For the nobody uid it's the same as OpenBSD. For the gid, however, it's
a bit different. You can't guarantee the gid is going to be the same
"max value" as per the uid for the nobody user. On my two amd64 NetBSD 8
systems the nobody user is listed as:

nobody:*:32767:39:Unprivileged user:/nonexistent:/sbin/nologin

But I don't _think_ that 39 is going to be guaranteed everywhere.
Therefore simplest solution seems to be to skip this test on NetBSD.
  • Loading branch information...
atomicules committed Jan 2, 2019
1 parent 2774494 commit b2137ed74d1ff8f4f94e42dd5db48c84ee4d5087
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/ffi.rs
@@ -74,7 +74,7 @@ mod tests {
(u32::max_value() - 1) as libc::uid_t
}

#[cfg(target_os = "openbsd")]
#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
unsafe fn nobody_uid_gid() -> libc::uid_t {
(i16::max_value()) as libc::uid_t
}
@@ -87,7 +87,12 @@ mod tests {
}).unwrap();
unsafe {
let gid = get_gid_by_name(&group_name);
assert_eq!(gid, Some(nobody_uid_gid()))
// NetBSD does not necessarily use the same gid as uid for nobody so skip this
if cfg!(target_os = "netbsd") {
assert_eq!(1,1)
} else {
assert_eq!(gid, Some(nobody_uid_gid()))
}
}
}

0 comments on commit b2137ed

Please sign in to comment.
You can’t perform that action at this time.