Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ file is the human-readable summary of what changed and why.

### Desktop / Web UI

- **Sandboxes now start on Linux** — every sandbox on Linux failed immediately
with `Can't mkdir /opt/codev-bridge: Read-only file system`. The guest's
`/opt` comes from the read-only image, so the sandbox could not create its
own mount point inside it; the internal bridge directory moved to `/codev-bridge`.
No image download or re-create is needed — existing sandboxes start as they are.
- **New session inside a sandbox now works** — a sandbox had no project of its
own in the app, so **New session** had nothing to open there and quietly
started the session on the local server instead: the sandbox looked selected
Expand Down
16 changes: 15 additions & 1 deletion packages/codev-sandbox/src/bwrap/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,27 @@ test("mounts the workspace rw and the bundle/bridge ro after the rootfs binds",
const joined = buildBwrapArgs(spec).join(" ")
expect(joined).toContain("--bind /host/project /workspace")
expect(joined).toContain("--ro-bind /host/bundle /opt/codev")
expect(joined).toContain("--ro-bind /data/default/bridge /opt/codev-bridge")
expect(joined).toContain("--ro-bind /data/default/bridge /codev-bridge")
expect(joined).toContain("--bind /data/default/runtime /run/codev")
expect(joined).toContain("--bind /data/default/home /home/codev")
expect(joined.indexOf("--bind /host/project")).toBeGreaterThan(joined.indexOf("--ro-bind /data/default/rootfs/usr"))
expect(joined).toContain(`--chdir ${GUEST_WORKSPACE}`)
})

// bwrap creates missing mount points, but only where it can write: its own
// tmpfs root, never inside a read-only rootfs bind. A destination nested under
// a bound rootfs entry must therefore already exist in the image — which the
// image only guarantees for /opt/codev. GUEST_BRIDGE lived at /opt/codev-bridge
// and failed every real start with EROFS; the integration test missed it
// because its host-rootfs allowlist excludes /opt.
test("never nests a mount destination inside a read-only rootfs bind", () => {
const args = buildBwrapArgs({ ...spec, rootfsEntries: [{ name: "opt", symlinkTarget: null }] })
const destinations = args.flatMap((arg, index) =>
(arg === "--bind" || arg === "--ro-bind") && !args[index + 1].startsWith(spec.rootfsDir) ? [args[index + 2]] : [],
)
expect(destinations.filter((destination) => destination.startsWith("/opt/"))).toEqual(["/opt/codev"])
})

test("clears the environment before setting the boot env", () => {
const args = buildBwrapArgs(spec)
const joined = args.join(" ")
Expand Down
6 changes: 5 additions & 1 deletion packages/codev-sandbox/src/bwrap/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { join } from "node:path"

export const GUEST_WORKSPACE = "/workspace"
export const GUEST_BUNDLE = "/opt/codev"
export const GUEST_BRIDGE = "/opt/codev-bridge"
// Top level, not under /opt: the image's own /opt is bind-mounted read-only
// from the rootfs, so bwrap cannot create a mount point inside it. Only paths
// the image already provides (/opt/codev) or that bwrap creates on its tmpfs
// root (this one, /run/codev, /workspace) can be mounted over.
export const GUEST_BRIDGE = "/codev-bridge"
export const GUEST_RUNTIME = "/run/codev"
export const GUEST_HOME = "/home/codev"
// Fixed ports inside the guest's private network namespace — no conflicts are
Expand Down
Loading