summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-11 02:32:13 -0700
committerGitHub <noreply@github.com>2019-04-11 02:32:13 -0700
commit638789fd88f60839bd65cad3bc28f0c698d41e32 (patch)
treef4b02034a46fb86caedc007f2492564b26fb5016 /libpod
parentf9ae2d48309f0d51644f0a7da8ab4b6845a9db56 (diff)
parent09532c8cc04f52aad055b995a49f76e7909aa12c (diff)
downloadpodman-638789fd88f60839bd65cad3bc28f0c698d41e32.tar.gz
podman-638789fd88f60839bd65cad3bc28f0c698d41e32.tar.bz2
podman-638789fd88f60839bd65cad3bc28f0c698d41e32.zip
Merge pull request #2896 from giuseppe/fix-segfault-reload
rootless: fix segfault on refresh if there are containers
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 4dd2707e8..3b1c2be98 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -870,6 +870,20 @@ func makeRuntime(runtime *Runtime) (err error) {
_, err = os.Stat(runtimeAliveFile)
if err != nil {
+ // If we need to refresh, then it is safe to assume there are
+ // no containers running. Create immediately a namespace, as
+ // we will need to access the storage.
+ if os.Geteuid() != 0 {
+ aliveLock.Unlock()
+ became, ret, err := rootless.BecomeRootInUserNS()
+ if err != nil {
+ return err
+ }
+ if became {
+ os.Exit(ret)
+ }
+
+ }
// If the file doesn't exist, we need to refresh the state
// This will trigger on first use as well, but refreshing an
// empty state only creates a single file