diff --git a/.gitea/workflows/windows-release.yml b/.gitea/workflows/windows-release.yml index 31185a1..adbb8d4 100644 --- a/.gitea/workflows/windows-release.yml +++ b/.gitea/workflows/windows-release.yml @@ -75,7 +75,19 @@ jobs: working-directory: windows run: nix develop --command rustup toolchain install - # The default members: everything the zip carries, not the app (GPUI) yet. + # The SSH tunnel's end-to-end test runs an sshd of its own. As root (the job's user in the + # runner's container) sshd separates privileges: it needs its empty, root-owned directory + # and its unprivileged user, which the image does not have. + - name: Test prerequisites + run: | + set -euo pipefail + if [ "$(id -u)" = 0 ]; then + install -d -m 0755 -o root -g root /var/empty + id sshd >/dev/null 2>&1 || useradd --system --no-create-home --home-dir /var/empty --shell /usr/sbin/nologin sshd + fi + + # The default members: the service, proxy-ctl, the client and core (the app's crate is + # built by Package). - name: Test working-directory: windows run: nix develop --command cargo test --locked diff --git a/windows/crates/ps-ctl/tests/e2e.rs b/windows/crates/ps-ctl/tests/e2e.rs index 3fae9b2..2da5812 100644 --- a/windows/crates/ps-ctl/tests/e2e.rs +++ b/windows/crates/ps-ctl/tests/e2e.rs @@ -230,7 +230,15 @@ fn an_ssh_tunnel() { ), ) .unwrap(); - let _sshd = Kill(Command::new(&sshd).args(["-D", "-e", "-f"]).arg(dir.join("sshd_config")).stderr(std::fs::File::create(dir.join("sshd.log")).unwrap()).spawn().unwrap()); + let mut sshd = Kill(Command::new(&sshd).args(["-D", "-e", "-f"]).arg(dir.join("sshd_config")).stderr(std::fs::File::create(dir.join("sshd.log")).unwrap()).spawn().unwrap()); + // One that cannot start says why, here (as root it needs its privilege separation: the + // directory /var/empty and the user sshd). + wait_for("sshd", Duration::from_secs(10), || { + if let Ok(Some(status)) = sshd.0.try_wait() { + panic!("sshd exited ({status}):\n{}", std::fs::read_to_string(dir.join("sshd.log")).unwrap_or_default()); + } + std::net::TcpStream::connect(("127.0.0.1", ssh_port)).is_ok() + }); let state = dir.join("state"); std::fs::create_dir_all(&state).unwrap();