Skip to content

fix(nix): container entrypoint chown -R strips setgid, breaking hostUsers group access#23633

Merged
alt-glitch merged 1 commit into
mainfrom
fix/nix-container-chown-setgid
May 11, 2026
Merged

fix(nix): container entrypoint chown -R strips setgid, breaking hostUsers group access#23633
alt-glitch merged 1 commit into
mainfrom
fix/nix-container-chown-setgid

Conversation

@alt-glitch

@alt-glitch alt-glitch commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

The NixOS container entrypoint runs chown -R $UID:$GID $HERMES_HOME on every container start. Because HERMES_HOME is a bind-mounted host directory, this affects host filesystem permissions. The Linux kernel strips the setgid bit on any chown call (security behavior), so the 2770 permissions the NixOS activation script sets on HERMES_HOME get destroyed on every container restart.

This causes PermissionError for interactive CLI users listed in container.hostUsers — they're in the hermes group but can't enter the 0700 directory.

Affected config: container.enable = true + container.hostUsers + addToSystemPackages = true

Fix

Replace chown -R with find $HERMES_HOME ! -user $UID -exec chown $UID:$GID {} +. This only touches files with wrong ownership, leaving correctly-owned directories and their setgid/permission bits intact.

Related issues

Test plan

  • nix flake check --no-build passes
  • nixos-rebuild switch with container.enable + hostUsers + addToSystemPackages
  • After container restart, verify /var/lib/hermes/.hermes retains 2770
  • Interactive hermes --tui works as a hostUser without sudo chmod workaround

@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/nix-container-chown-setgid vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8157 on HEAD, 8157 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4287 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: #19795, #19788, #9383
@alt-glitch alt-glitch force-pushed the fix/nix-container-chown-setgid branch from ee7a202 to a07d972 Compare May 11, 2026 07:25
@alt-glitch alt-glitch marked this pull request as ready for review May 11, 2026 07:29
@alt-glitch alt-glitch merged commit 64145a1 into main May 11, 2026
9 of 12 checks passed
@alt-glitch alt-glitch deleted the fix/nix-container-chown-setgid branch May 11, 2026 07:30
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists area/nix Nix flake, NixOS module, container packaging area/docker Docker image, Compose, packaging labels May 11, 2026
rmulligan pushed a commit to rmulligan/hermes-agent that referenced this pull request May 11, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
JinyuID pushed a commit to JinyuID/hermes-agent that referenced this pull request May 11, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
jsboige pushed a commit to jsboige/hermes-agent that referenced this pull request May 14, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
AlexFoxD pushed a commit to AlexFoxD/hermes-agent that referenced this pull request May 21, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…NousResearch#23633)

The container entrypoint ran `chown -R` on $HERMES_HOME every start.
`chown` strips the setgid bit (kernel security behavior), destroying
the 2770 permissions the NixOS activation script sets for group access
by hostUsers. This caused PermissionError for interactive CLI users
even though they were in the hermes group.

Replace with `find ... ! -user $UID -exec chown` which only touches
files with wrong ownership, leaving correctly-owned directories and
their permission bits intact.

Affects: container.enable + container.hostUsers + addToSystemPackages

Related: NousResearch#19795, NousResearch#19788, NousResearch#9383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging area/nix Nix flake, NixOS module, container packaging P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant