mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
Merge pull request #11056 from giuseppe/warning-root-no-shared
rootless: check that / is mounted as shared
This commit is contained in:
@ -14,11 +14,13 @@ import (
|
||||
"os/user"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/containers/podman/v3/pkg/errorhandling"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
pmount "github.com/containers/storage/pkg/mount"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -235,6 +237,24 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo
|
||||
return false, 0, nil
|
||||
}
|
||||
|
||||
if mounts, err := pmount.GetMounts(); err == nil {
|
||||
for _, m := range mounts {
|
||||
if m.Mountpoint == "/" {
|
||||
isShared := false
|
||||
for _, o := range strings.Split(m.Optional, ",") {
|
||||
if strings.HasPrefix(o, "shared:") {
|
||||
isShared = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isShared {
|
||||
logrus.Warningf("%q is not a shared mount, this could cause issues or missing mounts with rootless containers", m.Mountpoint)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cPausePid := C.CString(pausePid)
|
||||
defer C.free(unsafe.Pointer(cPausePid))
|
||||
|
||||
|
Reference in New Issue
Block a user