container ports: a switch must never re-chown a bind-mounted data dir away from the image's own user (audit after GOTCHAS #353) #1937

Closed
opened 2026-09-27 21:14:33 +00:00 by ben · 2 comments
Owner

What to build

GOTCHAS #353: every switch re-runs systemd-tmpfiles-resetup, and a d rule that names an owner re-chowns an existing directory back to that owner. Grist's /persist rule said root root, but the Grist image chowns that directory to its own uid 1001 at start. So after any deploy on the node, the running Grist failed every document open (fixed in 4dd7563d: the rule now names no owner).

The other container ports' renders carry the same 0750 root root rules on the host directories they bind-mount: archive (Paperless), whakapapa (Gramps), any-sync. For each container, check whether its image drops to a non-root user or chowns its data directory at start. Where it does, the rule must name no owner (- - -), or the owner the image uses when the render pins that uid.

Acceptance criteria

  • Each container port's bind-mounted host directories are checked against the image's runtime user (evidence noted per directory)
  • Every directory an image chowns to a non-root user has a tmpfiles rule that leaves its owner alone, with a render test like TestRenderDataCollections_ASwitchNeverTakesPersistFromGrist
  • Directories the container uses as root are unchanged

Blocked by

None — can start immediately

## What to build GOTCHAS #353: every switch re-runs systemd-tmpfiles-resetup, and a `d` rule that names an owner re-chowns an existing directory back to that owner. Grist's `/persist` rule said `root root`, but the Grist image chowns that directory to its own uid 1001 at start. So after any deploy on the node, the running Grist failed every document open (fixed in 4dd7563d: the rule now names no owner). The other container ports' renders carry the same `0750 root root` rules on the host directories they bind-mount: archive (Paperless), whakapapa (Gramps), any-sync. For each container, check whether its image drops to a non-root user or chowns its data directory at start. Where it does, the rule must name no owner (`- - -`), or the owner the image uses when the render pins that uid. ## Acceptance criteria - [ ] Each container port's bind-mounted host directories are checked against the image's runtime user (evidence noted per directory) - [ ] Every directory an image chowns to a non-root user has a tmpfiles rule that leaves its owner alone, with a render test like `TestRenderDataCollections_ASwitchNeverTakesPersistFromGrist` - [ ] Directories the container uses as root are unchanged ## Blocked by None — can start immediately

swarm-claim host=matou-dev-server-01 run=34408
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=34408 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1937 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1937,
  "status": "success",
  "commits": [
    "000d89599e8ccfb6a23f1f44684f51b1cd053156"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/anysync_test.go",
    "internal/clan/archive_test.go",
    "internal/clan/whakapapa_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/clan/ -run ASwitchNeverTakes",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Each container port's bind-mounted host directories are checked against the image's runtime user (evidence noted per directory)": "docs/GOTCHAS.md #353 Related line records the per-directory audit: archive /db 999 (MariaDB), /files 65534 (erseco nobody, no self-chown, #1271); whakapapa all dirs root (Gramps Web runs nginx/gunicorn/celery as root, home /root, no USER/gosu drop, evidenced by bind mount to /root/.gramps/grampsdb); any-sync /mongo 999 (mongo entrypoint chowns+gosu-drops), /redis 999, /minio + /tree(+subdirs) root (MinIO and nodes run as root, mount /root/.aws)",
    "Every directory an image chowns to a non-root user has a tmpfiles rule that leaves its owner alone, with a render test like TestRenderDataCollections_ASwitchNeverTakesPersistFromGrist": "All such dirs already pin the image's exact uid (archive/db 999, archive/files 65534, anysync/mongo 999, anysync/redis 999) — the GOTCHAS #353 rule's accepted 'owner the image uses when the render pins that uid' branch; no render change needed. Regression pins added: TestRenderArchive_ASwitchNeverTakesTheStoreFromItsImageUser (archive_test.go), TestRenderAnySync_ASwitchNeverTakesAStoreFromItsImageUser (anysync_test.go), TestRenderWhakapapa_ASwitchNeverTakesTheStoreFromGrampsWeb (whakapapa_test.go)",
    "Directories the container uses as root are unchanged": "No render (.go non-test) file was modified — whakapapa's root:root dirs and any-sync's /minio + /tree root:root dirs are pinned unchanged by the new tests; git diff shows only test files + docs"
  },
  "summary": "Audited archive, whakapapa and any-sync container ports against GOTCHAS #353 — every bind-mounted data dir already names its image's runtime user, so no render change was needed; added a per-port regression test and recorded the evidence.",
  "blockers": []
}
**close-report** for #1937 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1937, "status": "success", "commits": [ "000d89599e8ccfb6a23f1f44684f51b1cd053156" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/anysync_test.go", "internal/clan/archive_test.go", "internal/clan/whakapapa_test.go" ], "tests": [ { "command": "go test ./internal/clan/ -run ASwitchNeverTakes", "exit_code": 0 }, { "command": "go test ./internal/clan/", "exit_code": 0 } ], "criteria": { "Each container port's bind-mounted host directories are checked against the image's runtime user (evidence noted per directory)": "docs/GOTCHAS.md #353 Related line records the per-directory audit: archive /db 999 (MariaDB), /files 65534 (erseco nobody, no self-chown, #1271); whakapapa all dirs root (Gramps Web runs nginx/gunicorn/celery as root, home /root, no USER/gosu drop, evidenced by bind mount to /root/.gramps/grampsdb); any-sync /mongo 999 (mongo entrypoint chowns+gosu-drops), /redis 999, /minio + /tree(+subdirs) root (MinIO and nodes run as root, mount /root/.aws)", "Every directory an image chowns to a non-root user has a tmpfiles rule that leaves its owner alone, with a render test like TestRenderDataCollections_ASwitchNeverTakesPersistFromGrist": "All such dirs already pin the image's exact uid (archive/db 999, archive/files 65534, anysync/mongo 999, anysync/redis 999) — the GOTCHAS #353 rule's accepted 'owner the image uses when the render pins that uid' branch; no render change needed. Regression pins added: TestRenderArchive_ASwitchNeverTakesTheStoreFromItsImageUser (archive_test.go), TestRenderAnySync_ASwitchNeverTakesAStoreFromItsImageUser (anysync_test.go), TestRenderWhakapapa_ASwitchNeverTakesTheStoreFromGrampsWeb (whakapapa_test.go)", "Directories the container uses as root are unchanged": "No render (.go non-test) file was modified — whakapapa's root:root dirs and any-sync's /minio + /tree root:root dirs are pinned unchanged by the new tests; git diff shows only test files + docs" }, "summary": "Audited archive, whakapapa and any-sync container ports against GOTCHAS #353 — every bind-mounted data dir already names its image's runtime user, so no render change was needed; added a per-port regression test and recorded the evidence.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1937
No description provided.