Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/tools/test_ssh_bulk_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ def capture_popen(cmd, **kwargs):
assert "-" in tar_cmd # stdout
assert "-C" in tar_cmd

# ssh: extract from stdin at /
# ssh: extract from stdin at /, preserving existing dir modes (#17767)
ssh_str = " ".join(ssh_cmd)
assert "ssh" in ssh_str
assert "tar xf - -C /" in ssh_str
assert "tar xf -" in ssh_str
assert "--no-overwrite-dir" in ssh_str
assert "-C /" in ssh_str
assert "testuser@example.com" in ssh_str

def test_mkdir_failure_raises(self, mock_env, tmp_path):
Expand Down
6 changes: 5 additions & 1 deletion tools/environments/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ def _ssh_bulk_upload(self, files: list[tuple[str, str]]) -> None:

tar_cmd = ["tar", "-chf", "-", "-C", staging, "."]
ssh_cmd = self._build_ssh_command()
ssh_cmd.append("tar xf - -C /")
# --no-overwrite-dir prevents tar from overwriting the mode of
# existing directories (e.g. /home/<user>) with the staging
# directory's mode. Without this, a umask 002 produces 0775
# dirs which breaks sshd StrictModes (refuses authorized_keys).
ssh_cmd.append("tar xf - --no-overwrite-dir -C /")

tar_proc = subprocess.Popen(
tar_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
Expand Down
Loading