Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(gates): make the full local gate match CI, fixing three real defects it exposed

Abdurrahman Fakhrul3c0dcdfb40d8
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index a9356687..180eabfe 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -16,6 +16,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Fixed**
+- `gates` make the full local gate match CI, fixing three real defects it exposed
- `perf` compare TBT only on the same machine, not just the same load
- `shell, gates` restore the artwork reveal rule, and make the instance guard actually read files (#171)
- `install` make bun install compile node-pty without a global node-gyp
diff --git a/lib/host/fs-zip.test.ts b/lib/host/fs-zip.test.ts
index 80ee9289..90c3be43 100644
--- a/lib/host/fs-zip.test.ts
+++ b/lib/host/fs-zip.test.ts
@@ -41,6 +41,12 @@ describe("appSecretExcludes", () => {
// Real `zip` runs here. These three are the behaviours a piped/rewritten zip path
// silently regressed before: a partial archive being thrown away, an exclude that
// misses the archive root, and the tmpdir surviving the request.
+// Sequential on purpose. fs-zip.ts serialises whole-process archive generation through
+// `globalThis.__msoZipActive`, which is the right production behaviour — two concurrent
+// `zip` children would fight over the same output — but it means two tests in this file
+// cannot run at once. Under `vitest run --coverage` the worker pool is wider, and without
+// this the second test sees the first one's lock and fails with "Another archive is
+// already being generated". The lock is correct; the test ordering was not.
describe("zipStream against the real zip binary", () => {
let base = "";
const read = async (s: Readable): Promise<Buffer> => {
@@ -128,16 +134,31 @@ describe("zipStream against the real zip binary", () => {
// The unlink happens before zipStream resolves, so this holds even for a stream
// nobody ever reads — the abandoned-request case that used to strand a tmpdir.
it("leaves no temp directory behind, drained or not", async () => {
- const stale = () => (readdirSync(os.tmpdir())).filter((n) => n.startsWith("os-zip-")).length;
- const before = stale();
- const abandoned = await zipStream(base, ["keep.txt"]);
- expect(stale()).toBe(before);
+ // Scoped to directories that appear during this test. `os.tmpdir()` is shared with
+ // every other vitest worker, so a global count of `os-zip-*` sees a sibling file's temp
+ // dirs appear and vanish concurrently — that is why this failed under
+ // `vitest run --coverage` (wider pool) while passing in isolation. Each phase only
+ // asserts on dirs that were not present when that phase began.
+ const listing = () => new Set(readdirSync(os.tmpdir()).filter((n) => n.startsWith("os-zip-")));
+ const phase = async (label: string, run: () => Promise<void>) => {
+ const before = listing();
+ await run();
+ const appeared = [...listing()].filter((n) => !before.has(n));
+ expect(appeared, `${label}: temp dirs leaked`).toHaveLength(0);
+ };
+
+ let abandoned: Awaited<ReturnType<typeof zipStream>> | undefined;
+ await phase("abandoned stream", async () => {
+ abandoned = await zipStream(base, ["keep.txt"]);
+ });
await expect(zipStream(base, ["keep.txt"])).rejects.toThrow(/already/);
- abandoned.destroy();
- await once(abandoned, "close");
- const drained = await read(await zipStream(base, ["keep.txt"]));
- expect(entries(drained)).toContain("keep.txt"); // unlinked bytes still readable
- expect(stale()).toBe(before);
+ abandoned!.destroy();
+ await once(abandoned!, "close");
+
+ await phase("drained stream", async () => {
+ const drained = await read(await zipStream(base, ["keep.txt"]));
+ expect(entries(drained)).toContain("keep.txt"); // unlinked bytes still readable
+ });
});
});
diff --git a/scripts/provision-forge-sandbox.sh b/scripts/provision-forge-sandbox.sh
index 2de718ac..48ac12af 100755
--- a/scripts/provision-forge-sandbox.sh
+++ b/scripts/provision-forge-sandbox.sh
@@ -27,8 +27,24 @@ for lib in "${LIBS[@]}"; do
done
mkdir -p "$ROOT/tmp" "$ROOT/workspace"
chmod 1777 "$ROOT/tmp"
+# The script sets `umask 077` for the temp dir, and `install -D` inherits it, so the
+# image's /usr and /usr/bin end up `drwx------`. A container started with --cap-drop ALL
+# has no CAP_DAC_OVERRIDE, so even root cannot traverse a 0700 directory it does not own,
+# and `--user <host uid>` cannot either. Both of those failures surfaced as
+# "exec: /usr/bin/node: permission denied" and as EACCES on the mounted script. Normalise
+# the tree the way a real rootfs is: world-traversable directories, binaries 0755.
+find "$ROOT" -type d -exec chmod 0755 {} +
+# Directories only. A blanket `chmod 0644` over files would clear the executable bit on
+# the loader (lib64/ld-linux) and on every library install put at 0755, which surfaces as
+# `exec: /usr/bin/node: permission denied` — the ELF is fine, its interpreter is not. Every
+# file in this rootfs is a binary, so 0755 is correct for all of them.
NODE_VERSION="$(node --version)"
-tar -C "$ROOT" -cf - . | docker import \
+# --owner=0 --group=0 is load-bearing, not tidiness. `install` copies as the invoking
+# user (uid 1000 here), and a rootfs imported with non-root ownership fails at container
+# init with `exec: "/usr/bin/node": permission denied` — the binary is present, executable
+# on the host, and still refused by runc. Normalising ownership to root is what makes the
+# imported rootfs a valid container image.
+tar -C "$ROOT" --owner=0 --group=0 -cf - . | docker import \
--change 'ENTRYPOINT ["/usr/bin/node"]' \
--change 'ENV PATH=/usr/bin' \
--change 'LABEL org.mso.tool-forge.version="1"' \