@@ -24,13 +24,15 @@ const SECCOMP: &str = include_str!("seccomp.json");
24
24
25
25
// determine if the container engine is docker. this fixes issues with
26
26
// any aliases (#530), and doesn't fail if an executable suffix exists.
27
- fn get_is_docker ( ce : std:: path:: PathBuf , verbose : bool ) -> Result < bool > {
27
+ fn get_engine_type ( ce : std:: path:: PathBuf , verbose : bool ) -> Result < ( bool , bool ) > {
28
28
let stdout = Command :: new ( ce)
29
29
. arg ( "--help" )
30
30
. run_and_get_stdout ( verbose) ?
31
31
. to_lowercase ( ) ;
32
32
33
- Ok ( stdout. contains ( "docker" ) && !stdout. contains ( "emulate" ) )
33
+ let is_docker = stdout. contains ( "docker" ) && !stdout. contains ( "emulate" ) ;
34
+ let is_podman = stdout. contains ( "podman" ) ;
35
+ Ok ( ( is_docker, is_podman) )
34
36
}
35
37
36
38
fn get_container_engine ( ) -> Result < std:: path:: PathBuf , which:: Error > {
@@ -144,7 +146,8 @@ pub fn run(
144
146
let runner = config. runner ( target) ?;
145
147
146
148
let mut docker = docker_command ( "run" ) ?;
147
- let is_docker = get_is_docker ( get_container_engine ( ) . unwrap ( ) , verbose) ?;
149
+ #[ allow( unused_variables) ] // is_podman, target_os = "windows"
150
+ let ( is_docker, is_podman) = get_engine_type ( get_container_engine ( ) . unwrap ( ) , verbose) ?;
148
151
149
152
for ref var in config. env_passthrough ( target) ? {
150
153
validate_env_var ( var) ?;
@@ -195,18 +198,31 @@ pub fn run(
195
198
196
199
// docker uses seccomp now on all installations
197
200
if target. needs_docker_seccomp ( ) {
198
- let path = env:: current_dir ( )
199
- . wrap_err ( "couldn't get current directory" ) ?
200
- . canonicalize ( )
201
- . wrap_err_with ( || "when canonicalizing current_dir" . to_string ( ) ) ?
202
- . join ( "target" )
203
- . join ( target. triple ( ) )
204
- . join ( "seccomp.json" ) ;
205
- if !path. exists ( ) {
206
- write_file ( & path, false ) ?. write_all ( SECCOMP . as_bytes ( ) ) ?;
207
- }
201
+ let seccomp = if is_docker && cfg ! ( target_os = "windows" ) {
202
+ // docker on windows fails due to a bug in reading the profile
203
+ // https://github.com/docker/for-win/issues/12760
204
+ "unconfined" . to_string ( )
205
+ } else {
206
+ #[ allow( unused_mut) ] // target_os = "windows"
207
+ let mut path = env:: current_dir ( )
208
+ . wrap_err ( "couldn't get current directory" ) ?
209
+ . canonicalize ( )
210
+ . wrap_err_with ( || "when canonicalizing current_dir" . to_string ( ) ) ?
211
+ . join ( "target" )
212
+ . join ( target. triple ( ) )
213
+ . join ( "seccomp.json" ) ;
214
+ if !path. exists ( ) {
215
+ write_file ( & path, false ) ?. write_all ( SECCOMP . as_bytes ( ) ) ?;
216
+ }
217
+ #[ cfg( target_os = "windows" ) ]
218
+ if is_podman {
219
+ // podman weirdly expects a WSL path here, and fails otherwise
220
+ path = wslpath ( & path, verbose) ?;
221
+ }
222
+ path. display ( ) . to_string ( )
223
+ } ;
208
224
209
- docker. args ( & [ "--security-opt" , & format ! ( "seccomp={}" , path . display ( ) ) ] ) ;
225
+ docker. args ( & [ "--security-opt" , & format ! ( "seccomp={}" , seccomp ) ] ) ;
210
226
}
211
227
212
228
// We need to specify the user for Docker, but not for Podman.
0 commit comments