Skip to content

Commit 41437b4

Browse files
committed
return usernsmode=private for created containers with userns=auto
Signed-off-by: Riccardo Paolo Bestetti <pbl@bestov.io>
1 parent dee7350 commit 41437b4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

libpod/container_inspect_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ func (c *Container) platformInspectContainerHostConfig(ctrSpec *spec.Spec, hostC
294294
}
295295
}
296296
}
297+
298+
// If userns=auto, setting up the namespace is deferred until the container
299+
// is created. If the container is configured, check if it is going to have a
300+
// private userns and return accordingly
301+
if c.state.State == define.ContainerStateConfigured && c.config.IDMappings.AutoUserNs {
302+
usernsMode = "private"
303+
}
297304
}
298305
hostConfig.UsernsMode = usernsMode
299306
if c.config.IDMappings.UIDMap != nil && c.config.IDMappings.GIDMap != nil {

libpod/container_internal_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
682682
}
683683
}
684684

685-
// Add shared namespaces from other containers
685+
// Add shared namespaces from other containers. Also handles userns=auto
686686
if err := c.addSharedNamespaces(&g); err != nil {
687687
return nil, nil, err
688688
}

0 commit comments

Comments
 (0)