-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Feature request description
The Podman Quadlet unit generator uses --cidfile=%t/%N.cid in the generated ExecStart, ExecStop, ExecStopPost commands.
The %t specifier is the issue. When a system service uses User=, %t resolves to /run and the unprivileged user doesn't have permissions to create a file there.
Suggest potential solution
A possible solution would be for the Podman unit generator to notice that the .container file has User=foo in it and then use something other than %t. Since XDG_RUNTIME_DIR has to be set for the user anyway, perhaps using that value would work better.
At worst, placing this one file in a common temporary directory with foo as owner and 0600 mode (user-only r/w) would suffice. root can read the file just fine, so the system service manager won't care.
I understand there are issues with these solutions. Please don't let "perfect be the enemy of good". User= support is important and a silly thing like the %t specifier for the cid file directory should really not be a blocker.
Have you considered any alternatives?
Various comments on Podman's (and Systemd's) issue tracker say some version of the following:
If you have to start a user session anyway to be able to use
User=, why not just run the service withsystemctl --user startand be done with it? Just use a proper user service, stop trying to run it as a system service.
There's a bunch of reasons to use a system service, not the least of which is having all system services properly centralized in the system service manager (and all the UX benefits thereof). But these "creature comforts" don't seem to be convincing enough to various people, and I can somewhat understand why.
But then we get to the following: all sorts of useful Systemd features (like sandboxing) do not work with user service managers:
Also note that some sandboxing functionality is generally not available in user services (i.e. services run by the per-user service manager). [systemd.exec manpage]
Not supporting User= well reduces security.
Additional context
@vrothberg mentioned this way back in 2022 in a comment here: #20573 (comment)
Much is different in Systemd and Podman since then, and if I'm not mistaken, this usage of %t is the only blocker for fairly functional usage of User= in quadlet files.
@felixc recently posted a comprehensive report about his experience (thank you!) with using User= with Podman on Debian Trixie. I am running a similar setup to him and can confirm that things pretty much work fine after applying workarounds for Podman issues.
The necessary workarounds:
- Can't use Quadlets because of
%t. - Must work around Podman bug that reads
$HOMEas a fallback to$XDG_CONFIG_HOME(podman runfails when HOME set to invalid path and unprivileged system user specified as systemdUser=#26667) - (I will file bugs for other issues as I discover them)
The admin must also tell Systemd to start the user session for the user specified in User= with sudo loginctl enable-linger myuser (applies after next boot), but that's fair IMO.
Thank you for working on Podman! It's much nicer than Docker. I love you Podman folks, you are the reason I don't have to run a huge VC-backed codebase as a privileged daemon. 🥲
No AI was used to write any part of this issue report. Every word was written by a human.