nixpkgs/nixos/modules/services/continuous-integration
Vincent Haupert 3cf9508c72 nixos/github-runner: refactor tokens handling
This commit changes how we deal with the current token, i.e., the token
which may exist from a previous runner registration, and the configured
token, i.e., the path set for the respective NixOS configuration option.

Until now, we copied the configured and the current token (if any) to
the runtime directory to compare them. The path of the current token may
reference a file which is only accessible to specific users (even only
root). Therefore, we ran the copying of credentials with elevated
privileges by prefixing the `ExecStartPre=` script with a `+` (see
systemd.service(5)). In this script, we also changed the owner of the
files to the service user. Apparently, however, the user/group pair
sometimes did not exist because we use `DynamicUser=`.

To address this issue, we no longer change the owner of the file.
Instead, we change the file permissions to 0666 to allow the runner
configuration script (runs with full sandboxing) to read-write the file.
Due to the current permissions of the runtime directory (0755), this
would expose the token. Therefore, we process the tokens in the state
directory, which is only accessible to the service user.

If a new token file exists in the state directory, the configuration
script should trigger a new runner registration. Afterward, it deletes
the new token file. The token is still available using the path of the
current token which is inaccessible within the service's sandbox.
2021-12-01 16:15:43 +01:00
..
buildbot nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
gocd-agent nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
gocd-server nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
hercules-ci-agent nixos/hercules-ci-agent: Update module 2021-11-19 11:05:04 +01:00
hydra nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
jenkins nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
buildkite-agents.nix nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
github-runner.nix nixos/github-runner: refactor tokens handling 2021-12-01 16:15:43 +01:00
gitlab-runner.nix nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
hail.nix nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00