(
server: &str,
name: &str,
command: &[String],
tty: bool,
tls: &TlsOptions,
replace_process: bool,
)
| 522 | } |
| 523 | |
| 524 | async fn sandbox_exec_with_mode( |
| 525 | server: &str, |
| 526 | name: &str, |
| 527 | command: &[String], |
| 528 | tty: bool, |
| 529 | tls: &TlsOptions, |
| 530 | replace_process: bool, |
| 531 | ) -> Result<()> { |
| 532 | if command.is_empty() { |
| 533 | return Err(miette::miette!("no command provided")); |
| 534 | } |
| 535 | |
| 536 | let session = ssh_session_config(server, name, tls).await?; |
| 537 | let mut ssh = ssh_base_command(&session.proxy_command); |
| 538 | |
| 539 | if tty { |
| 540 | ssh.arg("-tt") |
| 541 | .arg("-o") |
| 542 | .arg("RequestTTY=force") |
| 543 | .arg("-o") |
| 544 | .arg("SetEnv=TERM=xterm-256color"); |
| 545 | } else { |
| 546 | ssh.arg("-T").arg("-o").arg("RequestTTY=no"); |
| 547 | } |
| 548 | |
| 549 | let command_str = command |
| 550 | .iter() |
| 551 | .map(|arg| shell_escape(arg)) |
| 552 | .collect::<Vec<_>>() |
| 553 | .join(" "); |
| 554 | |
| 555 | ssh.arg("sandbox") |
| 556 | .arg(command_str) |
| 557 | .stdin(Stdio::inherit()) |
| 558 | .stdout(Stdio::inherit()) |
| 559 | .stderr(Stdio::inherit()); |
| 560 | |
| 561 | tokio::task::spawn_blocking(move || exec_or_wait(ssh, tty && replace_process)) |
| 562 | .await |
| 563 | .into_diagnostic()??; |
| 564 | |
| 565 | Ok(()) |
| 566 | } |
| 567 | |
| 568 | /// Execute a command in a sandbox via SSH. |
| 569 | pub async fn sandbox_exec( |
no test coverage detected