Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(release): normalize staged module permissions

Steven Enamakel6e6c405f6316
diff --git a/scripts/release/stage-modules.mjs b/scripts/release/stage-modules.mjs
index ac3a8457ef..a61496b563 100644
--- a/scripts/release/stage-modules.mjs
+++ b/scripts/release/stage-modules.mjs
@@ -18,6 +18,8 @@
import { createHash } from "node:crypto";
import { execFileSync } from "node:child_process";
import {
+ chmodSync,
+ lstatSync,
mkdirSync,
readFileSync,
readdirSync,
@@ -157,6 +159,27 @@ export function extractArchive(archive, dir) {
execFileSync("tar", ["-xzf", archive, "-C", dir], { stdio: "pipe" });
}
+/**
+ * Reset every directory under `root` (and `root` itself) to 0755 and every
+ * regular file to 0644. tinybus refuses a module whose directory, or any
+ * ancestor of it, another account can write ("module directory is writable by
+ * another user"), and the staged tree ships in the AppImage/deb as-is, so it
+ * must not inherit the build host's umask (002 on Ubuntu) or the release
+ * tarball's mode bits. Libraries need no execute bit: `dlopen` maps them
+ * without it, and Debian policy ships shared objects 0644. Symlinks are left
+ * alone; `chmod` would follow them out of the tree.
+ */
+export function normalizeStagedPermissions(root) {
+ const stat = lstatSync(root);
+ if (stat.isSymbolicLink()) return;
+ if (stat.isDirectory()) {
+ chmodSync(root, 0o755);
+ for (const name of readdirSync(root)) normalizeStagedPermissions(join(root, name));
+ } else if (stat.isFile()) {
+ chmodSync(root, 0o644);
+ }
+}
+
const DOWNLOAD_TIMEOUT_MS = 120_000;
/**
@@ -212,6 +235,7 @@ export async function stageModules({
if (!keepsArchive(asset.hostKey)) replaceArchiveWithMarker(archive, actual);
console.log(`[bundled-modules] staged ${asset.id} ${asset.version} (${asset.hostKey})`);
}
+ normalizeStagedPermissions(output);
console.log(`[bundled-modules] staged ${assets.length} verified releases for ${hostKey}`);
return output;
}