quadlet: handle missing HOME in rootless configuration lookup - #29483
quadlet: handle missing HOME in rootless configuration lookup#29483shrevid03 wants to merge 1 commit into
Conversation
| } | ||
| } | ||
|
|
||
| func getRootlessConfigDir() (string, error) { |
There was a problem hiding this comment.
We already have a function that does this - pkg/util/utils_supported.go has GetRootlessConfigHomeDir() - I would expect us to re-use that, possibly with modifications.
|
Is this |
Fixes: podman-container-tools#29284 Signed-off-by: Shreya Vidyadhar Keshatti <shrevidh03@gmail.com>
5cdeb44 to
a58650e
Compare
|
Thanks @mheon for pointing that out. I missed GetRootlessConfigHomeDir() when I first worked on this. I’ve updated the patch to remove the Quadlet-specific helper and reuse the existing util helper instead. I also moved the regression test into pkg/util/utils_linux_test.go. |
|
@mheon I looked through the systemd docs, but I couldn’t find anything saying that HOME=/ is expected behavior for a systemd-homed user. |
Luap99
left a comment
There was a problem hiding this comment.
Is this homectl behavior documented anywhere? The completely-unset XDG_CONFIG_HOME and garbage setting for HOME seem like they are a complete contravention of Linux norms and would break so many things, to the point where I have to wonder if they are deliberate or not.
I agree input garbage == output garbage, its not our task to special case incorrect settings. This will create a total mess in the codebase when we just start ignoring certain things in certain places. If the systemd generator env sets these envs incorrectly then it needs to be fixed there IMO.
ygalblum
left a comment
There was a problem hiding this comment.
I commented about the code in case it still gets approved.
But, I agree with @Luap99 this seems like an environment issue caused by systemd. If we bypass it here, what guaranties that we don't hit the next issue caused by this incomplete environment?
| @@ -230,6 +231,12 @@ func getRootlessDirs(paths *searchPaths, nonNumericFilter, userLevelFilter func( | |||
| } | |||
|
|
|||
| configDir, err := os.UserConfigDir() | |||
There was a problem hiding this comment.
Why can't Quadlet just call util.GetRootlessConfigHomeDir with the new addition? All these checks seem duplicated
Summary
This addresses #29284, where rootless Quadlet files can be discovered by
podman quadlet listbut are not loaded by the systemd user generator in thereproduced
systemd-homedsetup.I reproduced the issue on Fedora CoreOS 44 using a disposable user created with
homectl. The actual user-generator environment was:Rootless Quadlet uses
os.UserConfigDir()to determine the user's configurationdirectory. With
HOME=/and noXDG_CONFIG_HOME, this resolves to/.config,so the user's actual
~/.config/containers/systemddirectory is not searched.User lookup still returns the correct home directory:
The change reuses Podman's existing
GetRootlessConfigHomeDir()path when therootless home environment is unusable. For the reproduced
HOME=/case, thehelper resolves the rootless user's UID using
rootless.GetRootlessUID()anduses the home directory returned by the user database.
Normal Quadlet lookup continues to use
os.UserConfigDir(), and explicitXDG_CONFIG_HOMEbehavior remains unchanged.Fixes: #29284
Reproduction
I created a disposable
systemd-homeduser and placedpgsql.containerandpgsql.podunder:Before the fix:
podman quadlet listdiscovered both files but reported them asNot loaded./usr/libexec/podman/quadlet -dryrun -userfrom the user's normal login environment generated both units correctly.systemctl --user daemon-reloadgenerated neither unit.The actual environment observed for
podman-user-generatorwas:Running Quadlet manually with the same
HOME=/environment reproduced thediscovery failure, narrowing the issue to rootless config-directory resolution
in the generator environment.
Testing
Added
TestGetRootlessConfigHomeDirWithRootHomein the Linux util tests tocover the
HOME=/regression.The relevant package tests pass:
git diff --checkalso passes.During the original reproduction, I also built the patched Quadlet binary and
exercised the systemd user-generator path. After:
the previously missing units were generated:
make validateprwas also attempted, butgolangci-lintwas killed with exit137 on the 2 GB validation VM, so the full validation did not complete.
Scope
The change is limited to rootless Quadlet source-directory lookup when the
systemd user generator does not receive a usable home directory.
It does not change:
HOMEhandlingXDG_CONFIG_HOMEhandlingpodman quadlet install