diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-06 17:42:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-06 17:42:54 +0200 |
commit | 37b40e9acdae6bfa79d53928361540754417cdc6 (patch) | |
tree | 77a8f189ed503f5c75efa27a4702ea8b4e004bb0 /libpod/runtime.go | |
parent | 3bffe77f824772b841080ea463324f5ae5c833d4 (diff) | |
parent | 5779e898090b7182ad9307e3ddf1087ac913c770 (diff) | |
download | podman-37b40e9acdae6bfa79d53928361540754417cdc6.tar.gz podman-37b40e9acdae6bfa79d53928361540754417cdc6.tar.bz2 podman-37b40e9acdae6bfa79d53928361540754417cdc6.zip |
Merge pull request #3466 from TomSweeneyRedHat/dev/tsweeney/myhome
Touch up XDG, add rootless links
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index b66b68cfd..38bfac8ba 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -328,16 +328,19 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { }, nil } -// SetXdgRuntimeDir ensures the XDG_RUNTIME_DIR env variable is set -// containers/image uses XDG_RUNTIME_DIR to locate the auth file. -// It internally calls EnableLinger() so that the user's processes are not +// SetXdgDirs ensures the XDG_RUNTIME_DIR env and XDG_CONFIG_HOME variables are set. +// containers/image uses XDG_RUNTIME_DIR to locate the auth file, XDG_CONFIG_HOME is +// use for the libpod.conf configuration file. +// SetXdgDirs internally calls EnableLinger() so that the user's processes are not // killed once the session is terminated. EnableLinger() also attempts to // get the runtime directory when XDG_RUNTIME_DIR is not specified. -func SetXdgRuntimeDir() error { +// This function should only be called when running rootless. +func SetXdgDirs() error { if !rootless.IsRootless() { return nil } + // Setup XDG_RUNTIME_DIR runtimeDir := os.Getenv("XDG_RUNTIME_DIR") runtimeDirLinger, err := rootless.EnableLinger() @@ -365,6 +368,16 @@ func SetXdgRuntimeDir() error { if err := os.Setenv("XDG_RUNTIME_DIR", runtimeDir); err != nil { return errors.Wrapf(err, "cannot set XDG_RUNTIME_DIR") } + + // Setup XDG_CONFIG_HOME + if cfgHomeDir := os.Getenv("XDG_CONFIG_HOME"); cfgHomeDir == "" { + if cfgHomeDir, err = util.GetRootlessConfigHomeDir(); err != nil { + return err + } + if err = os.Setenv("XDG_CONFIG_HOME", cfgHomeDir); err != nil { + return errors.Wrapf(err, "cannot set XDG_CONFIG_HOME") + } + } return nil } |