Skip to content

Commit

Permalink
Merge pull request #2294 from giuseppe/guess-xdg-runtime-dir
Browse files Browse the repository at this point in the history
config: detect XDG_RUNTIME_DIR if empty
  • Loading branch information
openshift-merge-bot[bot] authored Jan 13, 2025
2 parents 03380ec + acd2e61 commit a0fde92
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/containers/common/libnetwork/types"
"github.com/containers/common/pkg/capabilities"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/homedir"
"github.com/containers/storage/pkg/unshare"
units "github.com/docker/go-units"
selinux "github.com/opencontainers/selinux/go-selinux"
Expand Down Expand Up @@ -740,7 +741,13 @@ func (c *Config) CheckCgroupsAndAdjustConfig() {

session, found := os.LookupEnv("DBUS_SESSION_BUS_ADDRESS")
if !found {
sessionAddr := filepath.Join(os.Getenv("XDG_RUNTIME_DIR"), "bus")
xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR")
if xdgRuntimeDir == "" {
if dir, err := homedir.GetRuntimeDir(); err == nil {
xdgRuntimeDir = dir
}
}
sessionAddr := filepath.Join(xdgRuntimeDir, "bus")
if err := fileutils.Exists(sessionAddr); err == nil {
sessionAddr, err = filepath.EvalSymlinks(sessionAddr)
if err == nil {
Expand Down

0 comments on commit a0fde92

Please sign in to comment.