Skip to content

fix: support HERMES_UID=0 by skipping usermod and privilege drop#35078

Closed
x1am1 wants to merge 1 commit into
NousResearch:mainfrom
x1am1:fix/hermes-uid-zero
Closed

fix: support HERMES_UID=0 by skipping usermod and privilege drop#35078
x1am1 wants to merge 1 commit into
NousResearch:mainfrom
x1am1:fix/hermes-uid-zero

Conversation

@x1am1

@x1am1 x1am1 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Problem

HERMES_UID=0 is documented as a way to run the gateway as root, but it does not work. stage2-hook.sh runs usermod -u 0 hermes which fails silently with:

usermod: UID '0' already exists

because UID 0 is already assigned to root. The gateway continues running as uid 10000 (hermes), and files created by docker exec -u root operations remain root-owned, causing PermissionError on gateway.lock and errors.log → gateway restart loop.

Fix

Two files modified:

docker/stage2-hook.sh

  • When HERMES_UID=0, skip usermod (would fail anyway)
  • Set HERMES_RUN_AS_ROOT=1 in s6 container environment as a signal

docker/main-wrapper.sh

  • Check HERMES_RUN_AS_ROOT flag
  • When set, skip s6-setuidgid hermes privilege drop
  • Gateway runs directly as root

Testing

Set HERMES_UID=0 and HERMES_GID=0 in docker-compose.yml:

environment:
  - HERMES_UID=0
  - HERMES_GID=0

After docker compose up -d:

  • docker exec hermes-agent whoami should return root
  • No PermissionError in gateway logs
  • Files created by root operations are accessible

Related

Known issue documented in community skills:

HERMES_UID=0 does NOT work despite stage2-hook.sh source code suggesting it should. Tested and confirmed non-functional as of v0.15.1.

When HERMES_UID=0, usermod fails with 'UID 0 already exists' because
root already owns that UID. The gateway silently falls back to uid 10000,
defeating the purpose of the setting.

Fix: detect HERMES_UID=0 in stage2-hook.sh, skip usermod, and set
HERMES_RUN_AS_ROOT=1 in s6 container environment. main-wrapper.sh
checks this flag and skips s6-setuidgid so the gateway runs as root.

This makes HERMES_UID=0 work as documented — the gateway runs as root
with no file permission issues.
@alt-glitch alt-glitch added type/bug Something isn't working area/docker Docker image, Compose, packaging P2 Medium — degraded but workaround exists needs-decision Awaiting maintainer decision before any implementation labels May 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Needs maintainer decision: This PR enables HERMES_UID=0 (run as root), but open PR #34119 explicitly blocks UID=0 via range validation (1000-65534) for security reasons. These two PRs are mutually exclusive.

Related: #32559, #34401, #34684

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 needs-decision Awaiting maintainer decision before any implementation 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.

2 participants