mirror of
https://github.com/containers/podman.git
synced 2025-12-15 11:42:28 +08:00
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.0.0-rc93 to 1.0.0-rc94. - [Release notes](https://github.com/opencontainers/runc/releases) - [Commits](https://github.com/opencontainers/runc/compare/v1.0.0-rc93...v1.0.0-rc94) Signed-off-by: dependabot[bot] <support@github.com>
38 lines
848 B
Go
38 lines
848 B
Go
package userns
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/user"
|
|
)
|
|
|
|
var (
|
|
inUserNS bool
|
|
nsOnce sync.Once
|
|
)
|
|
|
|
// runningInUserNS detects whether we are currently running in a user namespace.
|
|
// Originally copied from github.com/lxc/lxd/shared/util.go
|
|
func runningInUserNS() bool {
|
|
nsOnce.Do(func() {
|
|
uidmap, err := user.CurrentProcessUIDMap()
|
|
if err != nil {
|
|
// This kernel-provided file only exists if user namespaces are supported
|
|
return
|
|
}
|
|
inUserNS = uidMapInUserNS(uidmap)
|
|
})
|
|
return inUserNS
|
|
}
|
|
|
|
func uidMapInUserNS(uidmap []user.IDMap) bool {
|
|
/*
|
|
* We assume we are in the initial user namespace if we have a full
|
|
* range - 4294967295 uids starting at uid 0.
|
|
*/
|
|
if len(uidmap) == 1 && uidmap[0].ID == 0 && uidmap[0].ParentID == 0 && uidmap[0].Count == 4294967295 {
|
|
return false
|
|
}
|
|
return true
|
|
}
|