Skip to content

Commit

Permalink
config: detect XDG_RUNTIME_DIR if empty
Browse files Browse the repository at this point in the history
follow-up for commit 464e79b.

use the homedir package to find the runtime directory, and look there
for the dbus session socket when XDG_RUNTIME_DIR is not set.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jan 13, 2025
1 parent 03380ec commit acd2e61
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 acd2e61

Please sign in to comment.