Skip to content

Commit

Permalink
rootless: set DBUS_SESSION_BUS_ADDRESS if it is not set
Browse files Browse the repository at this point in the history
if the variable is not set, make sure it has a sane value so that
go-dbus won't try to connect to the wrong user session.

Closes: containers#4162
Closes: containers#4164

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Oct 2, 2019
1 parent 7a56963 commit 57f4149
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ func SetXdgDirs() error {
return errors.Wrapf(err, "cannot set XDG_RUNTIME_DIR")
}

if rootless.IsRootless() && os.Getenv("DBUS_SESSION_BUS_ADDRESS") == "" {
sessionAddr := filepath.Join(runtimeDir, "bus")
if _, err := os.Stat(sessionAddr); err == nil {
os.Setenv("DBUS_SESSION_BUS_ADDRESS", fmt.Sprintf("unix:path=%s", sessionAddr))
}
}

// Setup XDG_CONFIG_HOME
if cfgHomeDir := os.Getenv("XDG_CONFIG_HOME"); cfgHomeDir == "" {
if cfgHomeDir, err = util.GetRootlessConfigHomeDir(); err != nil {
Expand Down

0 comments on commit 57f4149

Please sign in to comment.