Refactors getRootIDs
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
3856e27560
commit
817c2089aa
6 changed files with 68 additions and 23 deletions
22
runtime/container_linux.go
Normal file
22
runtime/container_linux.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package runtime
|
||||
|
||||
import "github.com/opencontainers/specs"
|
||||
|
||||
func getRootIDs(s *platformSpec) (int, int, error) {
|
||||
if s == nil {
|
||||
return 0, 0, nil
|
||||
}
|
||||
var hasUserns bool
|
||||
for _, ns := range s.Linux.Namespaces {
|
||||
if ns.Type == specs.UserNamespace {
|
||||
hasUserns = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasUserns {
|
||||
return 0, 0, nil
|
||||
}
|
||||
uid := hostIDFromMap(0, s.Linux.UIDMappings)
|
||||
gid := hostIDFromMap(0, s.Linux.GIDMappings)
|
||||
return uid, gid, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue