mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Merge pull request #2896 from giuseppe/fix-segfault-reload
rootless: fix segfault on refresh if there are containers
This commit is contained in:
@ -870,6 +870,20 @@ func makeRuntime(runtime *Runtime) (err error) {
|
|||||||
|
|
||||||
_, err = os.Stat(runtimeAliveFile)
|
_, err = os.Stat(runtimeAliveFile)
|
||||||
if err != nil {
|
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
|
// If the file doesn't exist, we need to refresh the state
|
||||||
// This will trigger on first use as well, but refreshing an
|
// This will trigger on first use as well, but refreshing an
|
||||||
// empty state only creates a single file
|
// empty state only creates a single file
|
||||||
|
Reference in New Issue
Block a user