-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systemd: further cleanups for DynamicUser setup
We need to have separate units to create dynamic users for our socket ownership[^1] (since this feature is not supported for `.socket` units in systemd) but we don't need to create our service users that way. Move to using `DynamicUser=yes` directly in our relevant `.service` files. In the case of `cockpit.service` this allows us to drop the separate `cockpit-ws-user.service`. For the `cockpit-wsinstance-*` services we do that instead of running as the `cockpit-wsinstance-socket`, which was a bit broken. `SupplementaryGroups=` seems not to work well together with `DynamicUser=true`[^2][^3] so use `Group=` instead, putting `cockpit-tls` and `cockpit-ws` into the group of the socket that it needs to connect to. We allow systemd to automatically name the `cockpit-ws` users, for which it picks the usernames `cockpit-wsinstance-https` and `cockpit-wsinstance-http`. Disappointingly, it doesn't use per-instance names for these (which is the documented behaviour[^4]). If we attempt to force the issue by providing our own `User=` containing `%i` then we get a hint about why that might be the case: the created usernames are far too long, causing issues which prevent the service from starting (since our instance IDs are sha256 digests). We *don't* allow systemd to pick the name for the `cockpit.service` unit because it would select the username `cockpit` and it would use this username even if such a (real) user already existed on the system, which seems a) somewhat possible, and b) quite bad. Force it to use a less-likely-to-exist name: `cockpit-systemd-service`. This also means we no longer use the username `cockpit-ws` for anything at all (which might be present on old systems, and might have access to read the TLS certificate and private keys, under old configurations). Now that we no longer depend on a separate unit to create the users that our services run as we can also remove the redundant `Requires=` and `After=` lines for the socket users that we depend on. We already `Requires=`/`After=` the sockets themselves and the sockets have those dependencies on the users. [^1]: systemd/systemd#23067 [^2]: systemd/systemd#26636 [^3]: systemd/systemd#8219 [^4]: https://0pointer.net/blog/dynamic-users-with-systemd.html (search for `[email protected]`)
- Loading branch information
1 parent
12c2b1e
commit 9d8226d
Showing
11 changed files
with
19 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,7 +377,6 @@ authentication via sssd/FreeIPA. | |
%{_unitdir}/cockpit.service | ||
%{_unitdir}/cockpit-motd.service | ||
%{_unitdir}/cockpit.socket | ||
%{_unitdir}/cockpit-ws-user.service | ||
%{_unitdir}/cockpit-session-socket-user.service | ||
%{_unitdir}/cockpit-session.socket | ||
%{_unitdir}/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ ${env:deb_systemdsystemunitdir}/cockpit.socket | |
${env:deb_systemdsystemunitdir}/cockpit-session.socket | ||
${env:deb_systemdsystemunitdir}/[email protected] | ||
${env:deb_systemdsystemunitdir}/cockpit-session-socket-user.service | ||
${env:deb_systemdsystemunitdir}/cockpit-ws-user.service | ||
${env:deb_systemdsystemunitdir}/cockpit-wsinstance-http.service | ||
${env:deb_systemdsystemunitdir}/cockpit-wsinstance-http.socket | ||
${env:deb_systemdsystemunitdir}/[email protected] | ||
|