Use runuser/run0 to connect to systemd --user instance#577
Merged
traylenator merged 1 commit intovoxpupuli:masterfrom Oct 24, 2025
Merged
Use runuser/run0 to connect to systemd --user instance#577traylenator merged 1 commit intovoxpupuli:masterfrom
runuser/run0 to connect to systemd --user instance#577traylenator merged 1 commit intovoxpupuli:masterfrom
Conversation
bd09440 to
5d75c89
Compare
runuser to connect to systemd --user instance
kenyon
reviewed
Oct 23, 2025
600726b to
d544121
Compare
Create a new function `systemd::systemctl_user` to construct array of command used to contact `systemd --user` instance so `systemctl --user status my.service` can be executed. In addition we switch to using `runuser` or `run0` for systemd >= 256 to become the user. * Using `systemctl` or `systemd-run` with --machinectl [email protected] always fails when puppet is ran inside its own systemd unit. I believe systemd services can not access `systemd --user` instances. * We use `runuser -u $user` rather than a `user => $user` on the exec since the $(id -u $user) must be resolved late within the exec itself. Now the command is generated inside a function this will make future improvements to this method much simpler.
runuser to connect to systemd --user instancerunuser/run0 to connect to systemd --user instance
Contributor
Author
|
Very happy to remove the |
bastelfreak
approved these changes
Oct 24, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request (PR) description
Create a new function
systemd::systemctl_userto construct array of command and args used to contactsystemd --userinstances sosystemctl --user status my.servicecan be executed.On systemd >= 256
run0is used withrunuserused on older OSes (RHEL9, Debian 12, .. )A new boolean is also added
install_runuserto installutil-linuxif needed which seems to be the correct package for all distributions. In reality this package will be installed on most systems anyway.We switch to using
runuserorrun0to become the user since:systemctlorsystemd-runwith--machinectl [email protected]always fails when puppet is ran inside its own systemd unit. I believe systemd services can not accesssystemd --userinstances.runuser -u $userrather than auser => $useron the exec since the $(id -u $user) must be resolved late within the exec itself.Now the command is generated inside a function this will make future improvements to this method much simpler.
This Pull Request (PR) fixes the following issues