From 69e70d6f74fb2ec9d25efd8491185e1b737afaef Mon Sep 17 00:00:00 2001 From: faumaray Date: Tue, 27 Oct 2026 15:35:49 +0300 Subject: [PATCH] windows: CI gives the SSH test's sshd its privilege separation The job runs as root in the runner's container, where sshd separates privileges and needs /var/empty (root's, not writable by others) and the sshd user; the image lacks the directory, so the test's sshd exited and an_ssh_tunnel failed. A step makes both. The test now waits for its sshd and, should it exit, says why. Checked as root in docker.gitea.com/runner-images:ubuntu-24.04: the end-to-end tests pass. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/windows-release.yml | 14 +++++++++++++- windows/crates/ps-ctl/tests/e2e.rs | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) 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();