[GH-ISSUE #5323] [Issue]: Docker ownership repair misses nested ownership mismatches and blocks startup #2940

Closed
opened 2026-10-21 05:58:12 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @NeoKazuya on GitHub (Aug 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5323

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Marinara's Docker startup skips its recursive ownership repair when the configured data and storage directories (/app/data and /app/data/storage by default) already belong to the runtime user, even if folders underneath them do not. After the private-storage hardening added in #4966, those missed folders cause an EPERM error and prevent the container from starting.

Expected behavior

With MARINARA_SKIP_DATA_CHOWN unset, the official image should repair mismatched ownership within the mounted data directory before dropping to the non-root runtime user. A correctly owned top-level directory should not hide incorrectly owned descendants from that repair.

Actual behavior

The entrypoint checks only the ownership of the two top-level data paths. If both already belong to UID/GID 1000, it skips the recursive repair completely. The server then starts as UID/GID 1000 and tries to apply private permissions throughout the storage tree. When a root-owned descendant needs its mode tightened, UID 1000 cannot chmod it and storage initialization aborts.

In the affected installation, /app/data/storage was already 1000:1000, while four older collections and collections.backup-* trees beneath it were still root:root. Correcting only those trees to 1000:1000 allowed the container to start again.

Steps to reproduce

  1. Bind-mount a host data directory at /app/data in the official Docker image.
  2. Set /app/data and /app/data/storage to UID/GID 1000, but leave a 0755 directory underneath /app/data/storage owned by root. Leave MARINARA_SKIP_DATA_CHOWN unset.
  3. Start the container on a build containing the private-storage hardening from #4966.
  4. Observe that the entrypoint does not run its recursive ownership repair and the server exits while applying private permissions to the root-owned descendant.

Environment

  • Marinara Engine version: staging image at source revision 9a810f64edb131c21735616f8fdce5265440af39
  • Install type: Docker using a host-folder bind mount
  • OS + version: TrueNAS SCALE 25.04.2.6 on ZFS (acltype=posix)
  • Docker version: 27.5.0 on Linux/amd64
  • Browser or app shell: Not applicable; server bootstrap fails before the app starts

Logs, screenshots, or video

AggregateError: [file-storage] Private storage permissions could not be established
    at hardenPrivateStorageTree (file:///app/packages/server/dist/db/file-backed-store.js:70:15)
    at FileTableStore.initialize (file:///app/packages/server/dist/db/file-backed-store.js:1433:13)

First aggregated cause:
Could not apply private permissions to
/app/data/storage/collections.backup-20260530-085020:
EPERM: operation not permitted, chmod
'/app/data/storage/collections.backup-20260530-085020'

Relevant ownership before recovery:

/app/data                         1000:1000
/app/data/storage                 1000:1000
/app/data/storage/collections     root:root
/app/data/storage/collections.*   root:root

The container exited with code 1 and restarted repeatedly.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • [] I DID NOT read this template and provide the requested details.
Originally created by @NeoKazuya on GitHub (Aug 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5323 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Marinara's Docker startup skips its recursive ownership repair when the configured data and storage directories (`/app/data` and `/app/data/storage` by default) already belong to the runtime user, even if folders underneath them do not. After the private-storage hardening added in #4966, those missed folders cause an `EPERM` error and prevent the container from starting. ## Expected behavior With `MARINARA_SKIP_DATA_CHOWN` unset, the official image should repair mismatched ownership within the mounted data directory before dropping to the non-root runtime user. A correctly owned top-level directory should not hide incorrectly owned descendants from that repair. ## Actual behavior The entrypoint checks only the ownership of the two top-level data paths. If both already belong to UID/GID 1000, it skips the recursive repair completely. The server then starts as UID/GID 1000 and tries to apply private permissions throughout the storage tree. When a root-owned descendant needs its mode tightened, UID 1000 cannot `chmod` it and storage initialization aborts. In the affected installation, `/app/data/storage` was already `1000:1000`, while four older `collections` and `collections.backup-*` trees beneath it were still `root:root`. Correcting only those trees to `1000:1000` allowed the container to start again. ## Steps to reproduce 1. Bind-mount a host data directory at `/app/data` in the official Docker image. 2. Set `/app/data` and `/app/data/storage` to UID/GID 1000, but leave a `0755` directory underneath `/app/data/storage` owned by root. Leave `MARINARA_SKIP_DATA_CHOWN` unset. 3. Start the container on a build containing the private-storage hardening from #4966. 4. Observe that the entrypoint does not run its recursive ownership repair and the server exits while applying private permissions to the root-owned descendant. ## Environment - Marinara Engine version: `staging` image at source revision `9a810f64edb131c21735616f8fdce5265440af39` - Install type: Docker using a host-folder bind mount - OS + version: TrueNAS SCALE 25.04.2.6 on ZFS (`acltype=posix`) - Docker version: 27.5.0 on Linux/amd64 - Browser or app shell: Not applicable; server bootstrap fails before the app starts ## Logs, screenshots, or video ```text AggregateError: [file-storage] Private storage permissions could not be established at hardenPrivateStorageTree (file:///app/packages/server/dist/db/file-backed-store.js:70:15) at FileTableStore.initialize (file:///app/packages/server/dist/db/file-backed-store.js:1433:13) First aggregated cause: Could not apply private permissions to /app/data/storage/collections.backup-20260530-085020: EPERM: operation not permitted, chmod '/app/data/storage/collections.backup-20260530-085020' ``` Relevant ownership before recovery: ```text /app/data 1000:1000 /app/data/storage 1000:1000 /app/data/storage/collections root:root /app/data/storage/collections.* root:root ``` The container exited with code 1 and restarted repeatedly. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:58:12 +07:00
Author
Owner

@NeoKazuya commented on GitHub (Aug 20, 2026):

@SpicyMarinara did you want to handle this or should I open a PR with the fix I have lined up?

<!-- gh-comment-id:5358757740 --> @NeoKazuya commented on GitHub (Aug 20, 2026): @SpicyMarinara did you want to handle this or should I open a PR with the fix I have lined up?
Author
Owner

@SpicyMarinara commented on GitHub (Aug 20, 2026):

@NeoKazuya can you throw the fix since you have it already? Thank you!

<!-- gh-comment-id:5358829762 --> @SpicyMarinara commented on GitHub (Aug 20, 2026): @NeoKazuya can you throw the fix since you have it already? Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
Pasta-Devs/Marinara-Engine#2940
No description provided.