The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
fix(ssh): verify runtime archives in homes containing newlines (#37150)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Simone committed
Nov 16, 2026 at 17:20 UTC
12b9845d1c5aec2bfede36b313adfc5098a2fb93
2 files changed
+12
-6
packages/ssh/src/tunnel.test.ts
+10
-4
@@ -340,14 +340,20 @@ describe("ssh tunnel scripts", () => {
340
},
341
);
342
343
- it("names gzip when a host with tar but no gzip cannot unpack the release archive", () => {
343
+ // sha256sum and shasum escape a newline in a file name they print, so the home path has one.
344
+ const checksumTools =
345
+ NodeChildProcess.spawnSync("sh", ["-c", 'command -v "$1"', "sh", "shasum"]).status === 0
346
+ ? ["sha256sum", "shasum"]
347
+ : ["sha256sum"];
348
+ it.each(checksumTools)("names missing gzip after verifying with %s", (checksum) => {
349
const root = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-ssh-runner-"));
350
try {
351
const bin = NodePath.join(root, "bin");
352
const release = NodePath.join(root, "release");
353
+ const home = NodePath.join(root, "home\ncache");
354
const archive = `t3-${ARCHIVE.archiveVersion}-linux-x64.tar.gz`;
355
NodeFS.mkdirSync(bin);
350
- NodeFS.mkdirSync(NodePath.join(root, "home"));
356
+ NodeFS.mkdirSync(home);
357
NodeFS.mkdirSync(NodePath.join(release, "t3"), { recursive: true });
358
NodeFS.writeFileSync(NodePath.join(release, "t3", "t3"), "#!/bin/sh\necho ok\n", {
359
mode: 0o755,
@@ -364,7 +370,7 @@ describe("ssh tunnel scripts", () => {
370
"rm",
371
"grep",
372
"cut",
367
- "sha256sum",
373
+ checksum,
374
"tar",
375
"mv",
376
]) {
@@ -389,7 +395,7 @@ describe("ssh tunnel scripts", () => {
395
NodeFS.writeFileSync(runner, SshTunnel.buildRemoteT3RunnerScript(ARCHIVE));
396
const result = NodeChildProcess.spawnSync(NodePath.join(bin, "sh"), [runner, "--version"], {
397
encoding: "utf8",
392
- env: { HOME: NodePath.join(root, "home"), PATH: bin },
398
+ env: { HOME: home, PATH: bin },
399
});
400
assert.notEqual(result.status, 0);
401
assert.match(result.stderr, /(missing|needs) gzip/);
packages/ssh/src/tunnel.ts
+2
-2
@@ -542,9 +542,9 @@ if ! t3_runtime_ready; then
542
t3_fetch "$T3_RELEASE_BASE_URL/v$T3_ARCHIVE_VERSION/$T3_ARCHIVE" "$T3_STAGING/$T3_ARCHIVE" @@T3_ARCHIVE_DOWNLOAD_SECONDS@@
543
T3_EXPECTED="$(grep " \\*\\{0,1\\}$T3_ARCHIVE$" "$T3_STAGING/SHA256SUMS" | cut -d' ' -f1)"
544
if command -v sha256sum >/dev/null 2>&1; then
545
- T3_ACTUAL="$(sha256sum "$T3_STAGING/$T3_ARCHIVE" | cut -d' ' -f1)"
545
+ T3_ACTUAL="$(sha256sum < "$T3_STAGING/$T3_ARCHIVE" | cut -d' ' -f1)"
546
else
547
- T3_ACTUAL="$(shasum -a 256 "$T3_STAGING/$T3_ARCHIVE" | cut -d' ' -f1)"
547
+ T3_ACTUAL="$(shasum -a 256 < "$T3_STAGING/$T3_ARCHIVE" | cut -d' ' -f1)"
548
fi
549
if [ -z "$T3_EXPECTED" ] || [ "$T3_ACTUAL" != "$T3_EXPECTED" ]; then
550
printf 'Checksum mismatch for %s.\\n' "$T3_ARCHIVE" >&2; exit 1