(
command: &str,
cwd: &std::path::Path,
sandbox_status: &SandboxStatus,
create_dirs: bool,
)
| 207 | } |
| 208 | |
| 209 | fn prepare_tokio_command( |
| 210 | command: &str, |
| 211 | cwd: &std::path::Path, |
| 212 | sandbox_status: &SandboxStatus, |
| 213 | create_dirs: bool, |
| 214 | ) -> TokioCommand { |
| 215 | if create_dirs { |
| 216 | prepare_sandbox_dirs(cwd); |
| 217 | } |
| 218 | |
| 219 | if let Some(launcher) = build_linux_sandbox_command(command, cwd, sandbox_status) { |
| 220 | let mut prepared = TokioCommand::new(launcher.program); |
| 221 | prepared.args(launcher.args); |
| 222 | prepared.current_dir(cwd); |
| 223 | prepared.envs(launcher.env); |
| 224 | return prepared; |
| 225 | } |
| 226 | |
| 227 | let mut prepared = TokioCommand::new("sh"); |
| 228 | prepared.arg("-lc").arg(command).current_dir(cwd); |
| 229 | if sandbox_status.filesystem_active { |
| 230 | prepared.env("HOME", cwd.join(".sandbox-home")); |
| 231 | prepared.env("TMPDIR", cwd.join(".sandbox-tmp")); |
| 232 | } |
| 233 | prepared |
| 234 | } |
| 235 | |
| 236 | fn prepare_sandbox_dirs(cwd: &std::path::Path) { |
| 237 | let _ = std::fs::create_dir_all(cwd.join(".sandbox-home")); |
no test coverage detected