1
1
#![ cfg_attr( minion_nightly, feature( unsafe_block_in_unsafe_fn) ) ]
2
2
#![ cfg_attr( minion_nightly, warn( unsafe_op_in_unsafe_fn) ) ]
3
- use minion:: { self , Dominion as _ } ;
3
+ use minion:: { self } ;
4
4
use std:: {
5
5
ffi:: { CStr , OsStr , OsString } ,
6
6
mem:: { self } ,
@@ -50,7 +50,7 @@ unsafe fn get_string(buf: *const c_char) -> OsString {
50
50
s. to_os_string ( )
51
51
}
52
52
53
- pub struct Backend ( Box < dyn minion:: Backend > ) ;
53
+ pub struct Backend ( Box < dyn minion:: erased :: Backend > ) ;
54
54
55
55
/// # Safety
56
56
/// Must be called once
@@ -69,7 +69,7 @@ pub unsafe extern "C" fn minion_lib_init() -> ErrorCode {
69
69
#[ no_mangle]
70
70
#[ must_use]
71
71
pub extern "C" fn minion_backend_create ( out : & mut * mut Backend ) -> ErrorCode {
72
- let backend = Backend ( minion:: setup ( ) ) ;
72
+ let backend = Backend ( minion:: erased :: setup ( ) ) ;
73
73
let backend = Box :: new ( backend) ;
74
74
* out = Box :: into_raw ( backend) ;
75
75
ErrorCode :: Ok
@@ -93,7 +93,7 @@ pub struct TimeSpec {
93
93
}
94
94
95
95
#[ repr( C ) ]
96
- pub struct DominionOptions {
96
+ pub struct SandboxOptions {
97
97
pub cpu_time_limit : TimeSpec ,
98
98
pub real_time_limit : TimeSpec ,
99
99
pub process_limit : u32 ,
@@ -103,16 +103,16 @@ pub struct DominionOptions {
103
103
}
104
104
105
105
#[ derive( Clone ) ]
106
- pub struct Dominion ( minion:: DominionRef ) ;
106
+ pub struct Sandbox ( Box < dyn minion:: erased :: Sandbox > ) ;
107
107
108
108
/// # Safety
109
109
/// `out` must be valid
110
110
#[ no_mangle]
111
- pub unsafe extern "C" fn minion_dominion_check_cpu_tle (
112
- dominion : & Dominion ,
111
+ pub unsafe extern "C" fn minion_sandbox_check_cpu_tle (
112
+ sandbox : & Sandbox ,
113
113
out : * mut bool ,
114
114
) -> ErrorCode {
115
- match dominion . 0 . check_cpu_tle ( ) {
115
+ match sandbox . 0 . check_cpu_tle ( ) {
116
116
Ok ( st) => {
117
117
unsafe {
118
118
out. write ( st) ;
@@ -126,11 +126,11 @@ pub unsafe extern "C" fn minion_dominion_check_cpu_tle(
126
126
/// # Safety
127
127
/// `out` must be valid
128
128
#[ no_mangle]
129
- pub unsafe extern "C" fn minion_dominion_check_real_tle (
130
- dominion : & Dominion ,
129
+ pub unsafe extern "C" fn minion_sandbox_check_real_tle (
130
+ sandbox : & Sandbox ,
131
131
out : * mut bool ,
132
132
) -> ErrorCode {
133
- match dominion . 0 . check_real_tle ( ) {
133
+ match sandbox . 0 . check_real_tle ( ) {
134
134
Ok ( st) => {
135
135
unsafe {
136
136
out. write ( st) ;
@@ -142,8 +142,8 @@ pub unsafe extern "C" fn minion_dominion_check_real_tle(
142
142
}
143
143
144
144
#[ no_mangle]
145
- pub extern "C" fn minion_dominion_kill ( dominion : & Dominion ) -> ErrorCode {
146
- match dominion . 0 . kill ( ) {
145
+ pub extern "C" fn minion_sandbox_kill ( sandbox : & Sandbox ) -> ErrorCode {
146
+ match sandbox . 0 . kill ( ) {
147
147
Ok ( _) => ErrorCode :: Ok ,
148
148
Err ( _) => ErrorCode :: Unknown ,
149
149
}
@@ -153,29 +153,29 @@ pub extern "C" fn minion_dominion_kill(dominion: &Dominion) -> ErrorCode {
153
153
/// Provided arguments must be well-formed
154
154
#[ no_mangle]
155
155
#[ must_use]
156
- pub unsafe extern "C" fn minion_dominion_create (
156
+ pub unsafe extern "C" fn minion_sandbox_create (
157
157
backend : & Backend ,
158
- options : DominionOptions ,
159
- out : & mut * mut Dominion ,
158
+ options : SandboxOptions ,
159
+ out : & mut * mut Sandbox ,
160
160
) -> ErrorCode {
161
161
let mut exposed_paths = Vec :: new ( ) ;
162
162
unsafe {
163
163
let mut p = options. shared_directories ;
164
164
while !( * p) . host_path . is_null ( ) {
165
- let opt = minion:: PathExpositionOptions {
165
+ let opt = minion:: SharedDir {
166
166
src : get_string ( ( * p) . host_path ) . into ( ) ,
167
167
dest : get_string ( ( * p) . sandbox_path ) . into ( ) ,
168
- access : match ( * p) . kind {
169
- SharedDirectoryAccessKind :: Full => minion:: DesiredAccess :: Full ,
170
- SharedDirectoryAccessKind :: Readonly => minion:: DesiredAccess :: Readonly ,
168
+ kind : match ( * p) . kind {
169
+ SharedDirectoryAccessKind :: Full => minion:: SharedDirKind :: Full ,
170
+ SharedDirectoryAccessKind :: Readonly => minion:: SharedDirKind :: Readonly ,
171
171
} ,
172
172
} ;
173
173
exposed_paths. push ( opt) ;
174
174
p = p. offset ( 1 ) ;
175
175
}
176
176
}
177
177
let isolation_root = unsafe { get_string ( options. isolation_root ) } . into ( ) ;
178
- let opts = minion:: DominionOptions {
178
+ let opts = minion:: SandboxOptions {
179
179
max_alive_process_count : options. process_limit as _ ,
180
180
memory_limit : u64:: from ( options. memory_limit ) ,
181
181
cpu_time_limit : std:: time:: Duration :: new (
@@ -189,20 +189,20 @@ pub unsafe extern "C" fn minion_dominion_create(
189
189
isolation_root,
190
190
exposed_paths,
191
191
} ;
192
- let d = backend. 0 . new_dominion ( opts) ;
192
+ let d = backend. 0 . new_sandbox ( opts) ;
193
193
let d = d. unwrap ( ) ;
194
194
195
- let dw = Dominion ( d) ;
195
+ let dw = Sandbox ( d) ;
196
196
* out = Box :: into_raw ( Box :: new ( dw) ) ;
197
197
ErrorCode :: Ok
198
198
}
199
199
200
200
/// # Safety
201
- /// `dominion ` must be pointer, returned by `minion_dominion_create `.
201
+ /// `sandbox ` must be pointer, returned by `minion_sandbox_create `.
202
202
#[ no_mangle]
203
203
#[ must_use]
204
- pub unsafe extern "C" fn minion_dominion_free ( dominion : * mut Dominion ) -> ErrorCode {
205
- let b = unsafe { Box :: from_raw ( dominion ) } ;
204
+ pub unsafe extern "C" fn minion_sandbox_free ( sandbox : * mut Sandbox ) -> ErrorCode {
205
+ let b = unsafe { Box :: from_raw ( sandbox ) } ;
206
206
mem:: drop ( b) ;
207
207
ErrorCode :: Ok
208
208
}
@@ -242,7 +242,7 @@ pub struct ChildProcessOptions {
242
242
pub argv : * const * const c_char ,
243
243
pub envp : * const EnvItem ,
244
244
pub stdio : StdioHandleSet ,
245
- pub dominion : * mut Dominion ,
245
+ pub sandbox : * mut Sandbox ,
246
246
pub workdir : * const c_char ,
247
247
}
248
248
@@ -269,7 +269,7 @@ pub static SHARED_DIRECTORY_ACCESS_FIN: SharedDirectoryAccess = SharedDirectoryA
269
269
sandbox_path : std:: ptr:: null ( ) ,
270
270
} ;
271
271
272
- pub struct ChildProcess ( Box < dyn minion:: ChildProcess > ) ;
272
+ pub struct ChildProcess ( Box < dyn minion:: erased :: ChildProcess > ) ;
273
273
274
274
/// # Safety
275
275
/// Provided `options` must be well-formed
@@ -314,7 +314,7 @@ pub unsafe extern "C" fn minion_cp_spawn(
314
314
path : get_string ( options. image_path ) . into ( ) ,
315
315
arguments,
316
316
environment,
317
- dominion : ( * options. dominion ) . 0 . clone ( ) ,
317
+ sandbox : ( * options. sandbox ) . 0 . clone ( ) ,
318
318
stdio,
319
319
pwd : get_string ( options. workdir ) . into ( ) ,
320
320
}
0 commit comments