File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ extern crate nix;
9
9
extern crate lazy_static;
10
10
extern crate libc;
11
11
extern crate rand;
12
+ #[ cfg( target_os = "freebsd" ) ]
13
+ extern crate sysctl;
12
14
extern crate tempfile;
13
15
14
16
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
@@ -27,13 +29,30 @@ macro_rules! require_capability {
27
29
}
28
30
}
29
31
32
+ #[ cfg( target_os = "freebsd" ) ]
33
+ macro_rules! skip_if_jailed {
34
+ ( $name: expr) => {
35
+ use sysctl:: CtlValue ;
36
+
37
+ if let CtlValue :: Int ( 1 ) = sysctl:: value( "security.jail.jailed" )
38
+ . unwrap( )
39
+ {
40
+ use std:: io:: Write ;
41
+ let stderr = std:: io:: stderr( ) ;
42
+ let mut handle = stderr. lock( ) ;
43
+ writeln!( handle, "{} cannot run in a jail. Skipping test." , $name)
44
+ . unwrap( ) ;
45
+ return ;
46
+ }
47
+ }
48
+ }
49
+
30
50
macro_rules! skip_if_not_root {
31
51
( $name: expr) => {
32
52
use nix:: unistd:: Uid ;
33
- use std;
34
- use std:: io:: Write ;
35
53
36
54
if !Uid :: current( ) . is_root( ) {
55
+ use std:: io:: Write ;
37
56
let stderr = std:: io:: stderr( ) ;
38
57
let mut handle = stderr. lock( ) ;
39
58
writeln!( handle, "{} requires root privileges. Skipping test." , $name) . unwrap( ) ;
Original file line number Diff line number Diff line change @@ -394,6 +394,13 @@ cfg_if!{
394
394
require_capability!( CAP_SYS_PACCT ) ;
395
395
}
396
396
}
397
+ } else if #[ cfg( target_os = "freebsd" ) ] {
398
+ macro_rules! require_acct{
399
+ ( ) => {
400
+ skip_if_not_root!( "test_acct" ) ;
401
+ skip_if_jailed!( "test_acct" ) ;
402
+ }
403
+ }
397
404
} else {
398
405
macro_rules! require_acct{
399
406
( ) => {
You can’t perform that action at this time.
0 commit comments