Merge pull request #4166 from giuseppe/set-dbus-session-if-not-set

rootless: set DBUS_SESSION_BUS_ADDRESS if it is not set
This commit is contained in:
OpenShift Merge Robot 2019-10-02 02:33:24 -07:00 • committed by GitHub
commit 32a2ce8fc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {