Description
Issue Description
XDG runtime checks should not be performed when only the go bindings are used.
After updating our podman go bindings from 4.9.4 to 5.0.3, our application began failing with the error
time="2024-08-29T22:12:26Z" level=error msg="stat /.config: no such file or directory"
We tracked this down to https://github.com/containers/storage/blob/main/pkg/homedir/homedir_unix.go#L120-L123, where the XDG runtime checks are verifying that $HOME/.config
exists. Our application runs in a container with $HOME
set to /
, and there is no .config, and the runtime non-root user doesn't have permission to create it.
Inserting a debug.PrintStack()
in GetConfigHome()
shows this stack trace:
goroutine 1 [running, locked to thread]:
runtime/debug.Stack()
/usr/lib/golang/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
/usr/lib/golang/src/runtime/debug/stack.go:16 +0x13
github.com/containers/storage/pkg/homedir.GetConfigHome.func1()
/app/vendor/github.com/containers/storage/pkg/homedir/homedir_unix.go:122 +0x176
sync.(*Once).doSlow(0x3e9?, 0x0?)
/usr/lib/golang/src/sync/once.go:74 +0xbf
sync.(*Once).Do(...)
/usr/lib/golang/src/sync/once.go:65
github.com/containers/storage/pkg/homedir.GetConfigHome()
/app/vendor/github.com/containers/storage/pkg/homedir/homedir_unix.go:111 +0x2c
github.com/containers/common/pkg/config.defaultConfig()
/app/vendor/github.com/containers/common/pkg/config/default.go:201 +0x7a
github.com/containers/common/pkg/config.newLocked(0xc00035fd78)
/app/vendor/github.com/containers/common/pkg/config/new.go:71 +0x2a
github.com/containers/common/pkg/config.Default()
/app/vendor/github.com/containers/common/pkg/config/new.go:63 +0xfe
github.com/containers/podman/v5/pkg/util.init.0()
/app/vendor/github.com/containers/podman/v5/pkg/util/utils.go:48 +0x13
Additional context: https://redhat-internal.slack.com/archives/CBBJY9GSX/p1725040560356209
Steps to reproduce the issue
Steps to reproduce the issue
- Create a go program that imports the podman bindings
- Run the go program as an unprivileged user with
$HOME=/
or other un-writable directory. - Program exits unexpectedly
Describe the results you received
Program exits with the error
time="2024-08-29T22:12:26Z" level=error msg="stat /.config: no such file or directory"
Describe the results you expected
Program runs as expected
podman info output
n/a, we are not actually running podman
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting