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 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d9705cd3a
commit
69e70d6f74
2 files changed
+22
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user