Skip to content

Commit

Permalink
Add test for ensuring consistent G/UID mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
cd-work committed Sep 27, 2023
1 parent a8834c6 commit 3a51640
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ name = "net_without_namespaces"
path = "tests/net_without_namespaces.rs"
harness = false

[[test]]
name = "consistent_id_mappings"
path = "tests/consistent_id_mappings.rs"
harness = false

[target.'cfg(target_os = "linux")'.dependencies]
seccompiler = "0.2.0"
landlock = "0.2.0"
Expand Down
16 changes: 16 additions & 0 deletions tests/consistent_id_mappings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use birdcage::{Birdcage, Sandbox};

fn main() {
let uid = unsafe { libc::getuid() };
let gid = unsafe { libc::getgid() };
let euid = unsafe { libc::geteuid() };
let egid = unsafe { libc::getegid() };

let birdcage = Birdcage::new().unwrap();
birdcage.lock().unwrap();

assert_eq!(uid, unsafe { libc::getuid() });
assert_eq!(gid, unsafe { libc::getgid() });
assert_eq!(euid, unsafe { libc::geteuid() });
assert_eq!(egid, unsafe { libc::getegid() });
}

0 comments on commit 3a51640

Please sign in to comment.