summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2019-07-01 14:35:13 -0400
committerTomSweeneyRedHat <tsweeney@redhat.com>2019-07-29 11:29:41 -0400
commit5779e898090b7182ad9307e3ddf1087ac913c770 (patch)
tree6d299bd2db2c339297edddc479a1be19a59de8a6 /libpod
parent6665269ab8bd413799df6568a83a3ac679c93ad1 (diff)
downloadpodman-5779e898090b7182ad9307e3ddf1087ac913c770.tar.gz
podman-5779e898090b7182ad9307e3ddf1087ac913c770.tar.bz2
podman-5779e898090b7182ad9307e3ddf1087ac913c770.zip
Touch up XDG, add rootless links
Touch up a number of formating issues for XDG_RUNTIME_DIRS in a number of man pages. Make use of the XDG_CONFIG_HOME environment variable in a rootless environment if available, or set it if not. Also added a number of links to the Rootless Podman config page and added the location of the auth.json files to that doc. Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 28958e932..c900f2b8b 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -325,16 +325,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()
@@ -362,6 +365,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
}