units: the tty templates; /dev/pts hidden in every instance namespace (rootfs plan 6)
Task 5. instancectl learns RoleTTY (ParseRole's sixth literal), UnitPrefixTTY and UnitPrefixRootfsTTY, TTYExeApp/TTYExeLive, TTYHello and OneShot; UnitName, RootfsUnitName, IsRootfsUnit and ParseUnitName know the tty units. carlos-instance-tty@ is the cmd template outside its named lines (stdin from the agent's tty socket, journal stdout/stderr, tty-app/tty-live), held by TestTTYTemplateEqualsCmdOutsideTheNamedLines. carlos-instance-rootfs-tty@ is the rootfs cmd template with the same swaps, instance-exit --rootfs tty (PF-9) and rootfs/tty/ sources, held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines; its namespace block is the rootfs block byte for byte. Every binary namespace block gains TemporaryFileSystem=/dev/pts:ro, and the binary probe gains the pts-private line, with devPts and openPtmx wired into productionProbeEnv (PF-8; the rootfs env inherits them). Roll dev first and watch nested readiness. Census overlay rootfs-apps-6 re-proposed (8 units, 2 new).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-rootfs-apps-6.md+24 −3internal/host/host_test.go+2 −0internal/host/units/carlos-instance-cmd@.service+8 −0internal/host/units/carlos-instance-gen@.service+8 −0internal/host/units/carlos-instance-probe.service+8 −0internal/host/units/carlos-instance-rootfs-tty@.service+269 −0internal/host/units/carlos-instance-seed@.service+8 −0internal/host/units/carlos-instance-sidecar@.service+8 −0internal/host/units/carlos-instance-tty@.service+179 −0internal/host/units/carlos-instance@.service+8 −0internal/host/units_hardening_test.go+7 −4internal/host/units_isolation_test.go+79 −2internal/host/units_rootfs_test.go+36 −5internal/instancectl/names.go+38 −12internal/instancectl/names_test.go+71 −0internal/instanceexec/probe.go+12 −2internal/instanceexec/probe_hardening.go+1 −1internal/instanceexec/probe_rootfs_linux.go+0 −2internal/instanceexec/probe_rootfs_other.go+4 −1internal/instanceexec/probe_test.go+70 −1internal/layout/plan.go+1 −1internal/layout/plan_test.go+1 −1internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv+26 −1
Intent
<task-notification> <task-id>a77eab2c005978ce9</task-id> <tool-use-id>toolu_01QxWLhsoc1jmb8xdBxhophP</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a77eab2c005978ce9.output</output-file> <status>completed</status> <summary>Agent "Plan 6 Task 4: apps set --interactive" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE_WITH_CONCERNS. Task 4 is built and committed. The main open item is the census approval on #280, which belongs to you, not me. **Commit:** 91271850 on rootfs-apps-6-interactive (base f49c43b1). Not pushed. **Tests:** I watched the new tests fail before the code existed, then everything passed: - the whole `internal/appconfig` package; - the console's interactive-setting, door-census, closed-door and claim-mutation tests; - in the root package, the `apps set` tests and all three copy gates for RFS-6-C47 (`TestRootfsBuiltCopyIsApplied`, `TestZeroDowntimeCopyIsApplied`, `TestInstancePolicyCopyIsApplied`); - the record-write and root-read census tests in `internal/provision`. Build and vet are clean, the darwin, windows and linux/arm64 cross-builds succeed, and each of 6 deliberate code breakages made a test fail. RFS-6-C47 has no fourth checked consumer. The only other matches are notes and Luna briefs, which no test reads. **Concerns:** 1. **Census approval needed on #280.** The root-read census now also covers two more packages: the root package and `internal/appconfig`. No function changed classification; the census card simply lists them. I also had to edit the record-write census, which the brief didn't mention. It adds `claimRawSetInteractive` as a non-record write and re-pins `registerCLIRoutes`. 2. **Claim fixture setup.** The claim test harness only creates the apps `kass` and `titogo`, so the brief's `bab/shop` fixture got a 404. Its setup now creates `shop` first, the same way the `jam` fixture does. 3. **RFS-6-C41's leading spaces.** The copy deck's table drops the line's two leading spaces, so the constant starts at `--interactive` and the indent is added when the help is printed. The printed text is exactly the approved line. 4. **Gaps that would need new copy:** - The approved `apps set` usage line doesn't mention `[--interactive on|off]`, so `-h` shows the flag only in its own block and the flag list. - A console too old to have this setting returns a plain "not found". The existing old-console message says the console predates `apps set` entirely, which would be wrong here. 5. **Audit on every call.** Like the swap setting, the console records an audit entry and bumps the serial on every accepted request, even one that changes nothing. The full report (test details, the breakage table and the census card) is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-apps-6/.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-4-report.md`.</result> <usage><subagent_tokens>233470</subagent_tokens><tool_uses>107</tool_uses><duration_ms>1333482</duration_ms></usage> </task-notification>
<task-notification> <task-id>ab617b622cabab4ae</task-id> <tool-use-id>toolu_01BENLeUpFVCNKnCmc736LzW</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/ab617b622cabab4ae.output</output-file> <status>completed</status> <summary>Agent "#471 Task 3: hub registry, reservation" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE. Astra's P2 is fixed. **Commits on `design-tunnel-websockets-471`, not pushed:** - `0fe483db`: the Task 3 work. - `e5d2d14b`: the P2 fix. The `-tunnel` row in `TestTenancyComesFromReloadsArm` now uses `fwdOther` (`baj`, `domains.Sqid(8)`), a valid account that differs from the owner `bah`. The expected tenancy and the file's header comment changed to match. There is no `k3x` left in `internal/edge/upgrades_test.go`. Git printed its usual `packed-refs.lock` error, but the commit landed. **Tests:** all 11 Task 3 edge tests pass under `-race`, and `go vet ./internal/edge/` and gofmt are clean. **Concerns:** none. The `k3x` item in the report now records the ruling and the fix. The other notes are unchanged: no platform alias of a forward row can exist, one marker delete is redundant at the hub, a marked refusal keeps its marker header, and the empty-tenancy refusal goes beyond the brief. The full report is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-tunnel-websockets-471/.superpowers/sdd/2026-10-30-tunnel-websockets/task-3-report.md`.</result> <usage><subagent_tokens>236599</subagent_tokens><tool_uses>4</tool_uses><duration_ms>67753</duration_ms></usage> </task-notification>
<task-notification> <task-id>a42fbe2d3167f505e</task-id> <tool-use-id>toolu_01YafAmb1dKbxvXNsR4cLgiT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a42fbe2d3167f505e.output</output-file> <status>completed</status> <summary>Agent "Review Plan 6 Task 4" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Spec compliance:** ✅ Compliant. One ⚠️ can't be checked from this diff: the readers that enforce the setting come later (the session door in Task 10, the box in Task 12). They must read it with `GetInteractive` on the default bundle. `LoadMerged` on a named environment drops the field, so it would read false. That fails safe, but it would be a bug. **Task quality:** Approved. No Critical or Important findings. Your focus questions: - **Who can set it:** only an account owner can turn it on. Any member can turn it off. Every service credential is refused, including deploy and the app's own. Callers from another account get a 404, and there is no operator bypass. - **Default:** stays off. Off is the absent key, and turning it off on an app with no config writes nothing. - **Stale or other app's setting:** no path found. Writes go only to that app's own default config, and no other door can set the flag. - **C47:** byte for byte the same in all three consumers and the code. A grep found no fourth consumer, and I re-ran `TestRootfsBuiltCopyIsApplied` alone: it passes. - **Census edits:** both correct. `claimRawSetInteractive` gets the same non-record row as the swap setting's writer, and the `registerCLIRoutes` re-pin adds only one route line. - **Claim fixture:** harmless. The extra app it adds lives only in that one test case. Findings: - Minor: the `apps set` usage line (GAP-2) doesn't list `--interactive`. Fixing it needs a new copy row. - Minor: a console without the new door answers with a generic "not found" in `setInteractive`. A clearer message needs a new copy row. - Minor: a call that changes nothing still writes an audit row and bumps the serial. The swap door does the same. - Minor: `interactive.go:56-61` repeats `putManifestAt`'s body. The brief asked for that copy. - Minor: no behavioural test for a member of another account calling the door. The shared account check already refuses them. - Minor: the `--interactive` help line prints after "Any member of the app may change these" and doesn't wrap like the lines around it. Layout only. The review is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-apps-6/.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-4-review.md`.</result> <usage><subagent_tokens>138459</subagent_tokens><tool_uses>24</tool_uses><duration_ms>220043</duration_ms></usage> </task-notification>
Attributed to this commit: 87.0 g CO₂e (11,456,470 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on rootfs-apps-6-interactive, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md| index b487624d0..dfc73f51f 100644 |
| --- a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md |
| +++ b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md |
| @@ -1,19 +1,40 @@ |
| # Census approval: rootfs-apps-6 |
| -Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| +| `internal/host/units/carlos-instance-cmd@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else | |
| +| `internal/host/units/carlos-instance-gen@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else | |
| +| `internal/host/units/carlos-instance-probe.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service, so the probe proves what the tenants get (its new pts-private line); nothing else | |
| +| `internal/host/units/carlos-instance-seed@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else | |
| +| `internal/host/units/carlos-instance-sidecar@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else | |
| +| `internal/host/units/carlos-instance@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) | |
| +| `internal/instanceexec/probe.go` `productionProbeEnv` | body | unchanged (1) | rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); the same direct site, no new root read | |
| +| `internal/layout/plan.go` `NestedPlatformNames` | body | unchanged (1) | rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing | |
| | `internal/provision/reconcile.go` `Reconcile` | body | unchanged (178) | rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call | |
| -Envelopes re-pinned: `.`, `internal/appconfig`, `internal/provision`. |
| +Envelopes re-pinned: `.`, `internal/appconfig`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`, `internal/layout`, `internal/provision`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| Recorded dispositions, which each change must still satisfy: |
| +- `internal/host/units/carlos-instance-cmd@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=the cmd unit template (applied by PID 1 as root; its process runs as carlos): extends the J4 seed pattern to the run role. The template equals the seed template outside named lines, and the template-equality test pins that. Root lays out a staged executable validated by the same refuseStagedExe the seed and generation paths use, then starts this unit, which runs as carlos with the instance's own reach. No new trust of registry, /data or agent-asserted content beyond the seed path |
| +- `internal/host/units/carlos-instance-gen@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| +- `internal/host/units/carlos-instance-probe.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=one more BindReadOnlyPaths= line, so PID 1 opens one more bind source: /run/carlos-control/exe/_probe/box-addrs, bound to /opt/carlos/box-addrs, root's list of the box's own addresses, which RunProbe writes before every run (#367) in the root-only directory the unit already binds from; no tenant, app or agent input names or writes it |
| +- `internal/host/units/carlos-instance-seed@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| +- `internal/host/units/carlos-instance-sidecar@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| +- `internal/host/units/carlos-instance@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| +- `internal/instanceexec/probe.go` `productionProbeEnv`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site |
| +- `internal/layout/plan.go` `NestedPlatformNames`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing |
| - `internal/provision/reconcile.go` `Reconcile`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write. |
| -Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `d62fb15b639f48fde409606adcd630322d8c4b8cc5937ea9a257a4969ddc8f5a`. |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/host/units/carlos-instance-rootfs-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| +- new `internal/host/units/carlos-instance-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `5491ec585a12b07e249fe1e680cadc7463c985f63fefcea1330c03dbf38f82ed`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/host/host_test.go b/internal/host/host_test.go| index c23acbca4..2a5ce4d7d 100644 |
| --- a/internal/host/host_test.go |
| +++ b/internal/host/host_test.go |
| @@ -51,10 +51,12 @@ var expectedUnits = []string{ |
| "carlos-instance-rootfs-cmd@.service", |
| "carlos-instance-rootfs-gen@.service", |
| "carlos-instance-rootfs-probe.service", |
| + "carlos-instance-rootfs-tty@.service", |
| "carlos-instance-rootfs-worker@.service", |
| "carlos-instance-rootfs@.service", |
| "carlos-instance-seed@.service", |
| "carlos-instance-sidecar@.service", |
| + "carlos-instance-tty@.service", |
| "carlos-instance@.service", |
| "carlos-instances.slice", |
| "carlos-litestream.service", |
diff --git a/internal/host/units/carlos-instance-cmd@.service b/internal/host/units/carlos-instance-cmd@.service| index 0c02d9aa8..040660163 100644 |
| --- a/internal/host/units/carlos-instance-cmd@.service |
| +++ b/internal/host/units/carlos-instance-cmd@.service |
| @@ -101,6 +101,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units/carlos-instance-gen@.service b/internal/host/units/carlos-instance-gen@.service| index cf30f3330..a0b3a263e 100644 |
| --- a/internal/host/units/carlos-instance-gen@.service |
| +++ b/internal/host/units/carlos-instance-gen@.service |
| @@ -83,6 +83,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units/carlos-instance-probe.service b/internal/host/units/carlos-instance-probe.service| index 9699e11ff..838a4ad16 100644 |
| --- a/internal/host/units/carlos-instance-probe.service |
| +++ b/internal/host/units/carlos-instance-probe.service |
| @@ -77,6 +77,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units/carlos-instance-rootfs-tty@.service b/internal/host/units/carlos-instance-rootfs-tty@.service| new file mode 100644 |
| index 000000000..f2d048cd3 |
| --- /dev/null |
| +++ b/internal/host/units/carlos-instance-rootfs-tty@.service |
| @@ -0,0 +1,269 @@ |
| +# One interactive session against a rootfs instance (rootfs apps design |
| +# §5.10): carlos-instance-tty@.service for an app shipped as an image. It |
| +# is the rootfs cmd template outside its named lines, and a test holds it |
| +# there (TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines): the |
| +# same uid, namespace, image layout, bind mounts, slice and working |
| +# directory, so a session has exactly the reach a command has, which is |
| +# the instance's. The agent starts it through the control service's |
| +# POST /tty; the agent, not this file, enforces the session's own limits. |
| +[Unit] |
| +Description=carlos rootfs instance %I (tty) |
| +# Stop-only coupling, as for the cmd: when the edge stops, the session |
| +# stops, and only the agent starts one. |
| +BindsTo=carlos-edge.service |
| +Requires=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount |
| +After=carlos-edge.service data-instances.mount run-carlos-instances.mount run-carlos-logs.mount |
| + |
| +[Service] |
| +Type=oneshot |
| +RemainAfterExit=yes |
| +# The result stays loaded, active (exited) or failed, until the agent has |
| +# read it and stopped the unit (codex 4), as for the cmd. |
| +# The cmd's backstop past the run cap of 6 hours; the agent ends the |
| +# session at its own limits. |
| +TimeoutStartSec=6h5m |
| +# --rootfs before the role, in ExecStart= and ExecStopPost= alike, as in |
| +# carlos-instance-rootfs@.service. |
| +ExecStart=/opt/carlos/carlos instance-exec --rootfs tty %I |
| +# The advisory exit record, as for the other templates. Not "+" (codex R3-2). |
| +ExecStopPost=/opt/carlos/carlos instance-exit --rootfs tty %I |
| +User=carlos |
| +Group=carlos |
| +Slice=carlos-instances-%i.slice |
| +# SIGTERM to the session, SIGKILL to anything left 20 s later. |
| +KillMode=mixed |
| +TimeoutStopSec=20 |
| +# No SuccessExitStatus=: the agent reads the exit status itself. |
| +# One socket, the agent's: PID 1 connects stdin to it as root, outside the |
| +# namespace, on the nosymfollow logs mount, as for the cmd streams. The |
| +# trampoline receives the pty's fd over it and makes the pty the tenant's |
| +# stdio, so the journal lines below carry only the trampoline's own |
| +# diagnostics, never the tenant's output. |
| +StandardInput=file:/run/carlos/logs/%I.tty.sock |
| +StandardOutput=journal |
| +StandardError=journal |
| +# The instance's own two directories, the only writable data paths, bound |
| +# into the image root at the mount points ship adds (rootfs apps design |
| +# §5.1). |
| +BindPaths=/data/instances/%I /run/carlos/instances/%I |
| +ReadWritePaths=/data/instances/%I /run/carlos/instances/%I |
| +# The working directory is the instance's own data directory, the one its |
| +# database is in (discussion #256 item D): a session with no working_dir |
| +# in its manifest starts where the instance starts, and the trampoline |
| +# chdirs to the manifest's working_dir when there is one (rootfs apps |
| +# design §5.2). systemd applies it after the namespace is set up, so the |
| +# bind above is what it chdirs into. Same value as the instance template: |
| +# a session sees the files the instance made from the same place. |
| +WorkingDirectory=/data/instances/%I |
| +# The image is the app (#214 item 2): no app and no live bind (no tty-app, |
| +# no tty-live), and nothing from the version store. The session's root is |
| +# the image it was admitted against, through root's own tty link under the |
| +# exe layout, not the run link the instance and its workers mount nor the |
| +# cmd link (merge ruling M4): a start of any other role on another image |
| +# around a swap can never repoint the source this unit is about to mount, |
| +# nor the reverse. The control service writes it before it starts the |
| +# unit. |
| +RootImage=/run/carlos-control/exe/%I/rootfs/tty/image |
| +# The session's own root-written launch file and resolver copy, beside its |
| +# image link, read-only (C4; probe launch-root-owned, dns). The control |
| +# service writes all three sources before it starts the unit. |
| +BindReadOnlyPaths=/run/carlos-control/exe/%I/rootfs/tty/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/%I/rootfs/tty/resolv.conf:/etc/resolv.conf |
| + |
| +# --- the rootfs namespace (restated from carlos-instance@.service for an image root; rootfs apps design §5.3) --- |
| +# Every line of the binary block (carlos-instance@.service) is restated |
| +# here for a root that is the instance's image, not the host: a line that |
| +# still binds is kept with its comment; a line that would be a no-op, or |
| +# would fail on a path the image lacks, is replaced by one that proves the |
| +# same property, and the rootfs probe (instance-probe --rootfs) proves |
| +# each replacement from inside. The five rootfs units carry this block |
| +# byte for byte (TestRootfsTemplatesShareOneNamespace), so what the probe |
| +# proves is what a tenant gets. |
| +# |
| +# New, with no binary line to stand in for: the root itself. The image is |
| +# mounted read-only, no set-id bit in it is honoured and no device node in |
| +# it is usable, and /proc, /sys, /dev and /run are fresh API mounts of |
| +# this namespace, not the image's directories. RootImage= itself sits |
| +# outside the block because it is per instance (a drop-in for the |
| +# generation and worker templates). The probe's root-image check: the root |
| +# is a squashfs on a loop device carrying the probe marker. |
| +RootImageOptions=ro,nosuid,nodev |
| +MountAPIVFS=yes |
| +# Kept: on an image root this makes the root and the image's /etc |
| +# read-only (squashfs already is). systemd 257 exempts only the API file |
| +# systems /dev, /proc and /sys; /run, a fresh tmpfs under MountAPIVFS=, is |
| +# read-only too, and the unit's only writable paths are its two binds |
| +# (ReadWritePaths=, outside this block). The probe's root-read-only check: |
| +# a create at / and at /etc answers EROFS. |
| +ProtectSystem=strict |
| +# Kept: the image's /data mount point (ship adds it) becomes an empty |
| +# read-only tmpfs, and the bind outside this block reveals exactly one |
| +# directory in it (probe data-tree). |
| +TemporaryFileSystem=/data:ro |
| +# Kept: /run is a fresh tmpfs under MountAPIVFS=, so this is created, |
| +# never missing (probe run-tree). |
| +TemporaryFileSystem=/run/carlos:ro |
| +# Dropped: TemporaryFileSystem=/var/cache:ro and /var/lib:ro. The binary |
| +# block hides those HOST trees because other carlos-uid units write them |
| +# (codex R9-2); the host's /var is not in an image root at all, and the |
| +# image's own /var/lib is the app's (Debian's /var/lib/gems). What stands |
| +# in for them is the root being the image, proven by the probe's |
| +# root-image check, and its mounts-allowlisted check: no mount in the |
| +# namespace comes from the host's /var, /opt/carlos/versions, |
| +# /opt/carlos/live or another instance's directory. |
| +# |
| +# Kept: the version store holds every app's build on the box, world- |
| +# readable so a unit can exec its own (#214 item 2). A rootfs instance |
| +# sees none of it, and nothing of its image's own /opt/carlos either (ship |
| +# adds the mount point): an empty /opt/carlos with the platform binary |
| +# that ExecStart= and ExecStopPost= run put back, and, outside this block |
| +# because it is per instance, root's launch file at |
| +# /opt/carlos/launch.json. The probe's opt-own-image check lists exactly |
| +# what this line and the per-unit binds put back. |
| +TemporaryFileSystem=/opt/carlos:ro |
| +BindReadOnlyPaths=/opt/carlos/carlos |
| +# Dropped: InaccessiblePaths=/etc/carlos /run/carlos-control. The binary |
| +# block hides root-written credentials a carlos-GROUP process may read |
| +# (/etc/carlos/relay-masters is root:carlos 0640, codex R10-1) and the |
| +# root control service's socket directory (isolated-exec design §5.2). |
| +# Neither path exists in an image root; systemd fails a unit on a missing |
| +# InaccessiblePaths= target, and "-" would make the line a silent no-op. |
| +# The probe's etc-carlos and control-unreachable checks: both answer |
| +# ENOENT from inside. |
| +# |
| +# Kept: hides the image's /home, /root and /run/user; systemd ignores a |
| +# missing one. A unit-file pin only: the property is the image's, not the |
| +# host's. |
| +ProtectHome=yes |
| +# Replaces PrivateTmp=yes, which would bind host directories under |
| +# /var/tmp/systemd-private-* and need /var/tmp in the image. A private |
| +# tmpfs instead (rootfs apps design §5.3): empty, writable, charged to |
| +# this cgroup, and nothing of the host's /tmp in it. The probe's |
| +# tmp-private check: empty, writable, and the host's fixture |
| +# /tmp/carlos-probe absent. |
| +TemporaryFileSystem=/tmp:mode=1777,nosuid,nodev |
| +# Kept: a private /dev on the image's mount point (ship adds it). Probe |
| +# shm-private and the mount allowlist. |
| +PrivateDevices=yes |
| +# Kept: PrivateDevices= bind-mounts the HOST's /dev/shm into the private |
| +# /dev, and every instance is uid carlos, so a sibling's shared memory |
| +# would be one open away. Each unit gets its own, charged to its own |
| +# cgroup (probe shm-private). |
| +TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| +# Kept: POSIX message queues and SysV IPC belong to an IPC namespace, and |
| +# every instance is uid carlos, so a sibling's queue would be one mq_open |
| +# away (#178). PrivateIPC= gives each unit its own namespace, and |
| +# mq_open() goes through that namespace's own internal mount. |
| +# PrivateDevices= carries the host's /dev/mqueue into the private /dev the |
| +# way it carries /dev/shm, and that mount would still list and open the |
| +# host namespace's queues, so it is replaced the same way (probe |
| +# ipc-private covers both). |
| +PrivateIPC=yes |
| +TemporaryFileSystem=/dev/mqueue:ro |
| +# New (Plan 2 deviation 8; Plan 6 adds it to the binary block): |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant's terminal is what Plan 6 makes |
| +# of them. Hidden here from the start, so Plan 6 never edits a security |
| +# block it did not review. The probe's pts-private check: /dev/pts lists |
| +# nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| +# Replaces ProtectControlGroups=yes. The binary block mounts /sys/fs/cgroup |
| +# read-only so the edge's delegated subtree, carlos-owned, is not one |
| +# write away for a same-uid tenant (codex R9-1); with a fresh API /sys, |
| +# whether cgroup2 is mounted read-only under it is not something the |
| +# binary probe's check (a write to the edge's delegated cgroup.procs) can |
| +# see from an image. strict (systemd 257) is a cgroup namespace with a |
| +# private read-only /sys/fs/cgroup showing only this unit's own subtree. |
| +# The probe's cgroup-strict check: /proc/self/cgroup is 0::/, the mount |
| +# carries ro, access(W_OK) on its own cgroup.procs is refused (EACCES: |
| +# the file is root's and DAC is checked before the mount's ro flag; EROFS |
| +# would do as well), and the listing names no carlos.slice or |
| +# system.slice; a systemd that ignores the value leaves the listing |
| +# populated and fails the line. |
| +ProtectControlGroups=strict |
| +# Kept: these apply to the fresh /proc (probe pid1). |
| +ProtectProc=invisible |
| +ProcSubset=pid |
| +PrivatePIDs=yes |
| +# Kept, unchanged meaning; a unit-file pin. NoNewPrivileges= also voids |
| +# any set-id file in the image. |
| +RestrictNamespaces=yes |
| +NoNewPrivileges=yes |
| +CapabilityBoundingSet= |
| +# Kept, unchanged; a unit-file pin. |
| +RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX |
| +# Abstract unix sockets live in the network namespace, which instances |
| +# share with the box because they need outbound TCP, and the line above |
| +# cannot tell them from path sockets (#178). The trampoline scopes them |
| +# with Landlock before it execs the app (instanceexec.ScopeAbstractUnix): |
| +# an instance can connect only to abstract sockets its own processes |
| +# bound. A sibling can still bind a name first; that is a refusal of |
| +# service, never a connection. |
| +# |
| +# Egress (#214 item 3): the internet, and nothing on the box or private. |
| +# Loopback is where the console and other tenants' addr upstreams listen; |
| +# RFC 1918, ULA, link-local and CGNAT are the VPC, other boxes and the |
| +# cloud's internal services. IMDS stays named so the property is |
| +# greppable. A cgroup filter: it drops in both directions for every |
| +# socket the unit opens. The one thing an instance needs from these |
| +# ranges is the box's DNS resolver, so the control service re-opens |
| +# exactly the nameservers the instance sees with IPAddressAllow= on |
| +# carlos-instances.slice (an allow wins, and a slice's lists reach every |
| +# unit below it). The probe checks both halves. |
| +# |
| +# Kept byte for byte (the test pins it to the binary block's). The box's |
| +# own addresses are not in this list (#367): the control service denies |
| +# them on carlos-instances.slice, whose list every unit below it is merged |
| +# with, and the probe's box-addr check finds them closed from inside. |
| +IPAddressDeny=localhost multicast 0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 169.254.0.0/16 169.254.169.254/32 172.16.0.0/12 192.0.0.0/24 192.168.0.0/16 198.18.0.0/15 240.0.0.0/4 64:ff9b::/96 fc00::/7 fd00:ec2::254/128 fe80::/10 fec0::/10 |
| +# Replaced, outside this block because it is per instance: |
| +# BindReadOnlyPaths=-/run/systemd/resolve/resolv.conf:/etc/resolv.conf. |
| +# Its "-" skips a box without resolved, and inside an image that would |
| +# leave the image's own (empty) resolv.conf in place: no DNS. Each rootfs |
| +# unit binds root's copy of exactly the file the control service opened on |
| +# the slice (instancectl resolverFile) over /etc/resolv.conf instead. The |
| +# reason the binary line never binds resolved's stub still holds: an allow |
| +# opens an address both ways and on every port, so a loopback resolver can |
| +# never be opened; a tenant could bind systemd-resolved's 127.0.0.53 |
| +# itself and reach every listener bound to all addresses through it. |
| +# Where resolved runs, instances resolve through its upstreams, and the |
| +# control service opens those. The probe's dns and resolver-ports checks |
| +# read /etc/resolv.conf from inside and compare it with the allow. |
| +# |
| +# Kept, unchanged; unit-file pins. |
| +ProtectKernelTunables=yes |
| +ProtectKernelModules=yes |
| +ProtectKernelLogs=yes |
| +ProtectClock=yes |
| +ProtectHostname=yes |
| +RemoveIPC=yes |
| +LockPersonality=yes |
| +RestrictRealtime=yes |
| +# No RestrictSUIDSGID=: systemd cannot read the mode inside openat2's |
| +# open_how, so it refuses openat2 outright (ENOSYS), and every instancefs |
| +# open in here is an openat2 (#126, first roll; systemd 257). What it |
| +# guarded is covered: with no capabilities an instance can only make a |
| +# set-id file owned by carlos, which gains nothing for another carlos |
| +# process, NoNewPrivileges= voids it in here, and no other uid can reach |
| +# one (the image is nosuid by RootImageOptions=, the tenant trees are |
| +# nosuid, and /tmp is a nosuid tmpfs of this unit's own). |
| +# |
| +# Kept in the block for every template, the probe included (R11, rootfs |
| +# apps design §5.11). A release whose root-staged manifest declares jit |
| +# runs without it through a per-start drop-in that root writes and checks |
| +# the effective property of (C10), never through a unit file. The probe's |
| +# mdwe check: an mmap(PROT_WRITE|PROT_EXEC) is refused inside the probe, |
| +# which never gets the drop-in (EACCES from the kernel's PR_SET_MDWE, |
| +# which systemd 257 uses where the kernel has it, or EPERM from its |
| +# seccomp fallback). |
| +MemoryDenyWriteExecute=yes |
| +SystemCallArchitectures=native |
| + |
| +# --- per-service resources; the tier lives on the host slice (§4.3) --- |
| +TasksMax=256 |
| +# The kernel picks a tenant before it picks anything else in carlos.slice. |
| +OOMScoreAdjust=500 |
| +# One OOM kill takes every process of THIS service (systemd sets |
| +# memory.oom.group on the service cgroup for OOMPolicy=kill). A worker is |
| +# a sibling service with its own family rule (isolated-exec design §4.3; |
| +# rootfs apps design §5.4). |
| +OOMPolicy=kill |
diff --git a/internal/host/units/carlos-instance-seed@.service b/internal/host/units/carlos-instance-seed@.service| index 24e0eac7e..72f162fd8 100644 |
| --- a/internal/host/units/carlos-instance-seed@.service |
| +++ b/internal/host/units/carlos-instance-seed@.service |
| @@ -111,6 +111,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units/carlos-instance-sidecar@.service b/internal/host/units/carlos-instance-sidecar@.service| index 4a43cf115..befa84c4a 100644 |
| --- a/internal/host/units/carlos-instance-sidecar@.service |
| +++ b/internal/host/units/carlos-instance-sidecar@.service |
| @@ -110,6 +110,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units/carlos-instance-tty@.service b/internal/host/units/carlos-instance-tty@.service| new file mode 100644 |
| index 000000000..168f4e195 |
| --- /dev/null |
| +++ b/internal/host/units/carlos-instance-tty@.service |
| @@ -0,0 +1,179 @@ |
| +# One interactive session against an isolated exec-backed instance |
| +# (rootfs apps design §5.10): a command whose stdio is a terminal. It is |
| +# the cmd template outside its named lines, and a test holds it there |
| +# (TestTTYTemplateEqualsCmdOutsideTheNamedLines): the same uid, namespace, |
| +# bind mounts, slice and working directory as the instance, so a session |
| +# has exactly the reach a command has, which is the instance's. The agent |
| +# starts it through the control service's POST /tty; the agent, not this |
| +# file, enforces the session's own limits. |
| +[Unit] |
| +Description=carlos exec-backed instance %I (tty) |
| +# Stop-only coupling, as for the cmd: when the edge stops, the session |
| +# stops, and only the agent starts one. |
| +BindsTo=carlos-edge.service |
| +Requires=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount |
| +After=carlos-edge.service data-instances.mount run-carlos-instances.mount run-carlos-logs.mount |
| + |
| +[Service] |
| +Type=oneshot |
| +RemainAfterExit=yes |
| +# The result stays loaded, active (exited) or failed, until the agent has |
| +# read it and stopped the unit (codex 4), as for the cmd. |
| +# The cmd's backstop past the run cap of 6 hours; the agent ends the |
| +# session at its own limits. |
| +TimeoutStartSec=6h5m |
| +ExecStart=/opt/carlos/carlos instance-exec tty %I |
| +# The advisory exit record, as for the other templates. Not "+" (codex R3-2). |
| +ExecStopPost=/opt/carlos/carlos instance-exit tty %I |
| +User=carlos |
| +Group=carlos |
| +Slice=carlos-instances-%i.slice |
| +# SIGTERM to the session, SIGKILL to anything left 20 s later. |
| +KillMode=mixed |
| +TimeoutStopSec=20 |
| +# No SuccessExitStatus=: the agent reads the exit status itself. |
| +# One socket, the agent's: PID 1 connects stdin to it as root, outside the |
| +# namespace, on the nosymfollow logs mount, as for the cmd streams. The |
| +# trampoline receives the pty's fd over it and makes the pty the tenant's |
| +# stdio, so the journal lines below carry only the trampoline's own |
| +# diagnostics, never the tenant's output. |
| +StandardInput=file:/run/carlos/logs/%I.tty.sock |
| +StandardOutput=journal |
| +StandardError=journal |
| +# The instance's own two directories, the only writable data paths. |
| +BindPaths=/data/instances/%I /run/carlos/instances/%I |
| +ReadWritePaths=/data/instances/%I /run/carlos/instances/%I |
| +# The working directory is the instance's own data directory, the one its |
| +# database is in (discussion #256 item D). A flat child ran with cwd /, |
| +# and an app writing relative paths (./data/blobs) wrote under /data; |
| +# without this line a unit's cwd is / on a read-only tmpfs and that app |
| +# exits at start with "read-only file system". systemd applies it after |
| +# the namespace is set up, so the bind above is what it chdirs into. Same |
| +# value in all three templates: the seed and the sidecar see the files |
| +# the instance made from the same place. |
| +WorkingDirectory=/data/instances/%I |
| +# Its own build, and no other app's (#214 item 2). The namespace block |
| +# empties /opt/carlos; these put back /opt/carlos/live/<host>, a link to |
| +# ../app, and /opt/carlos/app, which PID 1 binds by chasing the source |
| +# link to the build the run was admitted against at every start. The |
| +# control service writes both sources before it starts the unit. They are |
| +# the session's own, tty-app and tty-live, not the app and live the |
| +# instance and sidecar templates bind nor the cmd's (merge ruling M4): a |
| +# start of any other role on another build around a swap can never |
| +# repoint the source this unit is about to bind, nor the reverse. |
| +BindReadOnlyPaths=/run/carlos-control/exe/%I/tty-app:/opt/carlos/app /run/carlos-control/exe/%I/tty-live:/opt/carlos/live |
| + |
| +# --- the namespace (titogo@.service, 2026-07-31 design, on systemd 257) --- |
| +ProtectSystem=strict |
| +TemporaryFileSystem=/data:ro |
| +TemporaryFileSystem=/run/carlos:ro |
| +# Every other tree a carlos-uid unit writes on the box is hidden the same |
| +# way (codex R9-2): the restore drills' cache under /var/cache, and |
| +# /var/lib as a class. An instance needs nothing from either. |
| +TemporaryFileSystem=/var/cache:ro |
| +TemporaryFileSystem=/var/lib:ro |
| +# The version store holds every app's build on the box, world-readable so |
| +# a unit can exec its own (#214 item 2). An instance sees none of it: an |
| +# empty /opt/carlos with the platform binary that ExecStart= and |
| +# ExecStopPost= run put back, and, outside this block because it is per |
| +# instance, its own build at /opt/carlos/live/<host>. |
| +TemporaryFileSystem=/opt/carlos:ro |
| +BindReadOnlyPaths=/opt/carlos/carlos |
| +# Root-written credentials a carlos-GROUP process may read live here: |
| +# /etc/carlos/relay-masters is root:carlos 0640 for carlos-relay.service, |
| +# and an instance's Group=carlos would read it too (codex R10-1). An |
| +# instance gets its configuration through its launch file and needs |
| +# nothing from /etc/carlos. /run/carlos-control is the root control |
| +# service's socket directory (design §5.2): hiding it here too means a |
| +# connect from inside any instance's namespace is impossible outright, |
| +# not merely refused by the peer check on the far end (final review, |
| +# plan 2, item 3). |
| +InaccessiblePaths=/etc/carlos /run/carlos-control |
| +ProtectHome=yes |
| +PrivateTmp=yes |
| +PrivateDevices=yes |
| +# PrivateDevices= bind-mounts the HOST's /dev/shm into the private /dev, |
| +# and every instance is uid carlos, so a sibling's shared memory would be |
| +# one open away. Each unit gets its own, charged to its own cgroup. |
| +TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| +# POSIX message queues and SysV IPC belong to an IPC namespace, and every |
| +# instance is uid carlos, so a sibling's queue would be one mq_open away |
| +# (#178). PrivateIPC= gives each unit its own namespace, and mq_open() |
| +# goes through that namespace's own internal mount. PrivateDevices= |
| +# carries the host's /dev/mqueue into the private /dev the way it carries |
| +# /dev/shm, and that mount would still list and open the host namespace's |
| +# queues, so it is replaced the same way. |
| +PrivateIPC=yes |
| +TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| +# /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| +# and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| +# for a same-uid tenant (codex R9-1). |
| +ProtectControlGroups=yes |
| +ProtectProc=invisible |
| +ProcSubset=pid |
| +PrivatePIDs=yes |
| +RestrictNamespaces=yes |
| +NoNewPrivileges=yes |
| +CapabilityBoundingSet= |
| +RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX |
| +# Abstract unix sockets live in the network namespace, which instances |
| +# share with the box because they need outbound TCP, and the line above |
| +# cannot tell them from path sockets (#178). The trampoline scopes them |
| +# with Landlock before it execs the app (instanceexec.ScopeAbstractUnix): |
| +# an instance can connect only to abstract sockets its own processes |
| +# bound. A sibling can still bind a name first; that is a refusal of |
| +# service, never a connection. |
| +# |
| +# Egress (#214 item 3): the internet, and nothing on the box or private. |
| +# Loopback is where the console and other tenants' addr upstreams listen; |
| +# RFC 1918, ULA, link-local and CGNAT are the VPC, other boxes and the |
| +# cloud's internal services. IMDS stays named so the property is |
| +# greppable. A cgroup filter: it drops in both directions for every |
| +# socket the unit opens. The one thing an instance needs from these |
| +# ranges is the box's DNS resolver, so the control service re-opens |
| +# exactly the nameservers the instance sees with IPAddressAllow= on |
| +# carlos-instances.slice (an allow wins, and a slice's lists reach every |
| +# unit below it). The probe checks both halves. |
| +IPAddressDeny=localhost multicast 0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 169.254.0.0/16 169.254.169.254/32 172.16.0.0/12 192.0.0.0/24 192.168.0.0/16 198.18.0.0/15 240.0.0.0/4 64:ff9b::/96 fc00::/7 fd00:ec2::254/128 fe80::/10 fec0::/10 |
| +# An allow opens an address both ways and on every port, so a loopback |
| +# resolver can never be opened: a tenant could bind systemd-resolved's |
| +# 127.0.0.53 itself and reach every listener bound to all addresses |
| +# through it. Where resolved runs, instances resolve through its |
| +# upstreams instead, and the control service opens those. The "-" makes |
| +# this a no-op on a box without resolved. |
| +BindReadOnlyPaths=-/run/systemd/resolve/resolv.conf:/etc/resolv.conf |
| +ProtectKernelTunables=yes |
| +ProtectKernelModules=yes |
| +ProtectKernelLogs=yes |
| +ProtectClock=yes |
| +ProtectHostname=yes |
| +RemoveIPC=yes |
| +LockPersonality=yes |
| +RestrictRealtime=yes |
| +# No RestrictSUIDSGID=: systemd cannot read the mode inside openat2's |
| +# open_how, so it refuses openat2 outright (ENOSYS), and every instancefs |
| +# open in here is an openat2 (#126, first roll; systemd 257). What it |
| +# guarded is covered: with no capabilities an instance can only make a |
| +# set-id file owned by carlos, which gains nothing for another carlos |
| +# process, NoNewPrivileges= voids it in here, and no other uid can reach |
| +# one (the tenant trees are nosuid, PrivateTmp's sit under a root 0700 |
| +# directory). |
| +MemoryDenyWriteExecute=yes |
| +SystemCallArchitectures=native |
| + |
| +# --- per-service resources; the tier lives on the host slice (§4.3) --- |
| +TasksMax=256 |
| +# The kernel picks a tenant before it picks anything else in carlos.slice. |
| +OOMScoreAdjust=500 |
| +# One OOM kill takes every process of THIS service (systemd sets |
| +# memory.oom.group on the service cgroup for OOMPolicy=kill). The sidecar |
| +# is a sibling service with its own family rule (§4.3). |
| +OOMPolicy=kill |
diff --git a/internal/host/units/carlos-instance@.service b/internal/host/units/carlos-instance@.service| index c8cec39bf..750d06d33 100644 |
| --- a/internal/host/units/carlos-instance@.service |
| +++ b/internal/host/units/carlos-instance@.service |
| @@ -110,6 +110,14 @@ TemporaryFileSystem=/dev/shm:mode=1777,nosuid,nodev |
| # queues, so it is replaced the same way. |
| PrivateIPC=yes |
| TemporaryFileSystem=/dev/mqueue:ro |
| +# PrivateDevices= carries the host's /dev/pts and /dev/ptmx into the |
| +# private /dev the same way, and a tenant that could list or open them |
| +# could reach a sibling's terminal or make a pty of the host's devpts. |
| +# Hidden here, as in the rootfs block. An interactive session's terminal |
| +# is never one of these: the agent opens it outside the namespace and |
| +# hands it in by fd (rootfs Plan 6). The probe's pts-private check: |
| +# /dev/pts lists nothing and open(/dev/ptmx) fails. |
| +TemporaryFileSystem=/dev/pts:ro |
| # /sys/fs/cgroup read-only: the edge's delegated subtree is carlos-owned, |
| # and its cgroup.kill / cgroup.freeze would otherwise be one write away |
| # for a same-uid tenant (codex R9-1). |
diff --git a/internal/host/units_hardening_test.go b/internal/host/units_hardening_test.go| index 943263954..338f07ab9 100644 |
| --- a/internal/host/units_hardening_test.go |
| +++ b/internal/host/units_hardening_test.go |
| @@ -42,10 +42,10 @@ const instanceDeny = "IPAddressDeny=localhost multicast " + |
| // Every directive the hardening adds to the shared namespace block (#214 |
| // items 2 and 3, #178), pinned exactly: the block is byte-identical across |
| -// the four templates and the probe (TestInstanceTemplatesShareOneNamespace), |
| -// so pinning it on carlos-instance@ pins it on all five. |
| +// the binary templates and the probe (TestInstanceTemplatesShareOneNamespace), |
| +// so pinning it on carlos-instance@ pins it on all of them. |
| func TestNamespaceBlockCarriesTheHardening(t *testing.T) { |
| - for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-probe.service"} { |
| + for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-tty@.service", "carlos-instance-probe.service"} { |
| u := readUnit(t, name) |
| for _, want := range []string{ |
| // #214 item 2: no other app's build is visible. |
| @@ -59,6 +59,8 @@ func TestNamespaceBlockCarriesTheHardening(t *testing.T) { |
| "BindReadOnlyPaths=-/run/systemd/resolve/resolv.conf:/etc/resolv.conf", |
| "PrivateIPC=yes", |
| "TemporaryFileSystem=/dev/mqueue:ro", |
| + // rootfs Plan 6: the host's terminals out of sight. |
| + "TemporaryFileSystem=/dev/pts:ro", |
| } { |
| if !hasDirective(u, want) { |
| t.Errorf("%s lacks %q", name, want) |
| @@ -118,7 +120,7 @@ func TestInstanceFenceIsEgressaddrFenceDeny(t *testing.T) { |
| // systemd's names, expanded the way it does. |
| named := map[string][]string{"localhost": {"127.0.0.0/8", "::1/128"}, "multicast": {"224.0.0.0/4", "ff00::/8"}} |
| units := map[string]string{"claimBoundTemplate": claimBoundTemplate} |
| - for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-probe.service"} { |
| + for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-tty@.service", "carlos-instance-probe.service"} { |
| units[name] = readUnit(t, name) |
| } |
| for name, u := range units { |
| @@ -170,6 +172,7 @@ func TestInstanceTemplatesBindOnlyTheirOwnBuild(t *testing.T) { |
| "carlos-instance-seed@.service": {"%I", ""}, |
| "carlos-instance-sidecar@.service": {"%I", ""}, |
| "carlos-instance-cmd@.service": {"%I", "cmd-"}, |
| + "carlos-instance-tty@.service": {"%I", "tty-"}, |
| "carlos-instance-probe.service": {"_probe", ""}, |
| } { |
| u := readUnit(t, name) |
diff --git a/internal/host/units_isolation_test.go b/internal/host/units_isolation_test.go| index daa41eeb6..b81ba72fa 100644 |
| --- a/internal/host/units_isolation_test.go |
| +++ b/internal/host/units_isolation_test.go |
| @@ -239,7 +239,7 @@ func TestInstanceTemplatesShareOneNamespace(t *testing.T) { |
| return u[start:end] |
| } |
| ref := block("carlos-instance@.service") |
| - for _, name := range []string{"carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-probe.service"} { |
| + for _, name := range []string{"carlos-instance-gen@.service", "carlos-instance-seed@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-tty@.service", "carlos-instance-probe.service"} { |
| if block(name) != ref { |
| t.Errorf("%s namespace block differs from carlos-instance@.service", name) |
| } |
| @@ -251,6 +251,9 @@ func TestInstanceTemplatesShareOneNamespace(t *testing.T) { |
| "ProtectControlGroups=yes", "ProtectProc=invisible", "ProcSubset=pid", "PrivatePIDs=yes", |
| "RestrictNamespaces=yes", "NoNewPrivileges=yes", "CapabilityBoundingSet=", |
| "IPAddressDeny=localhost ", " 169.254.169.254/32 ", " fd00:ec2::254/128 ", "PrivateIPC=yes", "MemoryDenyWriteExecute=yes", |
| + // PrivateDevices= binds the host's /dev/pts into the private /dev |
| + // (rootfs Plan 6): hidden, so no tenant reaches a host terminal. |
| + "TemporaryFileSystem=/dev/pts:ro", |
| } { |
| if !strings.Contains(ref, want) { |
| t.Errorf("namespace block lacks %q", want) |
| @@ -285,6 +288,11 @@ func TestInstanceTemplatesShareOneNamespace(t *testing.T) { |
| "carlos-instance-cmd@.service": {"Type=oneshot", "RemainAfterExit=yes", "TimeoutStartSec=6h5m", "ExecStart=/opt/carlos/carlos instance-exec cmd %I", |
| "ExecStopPost=/opt/carlos/carlos instance-exit cmd %I", "StandardOutput=file:/run/carlos/logs/%I.cmd.sock", |
| "StandardError=file:/run/carlos/logs/%I.cmd-err.sock", "KillMode=mixed", "TimeoutStopSec=20", "WorkingDirectory=/data/instances/%I"}, |
| + // One interactive session (rootfs Plan 6): the cmd unit's shape, |
| + // stdin from the agent's socket and no SuccessExitStatus=. |
| + "carlos-instance-tty@.service": {"Type=oneshot", "RemainAfterExit=yes", "TimeoutStartSec=6h5m", |
| + "ExecStart=/opt/carlos/carlos instance-exec tty %I", "StandardInput=file:/run/carlos/logs/%I.tty.sock", "Slice=carlos-instances-%i.slice", |
| + "KillMode=mixed", "TimeoutStopSec=20", "WorkingDirectory=/data/instances/%I", "User=carlos"}, |
| "carlos-instance-sidecar@.service": {"Type=simple", "ExecStart=/opt/carlos/carlos instance-exec sidecar %I", |
| "ExecStopPost=/opt/carlos/carlos instance-exit sidecar %I", "StandardOutput=file:/run/carlos/logs/%I.sidecar.sock", |
| "SuccessExitStatus=129 130 141 143", "WorkingDirectory=/data/instances/%I"}, |
| @@ -307,7 +315,7 @@ func TestInstanceTemplatesShareOneNamespace(t *testing.T) { |
| t.Errorf("%s uses ExecStopPost=+: the plus prefix keeps the unit's tmpfs (codex R3-2)", name) |
| } |
| // A seed a signal ended has not seeded (#126). |
| - if (name == "carlos-instance-seed@.service" || name == "carlos-instance-cmd@.service") && strings.Contains(u, "\nSuccessExitStatus=") { |
| + if (name == "carlos-instance-seed@.service" || name == "carlos-instance-cmd@.service" || name == "carlos-instance-tty@.service") && strings.Contains(u, "\nSuccessExitStatus=") { |
| t.Errorf("%s counts a signal's exit status as success", name) |
| } |
| if name != "carlos-instance-probe.service" && !strings.Contains(u, "User=carlos") { |
| @@ -474,6 +482,75 @@ func TestCmdTemplateEqualsSeedOutsideTheNamedLines(t *testing.T) { |
| } |
| } |
| +// unitDirectives is a unit's directives in order: comments and blank lines |
| +// dropped, each line trimmed. |
| +func unitDirectives(t *testing.T, name string) []string { |
| + t.Helper() |
| + var out []string |
| + for _, line := range strings.Split(readUnit(t, name), "\n") { |
| + line = strings.TrimSpace(line) |
| + if line == "" || strings.HasPrefix(line, "#") { |
| + continue |
| + } |
| + out = append(out, line) |
| + } |
| + return out |
| +} |
| + |
| +// equalOutsideTheNamedLines holds unit got to unit base with swap applied: |
| +// each named line of base becomes the listed lines, in order, and every |
| +// other directive is base's, in order. A swap line base no longer has |
| +// fails, so the table cannot go stale. |
| +func equalOutsideTheNamedLines(t *testing.T, base, got string, swap map[string][]string) { |
| + t.Helper() |
| + var want []string |
| + used := map[string]bool{} |
| + for _, l := range unitDirectives(t, base) { |
| + if c, ok := swap[l]; ok { |
| + want, used[l] = append(want, c...), true |
| + continue |
| + } |
| + want = append(want, l) |
| + } |
| + for l := range swap { |
| + if !used[l] { |
| + t.Errorf("%s no longer has %q, which the table names as a difference", base, l) |
| + } |
| + } |
| + have := unitDirectives(t, got) |
| + for i := 0; i < len(want) || i < len(have); i++ { |
| + var w, g string |
| + if i < len(want) { |
| + w = want[i] |
| + } |
| + if i < len(have) { |
| + g = have[i] |
| + } |
| + if w != g { |
| + t.Fatalf("directive %d: %s has %q, want %q (%s's line with the named swaps)", i, got, g, w, base) |
| + } |
| + } |
| +} |
| + |
| +// The tty template is the cmd template outside its named lines (rootfs |
| +// Plan 6, Task 5): the same uid, namespace, binds, slice and working |
| +// directory, so a session has exactly a command's reach, which is the |
| +// instance's. Its stdin is the agent's socket (PID 1 opens it as root, |
| +// outside the namespace, on the nosymfollow logs mount, as for the cmd |
| +// streams); stdout and stderr carry only the trampoline's own diagnostics, |
| +// since the tenant's stdio is the pty; and it binds its own executable |
| +// sources, tty-app and tty-live, which no other start writes. |
| +func TestTTYTemplateEqualsCmdOutsideTheNamedLines(t *testing.T) { |
| + equalOutsideTheNamedLines(t, "carlos-instance-cmd@.service", "carlos-instance-tty@.service", map[string][]string{ |
| + "Description=carlos exec-backed instance %I (cmd)": {"Description=carlos exec-backed instance %I (tty)"}, |
| + "ExecStart=/opt/carlos/carlos instance-exec cmd %I": {"ExecStart=/opt/carlos/carlos instance-exec tty %I"}, |
| + "ExecStopPost=/opt/carlos/carlos instance-exit cmd %I": {"ExecStopPost=/opt/carlos/carlos instance-exit tty %I"}, |
| + "StandardOutput=file:/run/carlos/logs/%I.cmd.sock": {"StandardInput=file:/run/carlos/logs/%I.tty.sock", "StandardOutput=journal"}, |
| + "StandardError=file:/run/carlos/logs/%I.cmd-err.sock": {"StandardError=journal"}, |
| + "BindReadOnlyPaths=/run/carlos-control/exe/%I/cmd-app:/opt/carlos/app /run/carlos-control/exe/%I/cmd-live:/opt/carlos/live": {"BindReadOnlyPaths=/run/carlos-control/exe/%I/tty-app:/opt/carlos/app /run/carlos-control/exe/%I/tty-live:/opt/carlos/live"}, |
| + }) |
| +} |
| + |
| // The generation template's instance string is "<iid>:<n>" (zero-downtime |
| // spec §7.6, plan 2 D1). No specifier can take the instance ID out of it, |
| // so the template keys NOTHING by %i or %I but the trampoline's argument. |
diff --git a/internal/host/units_rootfs_test.go b/internal/host/units_rootfs_test.go| index 10fc12245..b55325bc4 100644 |
| --- a/internal/host/units_rootfs_test.go |
| +++ b/internal/host/units_rootfs_test.go |
| @@ -5,7 +5,7 @@ import ( |
| "testing" |
| ) |
| -var rootfsTemplates = []string{"carlos-instance-rootfs@.service", "carlos-instance-rootfs-gen@.service", "carlos-instance-rootfs-worker@.service", "carlos-instance-rootfs-cmd@.service", "carlos-instance-rootfs-probe.service"} |
| +var rootfsTemplates = []string{"carlos-instance-rootfs@.service", "carlos-instance-rootfs-gen@.service", "carlos-instance-rootfs-worker@.service", "carlos-instance-rootfs-cmd@.service", "carlos-instance-rootfs-tty@.service", "carlos-instance-rootfs-probe.service"} |
| const ( |
| rootfsBlockStart = "# --- the rootfs namespace" |
| @@ -36,7 +36,7 @@ func rootfsOutsideBlock(t *testing.T, name string) string { |
| return u[:start] + u[end:] |
| } |
| -// The five rootfs units carry one restated namespace block, byte for byte, |
| +// The six rootfs units carry one restated namespace block, byte for byte, |
| // so a property the rootfs probe proves is the property a rootfs tenant |
| // gets (spec §5.3, §8; the binary templates' TestInstanceTemplatesShareOneNamespace). |
| func TestRootfsTemplatesShareOneNamespace(t *testing.T) { |
| @@ -78,7 +78,6 @@ func TestRootfsNamespaceRestatesTheBinaryBlock(t *testing.T) { |
| "MountAPIVFS=yes": true, |
| "TemporaryFileSystem=/tmp:mode=1777,nosuid,nodev": true, |
| "ProtectControlGroups=strict": true, |
| - "TemporaryFileSystem=/dev/pts:ro": true, // deviation 8; once Plan 6 adds it to the binary block it is kept, and Plan 6 drops this entry |
| } |
| for d := range bin { |
| if rfs[d] { |
| @@ -238,6 +237,14 @@ func TestRootfsTemplatesPerUnitLines(t *testing.T) { |
| "BindReadOnlyPaths=/run/carlos-control/exe/%I/rootfs/cmd/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/%I/rootfs/cmd/resolv.conf:/etc/resolv.conf", |
| "BindPaths=/data/instances/%I /run/carlos/instances/%I", "ReadWritePaths=/data/instances/%I /run/carlos/instances/%I", "Slice=carlos-instances-%i.slice", |
| "StandardOutput=file:/run/carlos/logs/%I.cmd.sock", "StandardError=file:/run/carlos/logs/%I.cmd-err.sock", "WorkingDirectory=/data/instances/%I"}, common...), |
| + // One interactive session (rootfs Plan 6): the rootfs cmd unit's |
| + // reach, stdin from the agent's socket, and the tty set of root's |
| + // files. |
| + "carlos-instance-rootfs-tty@.service": append([]string{"Type=oneshot", "RemainAfterExit=yes", "TimeoutStartSec=6h5m", "ExecStart=/opt/carlos/carlos instance-exec --rootfs tty %I", "ExecStopPost=/opt/carlos/carlos instance-exit --rootfs tty %I", |
| + "RootImage=/run/carlos-control/exe/%I/rootfs/tty/image", |
| + "BindReadOnlyPaths=/run/carlos-control/exe/%I/rootfs/tty/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/%I/rootfs/tty/resolv.conf:/etc/resolv.conf", |
| + "BindPaths=/data/instances/%I /run/carlos/instances/%I", "ReadWritePaths=/data/instances/%I /run/carlos/instances/%I", "Slice=carlos-instances-%i.slice", |
| + "StandardInput=file:/run/carlos/logs/%I.tty.sock", "StandardOutput=journal", "StandardError=journal", "WorkingDirectory=/data/instances/%I"}, common...), |
| "carlos-instance-rootfs-probe.service": {"Type=oneshot", "ExecStart=/opt/carlos/carlos instance-probe --rootfs", "RootImage=/run/carlos-control/exe/_probe/rootfs/run/image", |
| "BindPaths=/data/instances/_probe /run/carlos/instances/_probe", "ReadWritePaths=/data/instances/_probe /run/carlos/instances/_probe", "StandardOutput=truncate:/run/carlos-control/rootfs-probe.out", "Slice=carlos-instances.slice", "TasksMax=64", "MemoryMax=64M", "CPUQuota=50%", "CPUWeight=50", "IOWeight=50", "User=carlos", "Group=carlos", |
| "BindReadOnlyPaths=/run/carlos-control/exe/_probe/rootfs/run/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/_probe/rootfs/run/resolv.conf:/etc/resolv.conf /run/carlos-control/exe/_probe/rootfs/run/box-addrs:/opt/carlos/box-addrs"}, |
| @@ -251,7 +258,7 @@ func TestRootfsTemplatesPerUnitLines(t *testing.T) { |
| if strings.Contains(u, "ExecStopPost=+") { |
| t.Errorf("%s uses ExecStopPost=+ (codex R3-2)", name) |
| } |
| - if name == "carlos-instance-rootfs-cmd@.service" && strings.Contains(u, "\nSuccessExitStatus=") { |
| + if (name == "carlos-instance-rootfs-cmd@.service" || name == "carlos-instance-rootfs-tty@.service") && strings.Contains(u, "\nSuccessExitStatus=") { |
| t.Errorf("%s counts a signal's exit as success", name) |
| } |
| // Exactly one WorkingDirectory= per tenant template, and none in |
| @@ -352,6 +359,30 @@ func TestRootfsCmdTemplateEqualsRootfsOutsideTheNamedLines(t *testing.T) { |
| } |
| } |
| +// The rootfs tty template is the rootfs cmd template outside its named |
| +// lines (rootfs Plan 6, Task 5), as TestTTYTemplateEqualsCmdOutsideTheNamedLines |
| +// holds the binary pair: the same namespace block, binds, slice and working |
| +// directory, stdin from the agent's socket, and root's tty set of files |
| +// (rootfs/tty/ under the exe layout) where the command has its cmd set. The |
| +// image is the app: no tty-app or tty-live is bound. |
| +func TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines(t *testing.T) { |
| + t.Parallel() |
| + equalOutsideTheNamedLines(t, "carlos-instance-rootfs-cmd@.service", "carlos-instance-rootfs-tty@.service", map[string][]string{ |
| + "Description=carlos rootfs instance %I (cmd)": {"Description=carlos rootfs instance %I (tty)"}, |
| + "ExecStart=/opt/carlos/carlos instance-exec --rootfs cmd %I": {"ExecStart=/opt/carlos/carlos instance-exec --rootfs tty %I"}, |
| + "ExecStopPost=/opt/carlos/carlos instance-exit --rootfs cmd %I": {"ExecStopPost=/opt/carlos/carlos instance-exit --rootfs tty %I"}, |
| + "StandardOutput=file:/run/carlos/logs/%I.cmd.sock": {"StandardInput=file:/run/carlos/logs/%I.tty.sock", "StandardOutput=journal"}, |
| + "StandardError=file:/run/carlos/logs/%I.cmd-err.sock": {"StandardError=journal"}, |
| + "RootImage=/run/carlos-control/exe/%I/rootfs/cmd/image": {"RootImage=/run/carlos-control/exe/%I/rootfs/tty/image"}, |
| + "BindReadOnlyPaths=/run/carlos-control/exe/%I/rootfs/cmd/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/%I/rootfs/cmd/resolv.conf:/etc/resolv.conf": {"BindReadOnlyPaths=/run/carlos-control/exe/%I/rootfs/tty/launch.json:/opt/carlos/launch.json /run/carlos-control/exe/%I/rootfs/tty/resolv.conf:/etc/resolv.conf"}, |
| + }) |
| + for _, d := range directives(readUnit(t, "carlos-instance-rootfs-tty@.service")) { |
| + if strings.Contains(d, "rootfs/cmd/") || strings.Contains(d, "tty-app") || strings.Contains(d, "tty-live") { |
| + t.Errorf("rootfs tty template names %q: its sources are rootfs/tty/ and the image is the app", d) |
| + } |
| + } |
| +} |
| + |
| // Both probes are handed the box's own addresses as a root-owned file at |
| // /opt/carlos/box-addrs, and the instance templates are not (an instance |
| // has no business knowing them; the probe tests that they are closed). |
| @@ -362,7 +393,7 @@ func TestOnlyTheProbesBindTheBoxAddressList(t *testing.T) { |
| t.Errorf("%s does not bind /opt/carlos/box-addrs", name) |
| } |
| } |
| - for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-seed@.service", "carlos-instance-rootfs@.service", "carlos-instance-rootfs-gen@.service", "carlos-instance-rootfs-worker@.service", "carlos-instance-rootfs-cmd@.service"} { |
| + for _, name := range []string{"carlos-instance@.service", "carlos-instance-gen@.service", "carlos-instance-sidecar@.service", "carlos-instance-cmd@.service", "carlos-instance-tty@.service", "carlos-instance-seed@.service", "carlos-instance-rootfs@.service", "carlos-instance-rootfs-gen@.service", "carlos-instance-rootfs-worker@.service", "carlos-instance-rootfs-cmd@.service", "carlos-instance-rootfs-tty@.service"} { |
| if strings.Contains(readUnit(t, name), "box-addrs") { |
| t.Errorf("%s binds the box address list", name) |
| } |
diff --git a/internal/instancectl/names.go b/internal/instancectl/names.go| index f4d3be360..d107b17ed 100644 |
| --- a/internal/instancectl/names.go |
| +++ b/internal/instancectl/names.go |
| @@ -39,17 +39,25 @@ const ( |
| // has a rootfs template only, never a binary unit (UnitName answers "" |
| // for it). |
| RoleWorker Role = "worker" |
| + // RoleTTY is one interactive session (rootfs apps design §5.10): a |
| + // command whose stdio is a pty the agent holds. It has a binary |
| + // template and a rootfs one, as cmd does. |
| + RoleTTY Role = "tty" |
| ) |
| -// ParseRole accepts exactly the five literals. |
| +// ParseRole accepts exactly the six literals. |
| func ParseRole(s string) (Role, bool) { |
| switch Role(s) { |
| - case RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker: |
| + case RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker, RoleTTY: |
| return Role(s), true |
| } |
| return "", false |
| } |
| +// OneShot reports whether a role's unit runs one command to its end and |
| +// stays loaded until the agent has read the result: cmd and tty. |
| +func OneShot(r Role) bool { return r == RoleCmd || r == RoleTTY } |
| + |
| // Escape is systemd-escape(1)'s rule for a unit instance name: "/" becomes |
| // "-", a leading "." becomes "\x2e", and every byte outside [a-zA-Z0-9:_.] |
| // becomes "\x" plus two lowercase hex digits. For the identifiers this |
| @@ -75,13 +83,14 @@ func Escape(s string) string { |
| return b.String() |
| } |
| -// The four template prefixes. A unit under any of them is the platform's |
| -// to start, stop and sweep; nothing else is (design §5.3). |
| +// The five binary template prefixes. A unit under any of them is the |
| +// platform's to start, stop and sweep; nothing else is (design §5.3). |
| const ( |
| UnitPrefixRun = "carlos-instance@" |
| UnitPrefixSeed = "carlos-instance-seed@" |
| UnitPrefixSidecar = "carlos-instance-sidecar@" |
| UnitPrefixCmd = "carlos-instance-cmd@" |
| + UnitPrefixTTY = "carlos-instance-tty@" |
| ) |
| // The rootfs templates and the rootfs probe unit. A rootfs instance has |
| @@ -92,6 +101,7 @@ const ( |
| UnitPrefixRootfsGen = "carlos-instance-rootfs-gen@" |
| UnitPrefixRootfsWorker = "carlos-instance-rootfs-worker@" |
| UnitPrefixRootfsCmd = "carlos-instance-rootfs-cmd@" |
| + UnitPrefixRootfsTTY = "carlos-instance-rootfs-tty@" |
| RootfsProbeUnit = "carlos-instance-rootfs-probe.service" |
| ) |
| @@ -104,6 +114,18 @@ const ( |
| CmdExeLive = "cmd-live" |
| ) |
| +// TTYExeApp and TTYExeLive are the tty template's own executable mount |
| +// sources, as CmdExeApp and CmdExeLive are the cmd template's: a session |
| +// and a command starting on different builds never repoint each other's. |
| +const ( |
| + TTYExeApp = "tty-app" |
| + TTYExeLive = "tty-live" |
| +) |
| + |
| +// TTYHello is the one payload sent with the pty fd over the session's |
| +// socket. |
| +const TTYHello = "carlos-tty/1" |
| + |
| // prefixFor is the binary template of a role. It stays binary-only: a |
| // worker has no binary template, so it answers "" rather than falling to |
| // the run prefix (preflight 1.1), which would name the host's run unit. |
| @@ -115,6 +137,8 @@ func prefixFor(role Role) string { |
| return UnitPrefixSidecar |
| case RoleCmd: |
| return UnitPrefixCmd |
| + case RoleTTY: |
| + return UnitPrefixTTY |
| case RoleWorker: |
| return "" |
| } |
| @@ -122,7 +146,7 @@ func prefixFor(role Role) string { |
| } |
| // UnitName is the template instance for a role and a host: |
| -// carlos-instance[-seed|-sidecar|-cmd]@<Escape(InstanceID(host))>.service. |
| +// carlos-instance[-seed|-sidecar|-cmd|-tty]@<Escape(InstanceID(host))>.service. |
| // It is "" for RoleWorker, which has no binary unit; a caller handed "" |
| // refuses. |
| func UnitName(role Role, host string) string { |
| @@ -241,10 +265,10 @@ func GenLogSocket(host string, n uint64) string { |
| return filepath.Join(provision.SocketDir, "logs", GenKey(host, n)+".run.sock") |
| } |
| -// RootfsUnitName is the rootfs template instance for RoleRun or RoleCmd: |
| -// carlos-instance-rootfs[-cmd]@<Escape(InstanceID(host))>.service. It is "" |
| -// for any other role: seed and sidecar have no rootfs template, and a |
| -// worker's unit is WorkerUnitName. |
| +// RootfsUnitName is the rootfs template instance for RoleRun, RoleCmd or |
| +// RoleTTY: carlos-instance-rootfs[-cmd|-tty]@<Escape(InstanceID(host))>.service. |
| +// It is "" for any other role: seed and sidecar have no rootfs template, |
| +// and a worker's unit is WorkerUnitName. |
| func RootfsUnitName(role Role, host string) string { |
| var prefix string |
| switch role { |
| @@ -252,6 +276,8 @@ func RootfsUnitName(role Role, host string) string { |
| prefix = UnitPrefixRootfs |
| case RoleCmd: |
| prefix = UnitPrefixRootfsCmd |
| + case RoleTTY: |
| + prefix = UnitPrefixRootfsTTY |
| default: |
| return "" |
| } |
| @@ -374,7 +400,7 @@ func IsRootfsUnit(unit string) bool { |
| if !found { |
| return false |
| } |
| - for _, prefix := range []string{UnitPrefixRootfs, UnitPrefixRootfsGen, UnitPrefixRootfsWorker, UnitPrefixRootfsCmd} { |
| + for _, prefix := range []string{UnitPrefixRootfs, UnitPrefixRootfsGen, UnitPrefixRootfsWorker, UnitPrefixRootfsCmd, UnitPrefixRootfsTTY} { |
| if inst, found := strings.CutPrefix(body, prefix); found && inst != "" { |
| return true |
| } |
| @@ -434,8 +460,8 @@ func ParseUnitName(unit string) (Role, string, bool) { |
| prefix string |
| role Role |
| }{ |
| - {UnitPrefixSeed, RoleSeed}, {UnitPrefixSidecar, RoleSidecar}, {UnitPrefixCmd, RoleCmd}, |
| - {UnitPrefixRootfsCmd, RoleCmd}, {UnitPrefixRootfs, RoleRun}, |
| + {UnitPrefixSeed, RoleSeed}, {UnitPrefixSidecar, RoleSidecar}, {UnitPrefixCmd, RoleCmd}, {UnitPrefixTTY, RoleTTY}, |
| + {UnitPrefixRootfsCmd, RoleCmd}, {UnitPrefixRootfsTTY, RoleTTY}, {UnitPrefixRootfs, RoleRun}, |
| {UnitPrefixRun, RoleRun}, |
| } { |
| if strings.HasPrefix(body, p.prefix) { |
diff --git a/internal/instancectl/names_test.go b/internal/instancectl/names_test.go| index cac2fe1f0..a5bce6779 100644 |
| --- a/internal/instancectl/names_test.go |
| +++ b/internal/instancectl/names_test.go |
| @@ -260,3 +260,74 @@ func TestWorkerUnitNameEscapesHyphensAndRefusesOtherSpellings(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// The tty role (rootfs Plan 6, Task 5): one interactive session's unit, |
| +// binary and rootfs, named like the cmd role's and parsed back to RoleTTY. |
| +func TestRoleTTYNames(t *testing.T) { |
| + const host = "bill-2.example.com" |
| + esc := `bill\x2d2.example.com` |
| + if r, ok := ParseRole("tty"); !ok || r != RoleTTY { |
| + t.Fatalf("ParseRole(tty) = %q %v", r, ok) |
| + } |
| + for _, s := range []string{"TTY", "tty ", "pty", "tty-app"} { |
| + if _, ok := ParseRole(s); ok { |
| + t.Errorf("ParseRole(%q) accepted", s) |
| + } |
| + } |
| + // The five earlier literals still parse. |
| + for _, r := range []Role{RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker} { |
| + if got, ok := ParseRole(string(r)); !ok || got != r { |
| + t.Errorf("ParseRole(%q) = %q %v", r, got, ok) |
| + } |
| + } |
| + if UnitPrefixTTY != "carlos-instance-tty@" || UnitPrefixRootfsTTY != "carlos-instance-rootfs-tty@" { |
| + t.Errorf("prefixes = %q %q", UnitPrefixTTY, UnitPrefixRootfsTTY) |
| + } |
| + if TTYExeApp != "tty-app" || TTYExeLive != "tty-live" || TTYHello != "carlos-tty/1" { |
| + t.Errorf("tty constants = %q %q %q", TTYExeApp, TTYExeLive, TTYHello) |
| + } |
| + unit := UnitName(RoleTTY, host) |
| + if unit != `carlos-instance-tty@bill\x2d2.example.com.service` { |
| + t.Errorf("UnitName(RoleTTY) = %q", unit) |
| + } |
| + if r, e, ok := ParseUnitName(unit); !ok || r != RoleTTY || e != esc { |
| + t.Errorf("ParseUnitName(%q) = %q %q %v", unit, r, e, ok) |
| + } |
| + if IsRootfsUnit(unit) { |
| + t.Errorf("IsRootfsUnit(%q) = true for the binary tty unit", unit) |
| + } |
| + rootfs := RootfsUnitName(RoleTTY, host) |
| + if rootfs != `carlos-instance-rootfs-tty@bill\x2d2.example.com.service` { |
| + t.Errorf("RootfsUnitName(RoleTTY) = %q", rootfs) |
| + } |
| + if r, e, ok := ParseUnitName(rootfs); !ok || r != RoleTTY || e != esc { |
| + t.Errorf("ParseUnitName(%q) = %q %q %v", rootfs, r, e, ok) |
| + } |
| + if !IsRootfsUnit(rootfs) { |
| + t.Errorf("IsRootfsUnit(%q) = false", rootfs) |
| + } |
| + // The templates themselves are not instances. |
| + for _, bad := range []string{"carlos-instance-tty@.service", "carlos-instance-rootfs-tty@.service"} { |
| + if _, _, ok := ParseUnitName(bad); ok { |
| + t.Errorf("ParseUnitName(%q) accepted a template", bad) |
| + } |
| + if IsRootfsUnit(bad) { |
| + t.Errorf("IsRootfsUnit(%q) = true for a template", bad) |
| + } |
| + } |
| + // The tty units are never the cmd role's, either way round. |
| + if r, _, _ := ParseUnitName(UnitName(RoleCmd, host)); r != RoleCmd { |
| + t.Errorf("the cmd unit parses as %q", r) |
| + } |
| + if r, _, _ := ParseUnitName(RootfsUnitName(RoleCmd, host)); r != RoleCmd { |
| + t.Errorf("the rootfs cmd unit parses as %q", r) |
| + } |
| + if got := RootfsExeDir("/run/carlos-control/exe", "shop.example.com", RoleTTY); got != "/run/carlos-control/exe/shop.example.com/rootfs/tty" { |
| + t.Errorf("RootfsExeDir(RoleTTY) = %q", got) |
| + } |
| + for r, want := range map[Role]bool{RoleCmd: true, RoleTTY: true, RoleRun: false, RoleSeed: false, RoleSidecar: false, RoleWorker: false} { |
| + if OneShot(r) != want { |
| + t.Errorf("OneShot(%q) = %v, want %v", r, !want, want) |
| + } |
| + } |
| +} |
diff --git a/internal/instanceexec/probe.go b/internal/instanceexec/probe.go| index a379a686b..c76ace648 100644 |
| --- a/internal/instanceexec/probe.go |
| +++ b/internal/instanceexec/probe.go |
| @@ -72,8 +72,8 @@ type probeEnv struct { |
| // The terminal devices PrivateDevices= carries into a private /dev |
| // (Plan 2 deviation 8): devPts is /dev/pts, and openPtmx opens |
| - // /dev/ptmx (O_RDWR|O_NOCTTY) and closes it at once. Read by the |
| - // rootfs probe's pts-private line; Plan 6 adds it to this probe. |
| + // /dev/ptmx (O_RDWR|O_NOCTTY) and closes it at once. Read by both |
| + // probes' pts-private line (rootfs Plan 6 added the binary one). |
| devPts string |
| openPtmx func() error |
| // boxAddrs is instancectl.BoxAddrsPath: root's list of the box's own |
| @@ -142,6 +142,12 @@ func productionProbeEnv() probeEnv { |
| selfCgroup: ownCgroupDir, |
| ioEnforced: ioWeightEnforced, |
| + // The pts-private line (rootfs Plan 6, PF-8): the namespace block |
| + // hides /dev/pts, and these are what the line reads. openPtmx is |
| + // the real open on Linux and the !linux stub elsewhere. |
| + devPts: "/dev/pts", |
| + openPtmx: openPtmx, |
| + |
| boxAddrs: instancectl.BoxAddrsPath, |
| mmapWX: realMmapWX, |
| } |
| @@ -244,6 +250,10 @@ func runChecks(e probeEnv) instancectl.ProbeReport { |
| controlUnreachableCheck(e, v) |
| etcCarlosCheck(e, v) |
| shmPrivateCheck(e, v) |
| + // The host's terminals are out of reach (rootfs Plan 6): the block's |
| + // TemporaryFileSystem=/dev/pts:ro, as in the rootfs probe. |
| + detail, ok = ptsPrivate(e) |
| + v.pass("pts-private", detail, ok) |
| symlinkChecks(e, v) |
| imdsChecks(e, v) |
diff --git a/internal/instanceexec/probe_hardening.go b/internal/instanceexec/probe_hardening.go| index d419dcfe7..0dabf5f39 100644 |
| --- a/internal/instanceexec/probe_hardening.go |
| +++ b/internal/instanceexec/probe_hardening.go |
| @@ -206,7 +206,7 @@ func mdweHeld(e probeEnv) (detail string, ok bool) { |
| // ptsPrivate is the pts-private line (Plan 2 deviation 8): the private |
| // /dev carries no terminal of the host's. /dev/pts lists nothing and |
| // /dev/ptmx cannot be opened, so no pty can be made or reached from in |
| -// here. The rootfs probe runs it; Plan 6 adds it to the binary probe. |
| +// here. Both probes run it (rootfs Plan 6 added it to the binary probe). |
| func ptsPrivate(e probeEnv) (detail string, ok bool) { |
| d, empty := exactly(e.devPts) |
| perr := e.openPtmx() |
diff --git a/internal/instanceexec/probe_rootfs_linux.go b/internal/instanceexec/probe_rootfs_linux.go| index d57ac7da6..1a9b02b69 100644 |
| --- a/internal/instanceexec/probe_rootfs_linux.go |
| +++ b/internal/instanceexec/probe_rootfs_linux.go |
| @@ -16,8 +16,6 @@ import ( |
| // the image root's own. |
| func productionRootfsProbeEnv() rootfsProbeEnv { |
| e := productionProbeEnv() |
| - e.devPts = "/dev/pts" |
| - e.openPtmx = openPtmx |
| e.selfCgroup = func() (string, error) { return rootfsOwnCgroup("/proc/self/cgroup", cgroupMountpoint) } |
| return rootfsProbeEnv{ |
| probeEnv: e, |
diff --git a/internal/instanceexec/probe_rootfs_other.go b/internal/instanceexec/probe_rootfs_other.go| index 715743dc3..b9af0b665 100644 |
| --- a/internal/instanceexec/probe_rootfs_other.go |
| +++ b/internal/instanceexec/probe_rootfs_other.go |
| @@ -4,12 +4,15 @@ package instanceexec |
| import "errors" |
| +// openPtmx off Linux keeps the package building: the probe only runs |
| +// inside a systemd namespace on Linux. |
| +func openPtmx() error { return errors.ErrUnsupported } |
| + |
| // productionRootfsProbeEnv has nothing to probe off Linux: every line |
| // that touches the namespace fails. |
| func productionRootfsProbeEnv() rootfsProbeEnv { |
| unsupported := func(string) error { return errors.ErrUnsupported } |
| e := productionProbeEnv() |
| - e.openPtmx = func() error { return errors.ErrUnsupported } |
| return rootfsProbeEnv{ |
| probeEnv: e, |
| ownerUID: func(string) (uint32, error) { return 0, errors.ErrUnsupported }, |
diff --git a/internal/instanceexec/probe_test.go b/internal/instanceexec/probe_test.go| index f91288c2c..257710765 100644 |
| --- a/internal/instanceexec/probe_test.go |
| +++ b/internal/instanceexec/probe_test.go |
| @@ -61,6 +61,7 @@ func goodEnv(t *testing.T) probeEnv { |
| t.Fatal(err) |
| } |
| mqueue := mk("dev/mqueue") |
| + pts := mk("dev/pts") |
| cg := mk("cgroup/self") |
| for name, v := range map[string]string{"cpu.max": "50000 100000\n", "cpu.weight": "50\n", "io.weight": "default 50\n"} { |
| if err := os.WriteFile(filepath.Join(cg, name), []byte(v), 0o644); err != nil { |
| @@ -92,6 +93,10 @@ func goodEnv(t *testing.T) probeEnv { |
| selfCgroup: func() (string, error) { return cg, nil }, |
| ioEnforced: func(string) bool { return true }, |
| + // The hidden /dev/pts: an empty tmpfs, so /dev/ptmx (systemd's |
| + // link to pts/ptmx in a private /dev) has nothing behind it. |
| + devPts: pts, |
| + openPtmx: func() error { return syscall.ENOENT }, |
| boxAddrs: boxAddrs, |
| // MemoryDenyWriteExecute=yes as systemd 257 sets it on a 6.3+ |
| // kernel (PR_SET_MDWE). |
| @@ -124,7 +129,7 @@ func TestProbePassesOnAnIsolatedNamespace(t *testing.T) { |
| t.Fatalf("not ready: %+v", r.Lines) |
| } |
| for _, c := range []string{"data-tree", "run-tree", "var-empty", "pid1", "cgroup-ro", "cgroup-ro-mount", "control-unreachable", "etc-carlos", "shm-private", "symlink-eloop", "nosymfollow", "imds-v4", "imds-v6", "imds-tcp", |
| - "opt-own-build", "dns", "resolver-ports", "loopback-v4", "loopback-v6", "private-v4", "private-v6", "box-addr", "mdwe", "ipc-private", "abstract-unix", "cpu-limits", "io-weight"} { |
| + "opt-own-build", "dns", "resolver-ports", "loopback-v4", "loopback-v6", "private-v4", "private-v6", "box-addr", "mdwe", "ipc-private", "abstract-unix", "cpu-limits", "io-weight", "pts-private"} { |
| if v := verdict(r, c); v != "ok" { |
| t.Errorf("%s = %s", c, v) |
| } |
| @@ -394,3 +399,67 @@ func shortProbeSocketDir(t *testing.T) string { |
| }) |
| return dir |
| } |
| + |
| +// The binary probe's pts-private line (rootfs Plan 6, Task 5): the |
| +// namespace block hides the host's /dev/pts, which PrivateDevices= would |
| +// bind into the private /dev, so a tenant can neither list a terminal nor |
| +// make one. Both halves must hold, and each alone fails the box. |
| +func TestProbePtsPrivate(t *testing.T) { |
| + if r := runChecks(goodEnv(t)); !r.Ready || verdict(r, "pts-private") != "ok" || countLines(r, "pts-private") != 1 { |
| + t.Fatalf("hidden /dev/pts: ready=%v pts-private=%s %s", r.Ready, verdict(r, "pts-private"), detail(r, "pts-private")) |
| + } |
| + e := goodEnv(t) |
| + if err := os.WriteFile(filepath.Join(e.devPts, "0"), nil, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if r := runChecks(e); r.Ready || verdict(r, "pts-private") != "fail" || !strings.Contains(detail(r, "pts-private"), "[0]") { |
| + t.Errorf("a /dev/pts listing a terminal: ready=%v pts-private=%s %s", r.Ready, verdict(r, "pts-private"), detail(r, "pts-private")) |
| + } |
| + e = goodEnv(t) |
| + e.openPtmx = func() error { return nil } |
| + if r := runChecks(e); r.Ready || verdict(r, "pts-private") != "fail" || !strings.Contains(detail(r, "pts-private"), "/dev/ptmx opened") { |
| + t.Errorf("an openable /dev/ptmx: ready=%v pts-private=%s %s", r.Ready, verdict(r, "pts-private"), detail(r, "pts-private")) |
| + } |
| + // A /dev/pts that cannot be listed is not evidence it is empty. |
| + e = goodEnv(t) |
| + e.devPts = filepath.Join(e.devPts, "absent") |
| + if r := runChecks(e); r.Ready || verdict(r, "pts-private") != "fail" { |
| + t.Errorf("an unlistable /dev/pts passed: %s", detail(r, "pts-private")) |
| + } |
| +} |
| + |
| +// PF-8: the binary probe's production env sets both fields the |
| +// pts-private line reads. Without them the line fails on every box (an |
| +// empty path lists nothing, a nil openPtmx panics) and every box loses |
| +// nested readiness at roll. |
| +func TestBinaryProbeEnvWiresPts(t *testing.T) { |
| + e := productionProbeEnv() |
| + if e.devPts != "/dev/pts" { |
| + t.Errorf("productionProbeEnv().devPts = %q, want /dev/pts", e.devPts) |
| + } |
| + if e.openPtmx == nil { |
| + t.Fatal("productionProbeEnv().openPtmx is nil") |
| + } |
| + // The line answers through the env's own fields: an empty directory |
| + // and an openPtmx that fails read ok, whatever this host's /dev holds. |
| + e.devPts = t.TempDir() |
| + e.openPtmx = func() error { return syscall.ENOENT } |
| + if d, ok := ptsPrivate(e); !ok { |
| + t.Errorf("ptsPrivate over the production env with a hidden /dev/pts = %q, false", d) |
| + } |
| + // And the production openPtmx is the real open of /dev/ptmx: on this |
| + // host (no namespace) it agrees with a direct open. |
| + f, derr := os.OpenFile("/dev/ptmx", os.O_RDWR|syscall.O_NOCTTY, 0) |
| + if derr == nil { |
| + f.Close() |
| + } |
| + perr := productionProbeEnv().openPtmx() |
| + if (derr == nil) != (perr == nil) { |
| + t.Errorf("production openPtmx = %v, a direct open of /dev/ptmx = %v", perr, derr) |
| + } |
| + // The rootfs probe's env inherits the same wiring. |
| + re := productionRootfsProbeEnv() |
| + if re.devPts != "/dev/pts" || re.openPtmx == nil { |
| + t.Errorf("productionRootfsProbeEnv() devPts=%q openPtmx nil=%v", re.devPts, re.openPtmx == nil) |
| + } |
| +} |
diff --git a/internal/layout/plan.go b/internal/layout/plan.go| index 83222615d..92764c894 100644 |
| --- a/internal/layout/plan.go |
| +++ b/internal/layout/plan.go |
| @@ -211,7 +211,7 @@ func NestedPlatformNames(host string) map[string]bool { |
| out[db+activator.SeedMarkerSuffix] = true |
| out[filesMarkerName] = true |
| out[host+instancekey.AdoptionSuffix] = true |
| - for _, role := range []instancectl.Role{instancectl.RoleRun, instancectl.RoleSeed, instancectl.RoleSidecar, instancectl.RoleCmd} { |
| + for _, role := range []instancectl.Role{instancectl.RoleRun, instancectl.RoleSeed, instancectl.RoleSidecar, instancectl.RoleCmd, instancectl.RoleTTY} { |
| out[instancectl.LaunchFileName(role)] = true |
| } |
| return out |
diff --git a/internal/layout/plan_test.go b/internal/layout/plan_test.go| index eaebf3593..6784d856a 100644 |
| --- a/internal/layout/plan_test.go |
| +++ b/internal/layout/plan_test.go |
| @@ -165,7 +165,7 @@ func TestNestedPlatformNamesAreThePlansRawNames(t *testing.T) { |
| ".activator-" + h + ".db-litestream": true, ".files-gen": true, |
| h + ".db.gen": true, h + ".db-litestream": true, h + ".instance-key-adoption.json": true, |
| h + ".db.seed": true, |
| - "launch.run.json": true, "launch.seed.json": true, "launch.sidecar.json": true, "launch.cmd.json": true, |
| + "launch.run.json": true, "launch.seed.json": true, "launch.sidecar.json": true, "launch.cmd.json": true, "launch.tty.json": true, |
| } |
| if len(got) != len(want) { |
| t.Fatalf("NestedPlatformNames = %v, want %v", got, want) |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 63d7cae98..907c6465b 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -43,4 +43,4 @@ plan14-root-reads-region-ha-dead-holder-backoff.tsv 8f6a1865b0abcea9d4fb68232cc2 |
| plan14-root-reads-managed-fleets-1c-451.tsv af326671321edda76c7e6217a47892605a9e3b886fa880ad6d049c2f28f63873 |
| plan14-root-reads-fleet-public-routes.tsv bca6ef741a96b72767b1747789cd01b3111d61b68548cbe368258c31f3d53a2e |
| plan14-root-reads-fleet-routes-followups.tsv 1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7 |
| -plan14-root-reads-rootfs-apps-6.tsv d62fb15b639f48fde409606adcd630322d8c4b8cc5937ea9a257a4969ddc8f5a |
| +plan14-root-reads-rootfs-apps-6.tsv 5491ec585a12b07e249fe1e680cadc7463c985f63fefcea1330c03dbf38f82ed |
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv| index ce24f3163..9f9abb140 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv |
| @@ -1,7 +1,32 @@ |
| # Census overlay rootfs-apps-6, written by census-propose (#369). census-ruling-rootfs-apps-6, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-rootfs-apps-6.md. |
| -# 1 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 9 body, 0 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy ee96c9cf9e4e6b0dea8325a3eaf0053773b3a20d3940afe881a0db8aa71b2d23 internal/host/units/carlos-instance-cmd@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the cmd unit template (applied by PID 1 as root; its process runs as carlos): extends the J4 seed pattern to the run role. The template equals the seed template outside named lines, and the template-equality test pins that. Root lays out a staged executable validated by the same refuseStagedExe the seed and generation paths use, then starts this unit, which runs as carlos with the instance's own reach. No new trust of registry, /data or agent-asserted content beyond the seed path;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 925113f4c51c091f0da65c2c67c5902aa35ab37abbe6491ca935820517e8149d |
| +@legacy c986824bab7acb9d785c21f3a48d18f8e678d9252eaea80839ec869f52787a5e internal/host/units/carlos-instance-gen@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 0bd25fefd9306449d55e235e9bd8986466bc4cd68ad56b5614d32596ce39c262 |
| +@legacy 21c72b17e5c5abd6e63a6ab3df1976ddc9afacf88a0e4b3e2e27b6e881c73b9d internal/host/units/carlos-instance-probe.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=one more BindReadOnlyPaths= line, so PID 1 opens one more bind source: /run/carlos-control/exe/_probe/box-addrs, bound to /opt/carlos/box-addrs, root's list of the box's own addresses, which RunProbe writes before every run (#367) in the root-only directory the unit already binds from; no tenant, app or agent input names or writes it;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service, so the probe proves what the tenants get (its new pts-private line); nothing else file:external@0 0eaa68abc2c041aeac8ae3b52bc512bd28cf1dacf7580c29b05630d14ef80a67 |
| +@legacy 455d36b55c3d97593df35538d23dbb6a698875cdc63451f11eb09da0507ac05d internal/host/units/carlos-instance-seed@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 bfc1af41ba6317bdd8595b8f25869cc45835649966ca2ab89373f4ececd8fd73 |
| +@legacy eb66783c14afecf46fc2add7bddc9544847f396658626ce8139d7a028f5905cf internal/host/units/carlos-instance-sidecar@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 aed2039fd622fc3fa8455d21d9da0e55cd73ddc02b399482d75d546e0b310a30 |
| +@legacy 1572962cee0ed81c0ec52934c14b5f762d0b6643047c8790ec85daa26db14d0a internal/host/units/carlos-instance@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) file:external@0 9454117e9e93f85aded1e9ee9ef27d7a90c99e0e3b6ceecd4ea82eed9e30cf4c |
| +@legacy 91c30b88818f28be789a268b87d768fb3e77986e1c0316ccb54b897e5bb1dad4 internal/instanceexec/probe.go productionProbeEnv legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); the same direct site, no new root read data-literal@67 e03d88c7883f4f64e132fc751c9641aa4c8adb54eff113a6e9eed0511be67315 |
| +@legacy 7282b3718ce918bbd9d7e4dce31a4737bca6eddb45048749c502c8261c740cf8 internal/layout/plan.go NestedPlatformNames legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing data-literal@84 faf3813dcb08f2e153a45b53f4461899327775c298419fc7fe817e80110119d0 |
| @legacy 438a9858d01281800b89923ab2c4bf47bba5c3eab23e07fe43af9a5e3a9ae755 internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call registry:Account@36233,registry:Account@37498,registry:Account@55577,registry:Account@55623,registry:Account@56467,registry:Account@56844,registry:Account@57070,registry:Account@57137,registry:Account@57183,registry:Account@57276,registry:Account@57318,registry:Account@57966,registry:Account@58224,registry:Account@58764,registry:Account@58812,registry:Account@59185,registry:Account@59231,registry:Account@59476,registry:Account@59901,registry:Account@60389,registry:Account@61125,registry:Account@61318,registry:Account@61664,registry:Account@62229,registry:App@36206,registry:App@37471,registry:App@55597,registry:App@55635,registry:App@56479,registry:App@56856,registry:App@57082,registry:App@57157,registry:App@57195,registry:App@57296,registry:App@57978,registry:App@58236,registry:App@58776,registry:App@58824,registry:App@59205,registry:App@59243,registry:App@59488,registry:App@59913,registry:App@60401,registry:App@61137,registry:App@61330,registry:App@61676,registry:App@62241,registry:ClaimOwnership@36820,registry:DBPath@45677,registry:DBPath@45692,registry:DBPath@45938,registry:DBPath@46541,registry:DBPath@46554,registry:EgressAllow@35319,registry:Gate@42022,registry:Gate@42162,registry:Gate@42449,registry:Hibernate@40694,registry:Hibernate@40892,registry:Hibernate@40957,registry:Hibernate@41296,registry:Hibernate@41647,registry:Hibernate@41957,registry:HoldOp@60870,registry:HoldOp@60961,registry:HoldOp@61096,registry:HoldOp@61472,registry:Host@26327,registry:Host@55556,registry:Host@56443,registry:Host@56820,registry:Host@56984,registry:Host@57090,registry:Host@57986,registry:Host@58192,registry:Host@59068,registry:Host@59340,registry:Host@59455,registry:Host@59778,registry:Host@59875,registry:Host@60266,registry:Host@60363,registry:Host@60577,registry:Host@60952,registry:Host@61087,registry:Host@61291,registry:Host@61364,registry:Host@61463,registry:Host@61638,registry:Host@61713,registry:Host@61799,registry:Host@62206,registry:Kind@36962,registry:Kind@37225,registry:Kind@45595,registry:Kind@45608,registry:Kind@45718,registry:Kind@45731,registry:Kind@46452,registry:Kind@46463,registry:Kind@54680,registry:Kind@60568,registry:Kind@61078,registry:Kind@61454,registry:Kind@61629,registry:Kind@61790,registry:PolicyExpiresAt@35344,registry:Pool@54766,registry:Provisioned@36182,registry:Provisioned@37447,registry:Provisioned@54725,registry:RateLimit@42535,registry:RateLimit@42686,registry:RateLimit@42973,registry:Region@54755,registry:Replication@41381,registry:Replication@41508,registry:Runtime@28984,registry:Runtime@29162,registry:Runtime@31367,registry:Runtime@40061,registry:Runtime@40115,registry:Runtime@40319,registry:Seed@44075,registry:SeedSource@43558,registry:Size@35335,registry:Socket@45643,registry:Socket@45658,registry:Socket@45955,registry:Socket@46511,registry:Socket@46524,registry:Unit@45561,registry:Unit@45574,registry:Unit@46478,registry:Unit@46489,whole:ClaimOwnership@36823,whole:ClaimOwnership@36840,whole:Route@26309,whole:Route@26320,whole:Route@26338,whole:Route@27619,whole:Route@29479,whole:Route@29486,whole:Route@29526,whole:Route@29887,whole:Route@30225,whole:Route@30672,whole:Route@30723,whole:Route@30760,whole:Route@32432,whole:Route@32641,whole:Route@32980,whole:Route@32989,whole:Route@33035,whole:Route@35268,whole:Route@35827,whole:Route@36298,whole:Route@36308,whole:Route@36665,whole:Route@36672,whole:Route@36740,whole:Route@37063,whole:Route@38096,whole:Route@41047,whole:Route@45787,whole:Route@47373,whole:Route@47418,whole:Route@47428,whole:Route@48298,whole:Route@49325,whole:Route@54791,whole:Route@54939,whole:Route@56036,whole:Route@56395,whole:Route@56777,whole:Route@61551,whole:Route@62136,whole:Route@62186 be1b699f14a2f8d6935d959dee168bdf6fb556cd78da458f5ba8a1c0e8512a17 |
| +@legacy a51e04d46da95100335449f3aeeb490bf419c089a5924e26288ccfe192257535 internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Nothing starts it yet (Task 6) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953 |
| +@legacy dc75d2ec43e68117fd04c29c2c90eb33b8eaa4cc3b4aa7531e423eb1c2d012ac internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Nothing starts it yet (Task 6 adds POST /tty) file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d |
| +internal/host/units/carlos-instance-cmd@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the cmd unit template (applied by PID 1 as root; its process runs as carlos): extends the J4 seed pattern to the run role. The template equals the seed template outside named lines, and the template-equality test pins that. Root lays out a staged executable validated by the same refuseStagedExe the seed and generation paths use, then starts this unit, which runs as carlos with the instance's own reach. No new trust of registry, /data or agent-asserted content beyond the seed path;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 925113f4c51c091f0da65c2c67c5902aa35ab37abbe6491ca935820517e8149d |
| +internal/host/units/carlos-instance-gen@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 0bd25fefd9306449d55e235e9bd8986466bc4cd68ad56b5614d32596ce39c262 |
| +internal/host/units/carlos-instance-probe.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=one more BindReadOnlyPaths= line, so PID 1 opens one more bind source: /run/carlos-control/exe/_probe/box-addrs, bound to /opt/carlos/box-addrs, root's list of the box's own addresses, which RunProbe writes before every run (#367) in the root-only directory the unit already binds from; no tenant, app or agent input names or writes it;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service, so the probe proves what the tenants get (its new pts-private line); nothing else file:external@0 0eaa68abc2c041aeac8ae3b52bc512bd28cf1dacf7580c29b05630d14ef80a67 |
| +internal/host/units/carlos-instance-seed@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 bfc1af41ba6317bdd8595b8f25869cc45835649966ca2ab89373f4ececd8fd73 |
| +internal/host/units/carlos-instance-sidecar@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 aed2039fd622fc3fa8455d21d9da0e55cd73ddc02b399482d75d546e0b310a30 |
| +internal/host/units/carlos-instance@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) file:external@0 9454117e9e93f85aded1e9ee9ef27d7a90c99e0e3b6ceecd4ea82eed9e30cf4c |
| +internal/instanceexec/probe.go productionProbeEnv legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); the same direct site, no new root read data-literal@67 e03d88c7883f4f64e132fc751c9641aa4c8adb54eff113a6e9eed0511be67315 |
| +internal/layout/plan.go NestedPlatformNames legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing data-literal@84 faf3813dcb08f2e153a45b53f4461899327775c298419fc7fe817e80110119d0 |
| internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call registry:Account@36233,registry:Account@37498,registry:Account@55577,registry:Account@55623,registry:Account@56467,registry:Account@56844,registry:Account@57070,registry:Account@57137,registry:Account@57183,registry:Account@57276,registry:Account@57318,registry:Account@57966,registry:Account@58224,registry:Account@58764,registry:Account@58812,registry:Account@59185,registry:Account@59231,registry:Account@59476,registry:Account@59901,registry:Account@60389,registry:Account@61125,registry:Account@61318,registry:Account@61664,registry:Account@62229,registry:App@36206,registry:App@37471,registry:App@55597,registry:App@55635,registry:App@56479,registry:App@56856,registry:App@57082,registry:App@57157,registry:App@57195,registry:App@57296,registry:App@57978,registry:App@58236,registry:App@58776,registry:App@58824,registry:App@59205,registry:App@59243,registry:App@59488,registry:App@59913,registry:App@60401,registry:App@61137,registry:App@61330,registry:App@61676,registry:App@62241,registry:ClaimOwnership@36820,registry:DBPath@45677,registry:DBPath@45692,registry:DBPath@45938,registry:DBPath@46541,registry:DBPath@46554,registry:EgressAllow@35319,registry:Gate@42022,registry:Gate@42162,registry:Gate@42449,registry:Hibernate@40694,registry:Hibernate@40892,registry:Hibernate@40957,registry:Hibernate@41296,registry:Hibernate@41647,registry:Hibernate@41957,registry:HoldOp@60870,registry:HoldOp@60961,registry:HoldOp@61096,registry:HoldOp@61472,registry:Host@26327,registry:Host@55556,registry:Host@56443,registry:Host@56820,registry:Host@56984,registry:Host@57090,registry:Host@57986,registry:Host@58192,registry:Host@59068,registry:Host@59340,registry:Host@59455,registry:Host@59778,registry:Host@59875,registry:Host@60266,registry:Host@60363,registry:Host@60577,registry:Host@60952,registry:Host@61087,registry:Host@61291,registry:Host@61364,registry:Host@61463,registry:Host@61638,registry:Host@61713,registry:Host@61799,registry:Host@62206,registry:Kind@36962,registry:Kind@37225,registry:Kind@45595,registry:Kind@45608,registry:Kind@45718,registry:Kind@45731,registry:Kind@46452,registry:Kind@46463,registry:Kind@54680,registry:Kind@60568,registry:Kind@61078,registry:Kind@61454,registry:Kind@61629,registry:Kind@61790,registry:PolicyExpiresAt@35344,registry:Pool@54766,registry:Provisioned@36182,registry:Provisioned@37447,registry:Provisioned@54725,registry:RateLimit@42535,registry:RateLimit@42686,registry:RateLimit@42973,registry:Region@54755,registry:Replication@41381,registry:Replication@41508,registry:Runtime@28984,registry:Runtime@29162,registry:Runtime@31367,registry:Runtime@40061,registry:Runtime@40115,registry:Runtime@40319,registry:Seed@44075,registry:SeedSource@43558,registry:Size@35335,registry:Socket@45643,registry:Socket@45658,registry:Socket@45955,registry:Socket@46511,registry:Socket@46524,registry:Unit@45561,registry:Unit@45574,registry:Unit@46478,registry:Unit@46489,whole:ClaimOwnership@36823,whole:ClaimOwnership@36840,whole:Route@26309,whole:Route@26320,whole:Route@26338,whole:Route@27619,whole:Route@29479,whole:Route@29486,whole:Route@29526,whole:Route@29887,whole:Route@30225,whole:Route@30672,whole:Route@30723,whole:Route@30760,whole:Route@32432,whole:Route@32641,whole:Route@32980,whole:Route@32989,whole:Route@33035,whole:Route@35268,whole:Route@35827,whole:Route@36298,whole:Route@36308,whole:Route@36665,whole:Route@36672,whole:Route@36740,whole:Route@37063,whole:Route@38096,whole:Route@41047,whole:Route@45787,whole:Route@47373,whole:Route@47418,whole:Route@47428,whole:Route@48298,whole:Route@49325,whole:Route@54791,whole:Route@54939,whole:Route@56036,whole:Route@56395,whole:Route@56777,whole:Route@61551,whole:Route@62136,whole:Route@62186 be1b699f14a2f8d6935d959dee168bdf6fb556cd78da458f5ba8a1c0e8512a17 |
| +internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Nothing starts it yet (Task 6) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953 |
| +internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Nothing starts it yet (Task 6 adds POST /tty) file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d |
| @coverage . fbc28f10f89cd03cac31bae0d798ae7f707eb7671284a6115abd8c1c214369b6 |
| @coverage internal/appconfig cac8d8ef7538a456d034801c95ce6508a4983e5516b3bbbd302bec0fbafdd479 |
| +@coverage internal/host/units a437b93c66cdb75ca57ff6e609800fb17fc9c975c1db8f429030cbfd1830c843 |
| +@coverage internal/instancectl 0823bfcfed9770a548fb1444047b9bf22f74fecdf770e4f9443dae778465ca5f |
| +@coverage internal/instanceexec 437d5d54657ec32281d6f23d697302a177be9a4f54039ce3d1e71912a6376005 |
| +@coverage internal/layout 1527c3b31d87743798002b1ebefcd2cb0dc422a8642f72a3ff8dbefbd2c84d9b |
| @coverage internal/provision e1ecfdc3d169773ac6dd9dc09a6d0feea768ceb1b80195199c5ef74b2f0e6f5c |