From 5c0e38a5c9ab678d67e50766ea7dd8e4db6d34cd Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sat, 17 Oct 2026 05:14:50 -0700 Subject: [PATCH] fix(openfleet): keep the settings file's exact mode across a rewrite (#240) writeSettings created its temp file with the original mode, but the create mode is filtered through the umask, so a rewrite could leave the settings file with fewer permission bits than it had. It now chmods the temp file to the mode outright before the rename. Found and fixed by a moshcode work agent (fleet sweep); verify: npx vitest run ./src/hooks-install.test.ts (packages/openfleet). Co-authored-by: Claude Opus 5.5 --- packages/openfleet/src/hooks-install.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/openfleet/src/hooks-install.ts b/packages/openfleet/src/hooks-install.ts index d29fcc86..c35e1261 100644 --- a/packages/openfleet/src/hooks-install.ts +++ b/packages/openfleet/src/hooks-install.ts @@ -15,7 +15,7 @@ * command is marker enough. */ -import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs"; +import { chmodSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs"; import { homedir } from "node:os"; import { dirname, join } from "node:path"; import type { Env } from "./store.js"; @@ -117,6 +117,9 @@ export function writeSettings(file: string, data: Json, mode: number): void { // would otherwise leave it truncated. const tmp = `${file}.logicsrc-${process.pid}`; writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { mode }); + // The create mode is filtered through the umask; set it outright so the + // file keeps exactly the mode it had. + chmodSync(tmp, mode); renameSync(tmp, file); }