File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ fn get_tests() -> Vec<&'static dyn TestCase> {
15
15
extend_lifetime( simple:: TIdle ) ,
16
16
extend_lifetime( simple:: TRet1 ) ,
17
17
extend_lifetime( simple:: TOom ) ,
18
+ extend_lifetime( simple:: TSecurity ) ,
18
19
]
19
20
}
20
21
Original file line number Diff line number Diff line change @@ -140,6 +140,38 @@ impl crate::TestCase for TOom {
140
140
}
141
141
}
142
142
143
+ pub ( crate ) struct TSecurity ;
144
+ impl crate :: TestCase for TSecurity {
145
+ fn name ( & self ) -> & ' static str {
146
+ "test_security_restrictions"
147
+ }
148
+ fn description ( & self ) -> & ' static str {
149
+ "verifies that isolated program can not make certain bad things"
150
+ }
151
+ fn test ( & self ) -> ! {
152
+ // Check we can not read pid1's environment.
153
+ let err = std:: fs:: read ( "/proc/1/environ" ) . unwrap_err ( ) ;
154
+ assert_eq ! ( err. kind( ) , std:: io:: ErrorKind :: PermissionDenied ) ;
155
+ // Check we can not create mounts.
156
+ std:: fs:: create_dir ( "/prcfs" ) . unwrap ( ) ;
157
+ let err = nix:: mount:: mount (
158
+ Some ( "proc" ) ,
159
+ "/prcfs" ,
160
+ Some ( "proc" ) ,
161
+ nix:: mount:: MsFlags :: empty ( ) ,
162
+ None :: < & str > ,
163
+ )
164
+ . unwrap_err ( ) ;
165
+ assert ! ( matches!( err, nix:: Error :: Sys ( nix:: errno:: Errno :: EPERM ) ) ) ;
166
+ std:: process:: exit ( 24 )
167
+ }
168
+ fn check ( & self , cp : & mut dyn minion:: ChildProcess , d : minion:: DominionRef ) {
169
+ super :: assert_exit_code ( cp, 24 ) ;
170
+ super :: assert_empty ( & mut cp. stdout ( ) . unwrap ( ) ) ;
171
+ super :: assert_empty ( & mut cp. stderr ( ) . unwrap ( ) ) ;
172
+ }
173
+ }
174
+
143
175
fn exceed_time_limit ( ) -> ! {
144
176
loop {
145
177
unsafe {
You can’t perform that action at this time.
0 commit comments