Skip to content

Run NATS and the controller as their own users #1945

Backlog

Description

@retr0h

The agent runs as osapi after #1907 (#1943). The NATS server and the controller still run as root when osapi nats service install and osapi controller service install install them.

Run each one as its own user:

  • osapi-nats owns the JetStream store directory and the NATS config.
  • osapi-controller owns the controller's state and its signing keys.
  • Each unit gets the same sandbox as the agent unit: no capabilities, NoNewPrivileges=yes, and ProtectSystem=strict with a StateDirectory.
  • On macOS, each launch daemon names its user.
  • The install makes the users and the groups, and makes each state directory through descriptors with no link, as the agent install does.

The design is order-of-work item 5 of components/osapi/least-privilege.md in specs (osapi-io/specs#756).

Check: in the lab, ps -o user shows osapi-nats and osapi-controller, and the integration tests pass under the real units.

Activity

  1. added
    enhancement
    component/controller
    architecture
    on Dec 5, 2026
  2. retr0h commented on Dec 6, 2026

    @retr0h
    CollaboratorAuthor

    Layout note from #1943: osapi follows the FHS by default, with the least config possible, and the lab uses only the defaults. #1943 moves only the paths of the broker and the agent:

    • the enabled list: /etc/osapi/privileged/enabled (root 0644, in a root 0755 directory);
    • the broker's call directories: /run/osapi/privileged/ (root 0700), with the socket at /run/osapi/privileged.sock;
    • the rescue: /var/lib/osapi/privileged/rescue, in /var/lib/osapi/privileged (root 0711), and the check tree in /run/osapi/rescue-check;
    • the agent's state: /var/lib/osapi/agent (StateDirectory=osapi/agent), with its keys in /var/lib/osapi/agent/pki and its pending changes in /var/lib/osapi/agent/pending. Root owns /var/lib/osapi (0755).

    The rest of the layout is in this issue:

    • a state directory for each component: /var/lib/osapi/controller and /var/lib/osapi/nats (the JetStream store is /var/lib/osapi/jetstream today);
    • the key directories of the controller and NATS;
    • per-user XDG paths for the CLI and for osapi start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecturecomponent/controllerenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions