Skip to content

Commit 5589ddf

Browse files
rookmateclaude
andcommitted
fix(server): escape $ in the base dir handed to systemd-run
systemd expands $VAR in command arguments, so a literal ${...} in the T3 home would reach the transient install altered. The executable path is not expanded and stays as is. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 1d31934 commit 5589ddf

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎apps/server/src/cloud/bootService.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,27 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
657657
}),
658658
);
659659

660+
it.effect("keeps a literal $ in the base dir it hands to systemd-run", () =>
661+
Effect.gen(function* () {
662+
const { service, commands, makeService } = yield* makeHarness();
663+
const fs = yield* FileSystem.FileSystem;
664+
const path = yield* Path.Path;
665+
yield* service.install();
666+
commands.length = 0;
667+
668+
const home = yield* fs.makeTempDirectoryScoped({ prefix: "t3-dollar-" });
669+
const baseDir = path.join(home, "${UNSET}", ".t3");
670+
const inside = yield* makeService(undefined, "1.2.4", baseDir, true);
671+
yield* inside.install();
672+
673+
const handoff = commands.find((command) => command.startsWith("systemd-run "));
674+
expect(handoff).toContain(
675+
`${pinnedRuntimePaths(path, baseDir, "1.2.4", "linux").entryPath} service install`,
676+
);
677+
expect(handoff).toContain(`--base-dir ${path.join(home, "$${UNSET}", ".t3")}`);
678+
}),
679+
);
680+
660681
it.effect("restarts from inside the service by queuing the restart", () =>
661682
Effect.gen(function* () {
662683
const { service, commands, makeService } = yield* makeHarness();

‎apps/server/src/cloud/bootService.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
867867
"service",
868868
"install",
869869
"--base-dir",
870-
input.baseDir,
870+
// systemd expands $VAR in arguments (not in the executable path).
871+
input.baseDir.replaceAll("$", () => "$$"),
871872
...(options?.allowDowngrade === true ? ["--allow-downgrade"] : []),
872873
]);
873874
return plan;

0 commit comments

Comments
 (0)