Run an `ip` command on the host.
(args: &[&str])
| 469 | |
| 470 | /// Run an `ip` command on the host. |
| 471 | fn run_ip(args: &[&str]) -> Result<()> { |
| 472 | let ip_path = find_trusted_binary("ip", IP_SEARCH_PATHS)?; |
| 473 | |
| 474 | debug!(command = %format!("{ip_path} {}", args.join(" ")), "Running ip command"); |
| 475 | |
| 476 | let output = Command::new(ip_path) |
| 477 | .args(args) |
| 478 | .output() |
| 479 | .into_diagnostic()?; |
| 480 | |
| 481 | if !output.status.success() { |
| 482 | let stderr = String::from_utf8_lossy(&output.stderr); |
| 483 | return Err(miette::miette!( |
| 484 | "{ip_path} {} failed: {}", |
| 485 | args.join(" "), |
| 486 | stderr.trim() |
| 487 | )); |
| 488 | } |
| 489 | |
| 490 | Ok(()) |
| 491 | } |
| 492 | |
| 493 | /// Run an `ip` command inside a network namespace via `nsenter --net=`. |
| 494 | /// |
no test coverage detected