diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-10-01 23:06:00 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-10-02 09:21:57 +0200 |
commit | 57f4149a87ab7fd44a614658bd3d5ebc725285cd (patch) | |
tree | abcb57585e24a8db1bc261a2cbce4530c7094b41 /libpod | |
parent | 7a5696316a03df5dddded9c3afa8bf26acd74678 (diff) | |
download | podman-57f4149a87ab7fd44a614658bd3d5ebc725285cd.tar.gz podman-57f4149a87ab7fd44a614658bd3d5ebc725285cd.tar.bz2 podman-57f4149a87ab7fd44a614658bd3d5ebc725285cd.zip |
rootless: set DBUS_SESSION_BUS_ADDRESS if it is not set
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: https://github.com/containers/libpod/issues/4162
Closes: https://github.com/containers/libpod/issues/4164
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 675c92b7a..9f3549e00 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -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 { |