@@ -21,6 +21,7 @@ mod test_mount {
21
21
use nix:: sched:: { unshare, CLONE_NEWNS , CLONE_NEWUSER } ;
22
22
use nix:: sys:: stat:: { self , S_IRWXU , S_IRWXG , S_IRWXO , S_IXUSR , S_IXGRP , S_IXOTH } ;
23
23
use nix:: unistd:: getuid;
24
+ use nix:: sys:: utsname;
24
25
25
26
use tempdir:: TempDir ;
26
27
@@ -30,6 +31,20 @@ exit 23";
30
31
const EXPECTED_STATUS : i32 = 23 ;
31
32
32
33
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
+
33
48
pub fn test_mount_tmpfs_without_flags_allows_rwx ( ) {
34
49
let tempdir = TempDir :: new ( "nix-test_mount" )
35
50
. unwrap_or_else ( |e| panic ! ( "tempdir failed: {}" , e) ) ;
@@ -185,6 +200,7 @@ exit 23";
185
200
. write ( true )
186
201
. open ( "/proc/self/uid_map" )
187
202
. 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()))
188
204
. unwrap_or_else ( |e| panic ! ( "could not write uid map: {}" , e) ) ;
189
205
}
190
206
}
@@ -209,9 +225,12 @@ macro_rules! run_tests {
209
225
210
226
#[ cfg( target_os = "linux" ) ]
211
227
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,
214
232
test_mount_bind} ;
233
+ check_kernel ( ) ;
215
234
setup_namespaces ( ) ;
216
235
217
236
run_tests ! ( test_mount_tmpfs_without_flags_allows_rwx,
0 commit comments