summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Dieter <jdieter@gmail.com>2019-12-07 14:17:35 +0000
committerJonathan Dieter <jdieter@gmail.com>2019-12-07 14:18:55 +0000
commitb3014c1c69d5870104aa45f7caae7af041094171 (patch)
tree689274776320eda58ad7c1c3db95726c467f80ae
parent82a83b9ff55e1f22cb1951b927de29866fa44054 (diff)
downloadpodman-b3014c1c69d5870104aa45f7caae7af041094171.tar.gz
podman-b3014c1c69d5870104aa45f7caae7af041094171.tar.bz2
podman-b3014c1c69d5870104aa45f7caae7af041094171.zip
Return empty runtime directory if we're not rootless
Currently, we return a runtime directory of the form `/run/user/<uid>`, even when running as root. Depending on configuration, that directory may be deleted when the user logs out, which is quite awkward when the container is started as a systemd service and then someone logs in and out as root. This patch fixes the problem by returning an empty runtime directory if the container is being started by root. The runtime should automatically use the default runtime directory (`/run/crun` when crun is used), which should be accessible to root. Tested in Fedora 31 by running containers under both root and a regular user. State for root containers is stored in `/run/crun`, while state for rootless containers is in `/run/user/<uid>/crun`. Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
-rw-r--r--pkg/util/utils_supported.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/util/utils_supported.go b/pkg/util/utils_supported.go
index 253460686..0b78a8150 100644
--- a/pkg/util/utils_supported.go
+++ b/pkg/util/utils_supported.go
@@ -20,6 +20,10 @@ import (
func GetRuntimeDir() (string, error) {
var rootlessRuntimeDirError error
+ if !rootless.IsRootless() {
+ return "", nil
+ }
+
rootlessRuntimeDirOnce.Do(func() {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
uid := fmt.Sprintf("%d", rootless.GetRootlessUID())