Skip to content

Commit e3815c1

Browse files
fix(server): check only the service executable for characters systemd refuses
The earlier check also refused control characters in quoted Environment values such as T3CODE_INSTALL_BIN_DIR, which systemd accepts, so a tab there now failed mid-install and status reported the unit as stale. Only the executable path, which lives under the T3 home, is checked now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 21f384c commit e3815c1

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
628628
"preserves the custom install bin directory in the installed service on %s",
629629
(platform) =>
630630
Effect.gen(function* () {
631-
const installBinDir = '/custom/T3 & <100%>/"quoted"\\bin';
631+
const installBinDir = '/custom/T3\t& <100%>/"quoted"\\bin';
632632
const { service, makeService, fs } = yield* makeHarness(
633633
platform,
634634
"",
@@ -640,8 +640,8 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
640640
const unit = yield* fs.readFileString(plan.unitPath);
641641
expect(unit).toContain(
642642
platform === "linux"
643-
? 'Environment=T3CODE_INSTALL_BIN_DIR="/custom/T3 & <100%%>/\\"quoted\\"\\\\bin"'
644-
: '<key>T3CODE_INSTALL_BIN_DIR</key>\n <string>/custom/T3 &amp; &lt;100%&gt;/"quoted"\\bin</string>',
643+
? 'Environment=T3CODE_INSTALL_BIN_DIR="/custom/T3\t& <100%%>/\\"quoted\\"\\\\bin"'
644+
: '<key>T3CODE_INSTALL_BIN_DIR</key>\n <string>/custom/T3\t&amp; &lt;100%&gt;/"quoted"\\bin</string>',
645645
);
646646
expect((yield* service.status).current).toBe(true);
647647

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ export interface BootServicePlan {
9090
readonly handedOff?: boolean;
9191
}
9292

93-
// systemd refuses an executable with a quote or backslash even when quoted, and a unit
94-
// file has no way to carry a raw control character such as a newline.
93+
// systemd refuses an executable with a quote, backslash or control character even when
94+
// quoted. The executable lives under the T3 home, so this also catches a home with a newline.
9595
const systemdUnsafeValue = (plan: BootServicePlan) =>
96-
[plan.baseDir, plan.logPath, plan.installBinDir ?? "", ...plan.program].some((value) =>
97-
/[\x00-\x1f\x7f]/.test(value),
98-
) || /["'\\]/.test(plan.program[0] ?? "");
96+
/[\x00-\x1f\x7f"'\\]/.test(plan.program[0] ?? "");
9997

10098
/** Service units cannot rely on the user's shell or PATH. */
10199
export function renderBootServiceUnit(plan: BootServicePlan): string {

0 commit comments

Comments
 (0)