Skip to content

fix(docs): keep the systemd unit and environment file out of the app directory - #611

Merged
jsenecal merged 3 commits into
mainfrom
fix/515-host-files-out-of-app-dir
Nov 25, 2026
Merged

jsenecal merged 3 commits into
mainfrom
fix/515-host-files-out-of-app-dir

Conversation

@jsenecal

Copy link
Copy Markdown
Collaborator

Closes #515

The Docker and manual guides put the systemd unit and its environment file in the app directory: /etc/hyperglass/hyperglass.service, linked into /etc/systemd/system, and /etc/hyperglass/hyperglass.env, read through EnvironmentFile. systemd reads both as root, and with Docker the container user owns that directory (since #486), so a compromised container could edit ExecStart or set COMPOSE_FILE to a Compose file that mounts the host's root filesystem, and get root on the host at the next restart.

This follows the proposal in the issue:

  • Both sample units in .samples now read EnvironmentFile=/etc/default/hyperglass.
  • docker.mdx and manual.mdx create /etc/default/hyperglass (root, mode 0600) and copy the unit to /etc/systemd/system/hyperglass.service instead of linking it from /etc/hyperglass. docker.mdx gets a "Host files" section that explains why, and warns against pointing HYPERGLASS_APP_PATH at /opt/hyperglass or any directory holding host files.
  • environment-variables.mdx names the new path. While there, it no longer says the env file "does not configure Compose": systemd exports it to docker compose, which is what COMPOSE_FILE relies on. It now says .env applies to every docker compose command and the env file only when systemd runs Compose.
  • upgrading.mdx has a one-time migration in three steps, with what to check between them, so the old files are reviewed before anything runs them: stop and disable the service and show the old env file and a diff of the old unit against the new sample; copy the env file with install -o root -g root -m 600 (not mv, which would keep the container user as owner after chown -R 10001:10001), replace the link with a copy of the sample and remove the old files; then reload, enable and start. Users with a custom HYPERGLASS_APP_PATH are told to substitute it. Both upgrade paths and the 2.0.4 migration list link to it.
  • The install steps use cp --remove-destination, so an existing link from an older install is replaced rather than written through into the app directory.

Why /etc/default/hyperglass: it is the conventional root-owned place for a service's environment file, it is outside every mount, and it keeps the env file out of the /opt/hyperglass git checkout. RHEL users can use /etc/sysconfig if they prefer, by editing the unit.

Backward compatibility: no code changes. An installed unit keeps its own EnvironmentFile path, so existing installs keep working (and keep the risk) until they migrate. A unit copied from the new sample does not start until /etc/default/hyperglass exists, which the guides and the migration create.

Out of scope, as in the issue: mounting the app directory read-only, which needs the UI build output to move elsewhere first.

Docs and sample units only; the full test suite passes.

…directory

The installation guides put hyperglass.service and hyperglass.env in
/etc/hyperglass, which systemd reads as root and the Docker container
can write to. Install the unit as a regular file in /etc/systemd/system,
read the environment from a root-owned /etc/default/hyperglass, and
document a one-time migration for existing installs.

Closes #515
Split the migration into review, move and start steps so a changed
environment file or unit is checked before systemd runs it, tolerate the
link that systemctl disable already removed, and replace an existing
link with cp --remove-destination instead of writing through it into the
app directory. Note the custom app path and link the move section from
both upgrade paths.
@github-actions github-actions Bot added the docs Improve documentation label Nov 24, 2026
@coveralls

coveralls commented Nov 24, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 89.198%. remained the same — fix/515-host-files-out-of-app-dir into main

@jsenecal
jsenecal force-pushed the fix/515-host-files-out-of-app-dir branch from 109adac to 830d901 Compare November 25, 2026 20:45

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at 830d901.

Checked both sample units, the install and upgrade steps in the Docker, manual, environment-variable and upgrading guides against #515, and confirmed no remaining reference to the old unit or env file paths. CI gate passes and all commits are signed.

@WilhelmZA WilhelmZA added reviewing Issue is being reviewed by maintainers security Hardening and security-relevant changes labels Nov 25, 2026
@jsenecal
jsenecal merged commit dab8618 into main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improve documentation reviewing Issue is being reviewed by maintainers security Hardening and security-relevant changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep the systemd unit and hyperglass.env out of the mounted app directory

3 participants