Skip to content

Commit b6d9a28

Browse files
committed
Skip the mount tests on kernel 4.4.0
Some versions of that kernel have a known bug with tmpfs in namespaces. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087 Fixes #610
1 parent 274b09e commit b6d9a28

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/test_mount.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod test_mount {
2121
use nix::sched::{unshare, CLONE_NEWNS, CLONE_NEWUSER};
2222
use nix::sys::stat::{self, S_IRWXU, S_IRWXG, S_IRWXO, S_IXUSR, S_IXGRP, S_IXOTH};
2323
use nix::unistd::getuid;
24+
use nix::sys::utsname;
2425

2526
use tempdir::TempDir;
2627

@@ -30,6 +31,20 @@ exit 23";
3031
const EXPECTED_STATUS: i32 = 23;
3132

3233
const NONE: Option<&'static [u8]> = None;
34+
35+
// Skip tests on kernel 4.4.0, which has a bug regarding tmpfs in namespaces
36+
// https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1659087
37+
pub fn check_kernel() {
38+
let u = utsname::uname();
39+
if u.release().starts_with("4.4.0") {
40+
let stderr = io::stderr();
41+
let mut handle = stderr.lock();
42+
writeln!(handle, "Linux kernel 4.4.0 has known bugs with tmpfs in namespaces. Skipping test.")
43+
.unwrap();
44+
process::exit(0);
45+
}
46+
}
47+
3348
pub fn test_mount_tmpfs_without_flags_allows_rwx() {
3449
let tempdir = TempDir::new("nix-test_mount")
3550
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
@@ -185,6 +200,7 @@ exit 23";
185200
.write(true)
186201
.open("/proc/self/uid_map")
187202
.and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes()))
203+
//.and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes()))
188204
.unwrap_or_else(|e| panic!("could not write uid map: {}", e));
189205
}
190206
}
@@ -209,9 +225,12 @@ macro_rules! run_tests {
209225

210226
#[cfg(target_os = "linux")]
211227
fn main() {
212-
use test_mount::{setup_namespaces, test_mount_tmpfs_without_flags_allows_rwx,
213-
test_mount_rdonly_disallows_write, test_mount_noexec_disallows_exec,
228+
use test_mount::{setup_namespaces, check_kernel,
229+
test_mount_tmpfs_without_flags_allows_rwx,
230+
test_mount_rdonly_disallows_write,
231+
test_mount_noexec_disallows_exec,
214232
test_mount_bind};
233+
check_kernel();
215234
setup_namespaces();
216235

217236
run_tests!(test_mount_tmpfs_without_flags_allows_rwx,

0 commit comments

Comments
 (0)