From 7a5a6172c5ec69b974aba9809a3e28499581f1bf Mon Sep 17 00:00:00 2001 From: James Ross Date: Fri, 13 Nov 2026 15:09:48 -0800 Subject: [PATCH 1/2] Put devrun's TMPDIR on the scratch volume so doctests can run rustdoc builds and runs each doctest in TMPDIR, and Docker mounts --tmpfs /tmp noexec, so Bunny's cargo test --doc failed with "Permission denied ... maybe your tempdir is mounted with noexec?". TMPDIR is now /scratch/tmp, created before the run and fetch commands; /tmp stays a size-limited noexec tmpfs. The integration probe runs an executable from TMPDIR. Agent-Session: abe7b061-b12e-4785-a5bf-3fb4b6ce1a0c Agent-Tool: Claude Code --- bin/devrun | 7 +++++-- docs/hygiene.md | 3 ++- tests/integration-devrun | 1 + tests/test_devrun.py | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/devrun b/bin/devrun index 98dfced..db647cd 100755 --- a/bin/devrun +++ b/bin/devrun @@ -326,7 +326,7 @@ mode="$1"; shift export_patch="$1"; shift cd /work git_q() { git -c user.name=devrun -c user.email=devrun@invalid -c commit.gpgsign=false -c init.defaultBranch=main "$@"; } -mkdir -p "$HOME" +mkdir -p "$HOME" "$TMPDIR" if [ "$mode" = history ]; then git_q init -q . git_q fetch -q /scratch/in/history.bundle '+refs/*:refs/devrun/*' @@ -364,7 +364,7 @@ if [ "$1" = 1 ]; then find /target -mindepth 1 -delete; fi # Phase 1. Runs no repository-chosen code: the copy has no cargo config or toolchain file, and the # environment pins the compiler and clears the wrappers (docs/hygiene.md section 3). -FETCH_COMMAND = ["bash", "-c", 'mkdir -p "$HOME" && exec cargo fetch --locked'] +FETCH_COMMAND = ["bash", "-c", 'mkdir -p "$HOME" "$TMPDIR" && exec cargo fetch --locked'] class Docker: @@ -409,6 +409,9 @@ class Docker: "--mount", f"type=volume,src={self.project}-work,dst=/work", "--mount", f"type=volume,src={self.project}-scratch,dst=/scratch", "--env", "HOME=/tmp/home", + # Docker mounts --tmpfs noexec, so test binaries (rustdoc's doctests) cannot run + # from /tmp. TMPDIR is on the scratch volume, which allows execution. + "--env", "TMPDIR=/scratch/tmp", "--workdir", "/work"] for k, v in (env or {}).items(): args += ["--env", f"{k}={v}"] diff --git a/docs/hygiene.md b/docs/hygiene.md index 60ed5eb..3b81f92 100644 --- a/docs/hygiene.md +++ b/docs/hygiene.md @@ -51,7 +51,8 @@ image build and a smoke test. - Non-root user with a fixed UID (`10001`), `--user 10001:10001`. - `--cap-drop ALL`, `--security-opt no-new-privileges`. - `--read-only` root filesystem. Writable places: `/work` (the copy, at the - root of the work volume), `/scratch`, `/tmp` (tmpfs with a size limit), the + root of the work volume), `/scratch` (which also holds `TMPDIR`, `/scratch/tmp`, + because Docker mounts the `/tmp` tmpfs `noexec`), `/tmp` (tmpfs with a size limit), the other named volumes in section 5, and Docker's own `/dev/shm` and `/dev/mqueue`. - **No writable directory above the copy.** Cargo reads `.cargo/config.toml` in diff --git a/tests/integration-devrun b/tests/integration-devrun index aa1c0a5..91802ec 100755 --- a/tests/integration-devrun +++ b/tests/integration-devrun @@ -44,6 +44,7 @@ probe='set -e test "$(id -u)" = 10001 test "$(pwd)" = /work test -d "$HOME" && touch "$HOME/probe" +test "$TMPDIR" = /scratch/tmp && printf "#!/bin/sh\necho ran\n" > "$TMPDIR/exe" && chmod +x "$TMPDIR/exe" && test "$("$TMPDIR/exe")" = ran if touch /devrun-probe 2>/dev/null; then echo "the parent of /work is writable" >&2; exit 18; fi test -f README && test -L README.link && test "$(cat README.link | head -1)" = hello test -d .git # created inside the container by devrun, empty baseline only diff --git a/tests/test_devrun.py b/tests/test_devrun.py index c84be11..8f0de50 100644 --- a/tests/test_devrun.py +++ b/tests/test_devrun.py @@ -211,6 +211,7 @@ def test_run_container_mounts_the_copy_at_work_with_home_set(self): create = self.calls[-1] self.assertIn("type=volume,src=geordi-work,dst=/work", create) self.assertIn("HOME=/tmp/home", create) + self.assertIn("TMPDIR=/scratch/tmp", create) self.assertEqual(create[create.index("--workdir") + 1], "/work") From a666b307cbc479aac2b37e24271b03686c51d939 Mon Sep 17 00:00:00 2001 From: James Ross Date: Fri, 13 Nov 2026 15:26:05 -0800 Subject: [PATCH 2/2] Give TMPDIR its own capped exec tmpfs and make the probe strict CodeRabbit review on PR #8: - On the scratch volume, temporary files lost the 1 GiB cap /tmp gives them. TMPDIR is now /exec-tmp, a tmpfs mounted exec, size=1g, nosuid, nodev. It is not under /scratch, because preparation empties /scratch and cannot remove a mount point there. - The integration probe joined the TMPDIR checks with &&, where set -e does not stop on a failing test; each check is its own command now. Verified: 34 unit tests in the container; integration-devrun PASS; Bunny's cargo test --workspace --doc passes through this devrun with no TMPDIR override (it failed with "noexec" before). Agent-Session: abe7b061-b12e-4785-a5bf-3fb4b6ce1a0c Agent-Tool: Claude Code --- bin/devrun | 9 ++++++--- docs/hygiene.md | 5 +++-- tests/integration-devrun | 5 ++++- tests/test_devrun.py | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/devrun b/bin/devrun index db647cd..e67cd39 100755 --- a/bin/devrun +++ b/bin/devrun @@ -409,9 +409,12 @@ class Docker: "--mount", f"type=volume,src={self.project}-work,dst=/work", "--mount", f"type=volume,src={self.project}-scratch,dst=/scratch", "--env", "HOME=/tmp/home", - # Docker mounts --tmpfs noexec, so test binaries (rustdoc's doctests) cannot run - # from /tmp. TMPDIR is on the scratch volume, which allows execution. - "--env", "TMPDIR=/scratch/tmp", + # Docker mounts --tmpfs noexec by default, so test binaries (rustdoc's doctests) + # cannot run from /tmp. TMPDIR is a separate tmpfs that allows execution, capped at + # 1 GiB like /tmp. It is not under /scratch: preparation empties /scratch and could + # not remove a mount point there. + "--tmpfs", "/exec-tmp:rw,nosuid,nodev,exec,size=1g,mode=1777", + "--env", "TMPDIR=/exec-tmp", "--workdir", "/work"] for k, v in (env or {}).items(): args += ["--env", f"{k}={v}"] diff --git a/docs/hygiene.md b/docs/hygiene.md index 3b81f92..74c43be 100644 --- a/docs/hygiene.md +++ b/docs/hygiene.md @@ -51,8 +51,9 @@ image build and a smoke test. - Non-root user with a fixed UID (`10001`), `--user 10001:10001`. - `--cap-drop ALL`, `--security-opt no-new-privileges`. - `--read-only` root filesystem. Writable places: `/work` (the copy, at the - root of the work volume), `/scratch` (which also holds `TMPDIR`, `/scratch/tmp`, - because Docker mounts the `/tmp` tmpfs `noexec`), `/tmp` (tmpfs with a size limit), the + root of the work volume), `/scratch`, `/tmp` (tmpfs with a size limit, `noexec`), + `/exec-tmp` (`TMPDIR`: an `exec` tmpfs, also 1 GiB, so test binaries such as doctests + can run), the other named volumes in section 5, and Docker's own `/dev/shm` and `/dev/mqueue`. - **No writable directory above the copy.** Cargo reads `.cargo/config.toml` in diff --git a/tests/integration-devrun b/tests/integration-devrun index 91802ec..5ace57b 100755 --- a/tests/integration-devrun +++ b/tests/integration-devrun @@ -44,7 +44,10 @@ probe='set -e test "$(id -u)" = 10001 test "$(pwd)" = /work test -d "$HOME" && touch "$HOME/probe" -test "$TMPDIR" = /scratch/tmp && printf "#!/bin/sh\necho ran\n" > "$TMPDIR/exe" && chmod +x "$TMPDIR/exe" && test "$("$TMPDIR/exe")" = ran +test "$TMPDIR" = /exec-tmp +printf "#!/bin/sh\necho ran\n" > "$TMPDIR/exe" +chmod +x "$TMPDIR/exe" +test "$("$TMPDIR/exe")" = ran if touch /devrun-probe 2>/dev/null; then echo "the parent of /work is writable" >&2; exit 18; fi test -f README && test -L README.link && test "$(cat README.link | head -1)" = hello test -d .git # created inside the container by devrun, empty baseline only diff --git a/tests/test_devrun.py b/tests/test_devrun.py index 8f0de50..bb4c23f 100644 --- a/tests/test_devrun.py +++ b/tests/test_devrun.py @@ -211,7 +211,8 @@ def test_run_container_mounts_the_copy_at_work_with_home_set(self): create = self.calls[-1] self.assertIn("type=volume,src=geordi-work,dst=/work", create) self.assertIn("HOME=/tmp/home", create) - self.assertIn("TMPDIR=/scratch/tmp", create) + self.assertIn("TMPDIR=/exec-tmp", create) + self.assertIn("/exec-tmp:rw,nosuid,nodev,exec,size=1g,mode=1777", create) self.assertEqual(create[create.index("--workdir") + 1], "/work")