Use runuser/run0 to connect to systemd --user instance
#577
+229
−51
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