Skip to content

Commit ab148a0

Browse files
committed
fixup! Replace wireguard-go with GotaTun in test-manager
1 parent 169f016 commit ab148a0

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

test/test-manager/src/container.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#![cfg(target_os = "linux")]
2-
3-
use nix::unistd::geteuid;
4-
use tokio::process::Command;
5-
61
/// Re-launch self with rootlesskit if we're not root.
72
/// Allows for rootless and containerized networking.
83
/// The VNC port is published to localhost.
4+
#[cfg(target_os = "linux")]
95
pub async fn relaunch_with_rootlesskit(vnc_port: Option<u16>) {
6+
use nix::unistd::geteuid;
7+
use tokio::process::Command;
8+
109
// check if user is root (`man getuid`).
1110
if geteuid().is_root() {
1211
return;
@@ -44,3 +43,23 @@ pub async fn relaunch_with_rootlesskit(vnc_port: Option<u16>) {
4443

4544
std::process::exit(status.code().unwrap_or(1));
4645
}
46+
47+
#[cfg(target_os = "macos")]
48+
async fn relaunch_with_sudo() {
49+
// check if user is root (`man getuid`).
50+
if nix::unistd::geteuid().is_root() {
51+
return;
52+
}
53+
let mut cmd = tokio::process::Command::new("sudo");
54+
cmd.arg("--preserve-env");
55+
cmd.args(std::env::args());
56+
57+
log::info!("Root privileges required. Re-launching with sudo.");
58+
eprintln!("{cmd:?}");
59+
60+
let status = cmd.status().await.unwrap_or_else(|e| {
61+
panic!("failed to execute [{cmd:?}]: {e}");
62+
});
63+
64+
std::process::exit(status.code().unwrap_or(1));
65+
}

test/test-manager/src/main.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::net::IpAddr;
1414
use std::{net::SocketAddr, path::PathBuf, time::Duration};
1515

1616
use anyhow::{Context, Ok, Result};
17-
use clap::{Parser, builder::PossibleValuesParser};
17+
use clap::{builder::PossibleValuesParser, Parser};
1818
use config::ConfigFile;
1919
use package::TargetInfo;
2020
use tests::{config::TEST_CONFIG, get_filtered_tests};
@@ -280,7 +280,7 @@ async fn inner_main() -> Result<()> {
280280
container::relaunch_with_rootlesskit(vnc).await;
281281

282282
#[cfg(target_os = "macos")]
283-
relaunch_with_sudo().await;
283+
container::relaunch_with_sudo().await;
284284

285285
let mut config = config.clone();
286286
config.runtime_opts.keep_changes = keep_changes;
@@ -316,7 +316,7 @@ async fn inner_main() -> Result<()> {
316316
container::relaunch_with_rootlesskit(vnc).await;
317317

318318
#[cfg(target_os = "macos")]
319-
relaunch_with_sudo().await;
319+
container::relaunch_with_sudo().await;
320320

321321
let mut config = config.clone();
322322
config.runtime_opts.display = match (display, vnc.is_some()) {
@@ -441,22 +441,3 @@ async fn inner_main() -> Result<()> {
441441
}
442442
}
443443
}
444-
445-
async fn relaunch_with_sudo() {
446-
// check if user is root (`man getuid`).
447-
if nix::unistd::geteuid().is_root() {
448-
return;
449-
}
450-
let mut cmd = tokio::process::Command::new("sudo");
451-
cmd.arg("--preserve-env");
452-
cmd.args(std::env::args());
453-
454-
log::info!("Root privileges required. Re-launching with sudo.");
455-
eprintln!("{cmd:?}");
456-
457-
let status = cmd.status().await.unwrap_or_else(|e| {
458-
panic!("failed to execute [{cmd:?}]: {e}");
459-
});
460-
461-
std::process::exit(status.code().unwrap_or(1));
462-
}

0 commit comments

Comments
 (0)