hermes-control-interface icon indicating copy to clipboard operation
hermes-control-interface copied to clipboard

[FEATURE] non-root user fix

Open Fr3akaz0id opened this issue 7 months ago • 1 comments

running agents as root is not the best idea :)

here is my propose for a fix that makes it work with a user systemd entry and non-root user (hermes figured it out) and a single gateway.

Plan: Fix Hermes Control Interface for user (non-root)

Issues Found

1. Gateway service name mismatch

  • App looks for hermes-gateway-${profile} (e.g. hermes-gateway-default)
  • Actual service is hermes-gateway.service (user-level, no profile suffix)
  • systemctl is-active hermes-gateway-* glob doesn't match bare hermes-gateway

2. All systemctl/journalctl calls missing --user flag

  • Gateway is a user-level service (under ~/.config/systemd/user/)
  • systemctl is-active, systemctl status, systemctl start/stop/restart, journalctl -u — all fail without --user
  • System-level journalctl also requires adm group which user doesn't have

3. Identity hardcoded as "root@hermes" everywhere

  • server.js: lines 150, 1052, 1071, 1659, 1671, 2290
  • Terminal prompt shows root@hermes:/path#
  • Login screen shows root@hermes

4. Log tabs (Agent/Gateway/Errors) don't work

  • Server ignores the ?log= query parameter — only does journalctl -u for gateway
  • Agent and error logs should read from ~/.hermes/logs/{agent,errors}.log files
  • Gateway logs need journalctl --user

5. Connections always show disconnected

  • Frontend hardcodes status based on service active/inactive instead of parsing actual connections

Proposed Changes (server.js + auth.js)

# What How
1 Dynamic identity Detect os.userInfo().username and os.hostname(), replace all root@hermes with ${user}@${host}
2 Fix gateway service discovery Try both hermes-gateway (user service) and hermes-gateway-${profile} as fallback. Add --user to all systemctl/journalctl calls
3 Fix log endpoint Parse ?log= param: agent → read ~/.hermes/logs/agent.log, errors → ~/.hermes/logs/errors.log, gateway → journalctl --user -u hermes-gateway
4 Fix auth.js HOME Use os.homedir() instead of process.env.HOME || '/root'
5 Fix connections display Parse actual gateway status from hermes status or journalctl output

Files Modified

  • /opt/hermes-control-interface/server.js — gateway service name, systemctl flags, log endpoint, identity
  • /opt/hermes-control-interface/auth.js — HOME path resolution

No sudo/group changes needed

  • All systemctl/journalctl calls work with --user for user-level services
  • File-based logs don't need special permissions (user owns ~/.hermes/logs/)

maybe it helps.

Fr3akaz0id avatar Apr 13 '26 16:04 Fr3akaz0id

All items fixed in v3.2.0.

1. Gateway service name mismatch → Fixed in 691cd47

  • getGatewayServiceName() now tries both hermes-gateway (bare) and hermes-gateway-${profile} (profiled)
  • primary: non-root uses bare, root uses profiled
  • Both systemctl status check and start/stop/restart try primary then fallback

2. systemctl/journalctl missing --user → Fixed in 691cd47

  • SYSTEMD_USER_FLAG = IS_ROOT ? '' : '--user'
  • All systemctl/journalctl calls now auto-add --user for non-root
  • XDG_RUNTIME_DIR auto-detected if not set

3. Identity hardcoded root@hermes → Fixed in 691cd47

  • HCI_USER = os.userInfo().username
  • HCI_HOST = os.hostname()
  • HCI_IDENTITY = \${HCI_USER}@${HCI_HOST}``
  • Terminal prompt, login screen, all use dynamic identity

4. Log tabs don't work → Fixed in 691cd47

  • /api/gateway/:profile/logs?log=agent|error|gateway
  • agent → reads ~/.hermes/logs/agent.log
  • error → reads ~/.hermes/logs/errors.log
  • gateway → journalctl --user -u hermes-gateway

5. Connections show disconnected → Already worked

  • Parses from hermes status --all output
  • Shows ✓/✗ per platform with detail

Bonus: auth.js uses os.homedir() instead of process.env.HOME || '/root'

Commit: https://github.com/xaspx/hermes-control-interface/commit/691cd47 Release: https://github.com/xaspx/hermes-control-interface/releases/tag/v3.2.0

xaspx avatar Apr 14 '26 14:04 xaspx