diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/spec/spec.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index acc41f7c5..dcf1c51dd 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -326,6 +326,14 @@ func addPidNS(config *CreateConfig, g *generate.Generator) error { } func addUserNS(config *CreateConfig, g *generate.Generator) error { + if IsNS(string(config.UsernsMode)) { + g.AddOrReplaceLinuxNamespace(spec.UserNamespace, NS(string(config.UsernsMode))) + + // runc complains if no mapping is specified, even if we join another ns. So provide a dummy mapping + g.AddLinuxUIDMapping(uint32(0), uint32(0), uint32(1)) + g.AddLinuxGIDMapping(uint32(0), uint32(0), uint32(1)) + } + if (len(config.IDMappings.UIDMap) > 0 || len(config.IDMappings.GIDMap) > 0) && !config.UsernsMode.IsHost() { g.AddOrReplaceLinuxNamespace(spec.UserNamespace, "") } |