Skip to content

Fix LSIO PUID/PGID permission race and harden abc rename - #450

Merged
ptr727 merged 1 commit into
developfrom
fix-lsio-puid-pgid-ordering
Jun 25, 2026
Merged

ptr727 merged 1 commit into
developfrom
fix-lsio-puid-pgid-ordering

Conversation

@ptr727

@ptr727 ptr727 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Problem

Fixes #449. On LSIO images, upgrading could leave /media chowned to the build-time UID while the mediaserver ran as the remapped PUID, breaking writes (QIODevice::write ... device not open) and triggering a full chown sweep on every start.

Root cause: the init-nx-permissions chown sweep had no s6-rc dependency on the base init-adduser oneshot that remaps PUID/PGID onto the renamed account. As a dependency-free graph source, s6-rc could run the recursive chown of /config and /media before the remap, locking files to the pre-remap UID.

Changes

  • Fix the race: add init-nx-permissions/dependencies.d/init-adduser so the chown sweep (and, transitively, init-nx-relocate) runs strictly after the PUID/PGID remap. With correct ordering the stat guard sees /media already owned by the account and skips the sweep entirely.
  • Extract RUN blocks to shell scripts: the installer download and the LSIO abc→account rename move from large inline RUN blocks into Docker/download.sh and Docker/lsio-rename-user.sh, copied and run with parameters (shellcheck-able, single-quote-clean, pinned LF).
  • Harden the unsupported abc rename: the rename script asserts the expected init-adduser signature before and after patching and fails the build if upstream changes it, rather than silently regressing PUID/PGID handling. (LSIO still does not support renaming abc.)
  • Codegen LF output: WriteDockerfile normalizes generated Dockerfiles to LF + a single trailing newline regardless of OS (raw-string literals inherit CRLF from the CRLF-encoded C# source, and CRLF breaks RUN line continuations).

Validation

  • Built NxMeta-LSIO (amd64) end-to-end: account renamed, abc removed, init-adduser repointed, new ordering dependency present, /temp clean.
  • Rename script verified against nx-base-lsio:ubuntu-noble; fails closed (exit 1, clear message) when the signature is broken or the file is missing.
  • All 12 Dockerfiles LF; 21/21 unit tests pass; CSharpier + dotnet format style --verify-no-changes clean.

🤖 Generated with Claude Code

The LSIO init-nx-permissions chown sweep had no s6-rc dependency on the base
init-adduser oneshot that remaps PUID/PGID onto the renamed account. s6-rc could
therefore run the recursive chown of /config and /media before the remap, leaving
files owned by the build-time UID while the mediaserver runs as the remapped UID,
breaking writes. Add an init-adduser ordering dependency so the sweep (and, via it,
init-nx-relocate) runs only after the remap.

Extract the installer download and the LSIO abc->account rename into shell scripts
that are copied and run with parameters, replacing the large inline RUN blocks. The
rename script asserts the expected init-adduser signature before and after patching
and fails the build if upstream changes it, instead of silently regressing PUID/PGID.

Make the codegen write Dockerfiles as LF with a single trailing newline regardless
of OS, since the raw-string literals inherit CRLF from the CRLF-encoded C# source
and CRLF breaks RUN line continuations.
Copilot AI review requested due to automatic review settings June 25, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an LSIO startup ordering race that could leave /media (and other mounts) owned by the pre-remap UID/GID, causing write failures and repeated recursive chown sweeps on container start. It also refactors repeated Dockerfile RUN blocks into reusable shell scripts and ensures generated Dockerfiles are consistently LF-terminated to avoid Docker RUN continuation issues.

Changes:

  • Add an s6-rc dependency so init-nx-permissions (and dependent startup actions) runs after LSIO’s init-adduser PUID/PGID remap.
  • Extract installer download logic and LSIO abc→account rename logic into Docker/download.sh and Docker/lsio-rename-user.sh.
  • Normalize generated Dockerfiles to LF with exactly one trailing newline; make apt cleanup non-interactive (apt-get autoremove --purge --yes).

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
NxWitness.code-workspace Adds spell-check allowlist words used by the new scripts/log wording.
Docker/NxWitness.Dockerfile Uses download.sh for installer staging; non-interactive autoremove.
Docker/NxWitness-LSIO.Dockerfile Uses download.sh + lsio-rename-user.sh for LSIO variant; keeps s6-overlay layout.
Docker/NxMeta.Dockerfile Same download script refactor + non-interactive autoremove.
Docker/NxMeta-LSIO.Dockerfile Same download + LSIO rename script refactor.
Docker/NxGo.Dockerfile Same download script refactor + non-interactive autoremove.
Docker/NxGo-LSIO.Dockerfile Same download + LSIO rename script refactor.
Docker/DWSpectrum.Dockerfile Same download script refactor + non-interactive autoremove.
Docker/DWSpectrum-LSIO.Dockerfile Same download + LSIO rename script refactor.
Docker/WisenetWAVE.Dockerfile Same download script refactor + non-interactive autoremove.
Docker/WisenetWAVE-LSIO.Dockerfile Same download + LSIO rename script refactor.
Docker/download.sh New shared download/staging implementation for .zip/.deb inputs.
Docker/lsio-rename-user.sh New hardened LSIO abc rename + init-adduser repoint with signature assertions.
Docker/s6-overlay/s6-rc.d/init-nx-permissions/dependencies.d/init-adduser Enforces s6-rc ordering so permission fixes happen after PUID/PGID remap.
CreateMatrix/Dockerfile.cs Centralizes Dockerfile writes with LF normalization and makes apt cleanup non-interactive.

@ptr727
ptr727 merged commit 64f6732 into develop Jun 25, 2026
10 checks passed
ptr727 added a commit that referenced this pull request Jun 25, 2026
Prep for the 2.14 `develop -> main` release.

- Bump `version.json` NBGV floor 2.13 -> 2.14.
- Add the `Version 2.14` release note to HISTORY.md and the README
Release Notes for the LSIO PUID/PGID permission-ordering fix (#450).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
ptr727 added a commit that referenced this pull request Jun 25, 2026
Promote `develop` to `main` for the 2.14 release.

## Included

- **Fix LSIO PUID/PGID permission race (#450)** — the
`init-nx-permissions` chown sweep now depends on the base `init-adduser`
oneshot, so it runs after the PUID/PGID remap instead of racing it
(which could leave `/config` and `/media` owned by the wrong user and
break media writes). Also extracts the installer download and LSIO `abc`
rename into shell scripts, hardens the rename against upstream
`init-adduser` changes, and makes codegen emit LF Dockerfiles.
- **Bump version to 2.14 and document the fix (#451)** — `version.json`
floor 2.13 -> 2.14, HISTORY.md and README release notes.
- **Re-sync verbatim-carry artifacts from template (#448)** — already on
develop.

Validated on a live Synology server (the #449 reporter's scenario) via
the `:develop` tag; the publish run on develop was green across the full
matrix.

Closes #449.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@ptr727
ptr727 deleted the fix-lsio-puid-pgid-ordering branch July 7, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants