mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: use Namespaces.IsPrivate more
In these cases, this is exactly what we want to find out. Slightly improves performance and readability. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -34,7 +34,7 @@ func rootlessEUIDMappings(config *configs.Config) error {
|
||||
return errors.New("rootless container requires user namespaces")
|
||||
}
|
||||
// We only require mappings if we are not joining another userns.
|
||||
if path := config.Namespaces.PathOf(configs.NEWUSER); path == "" {
|
||||
if config.Namespaces.IsPrivate(configs.NEWUSER) {
|
||||
if len(config.UIDMappings) == 0 {
|
||||
return errors.New("rootless containers requires at least one UID mapping")
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
|
||||
}
|
||||
config.Namespaces.Add(t, ns.Path)
|
||||
}
|
||||
if config.Namespaces.Contains(configs.NEWNET) && config.Namespaces.PathOf(configs.NEWNET) == "" {
|
||||
if config.Namespaces.IsPrivate(configs.NEWNET) {
|
||||
config.Networks = []*configs.Network{
|
||||
{
|
||||
Type: "loopback",
|
||||
@@ -481,7 +481,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
|
||||
// Only set it if the container will have its own cgroup
|
||||
// namespace and the cgroupfs will be mounted read/write.
|
||||
//
|
||||
hasCgroupNS := config.Namespaces.Contains(configs.NEWCGROUP) && config.Namespaces.PathOf(configs.NEWCGROUP) == ""
|
||||
hasCgroupNS := config.Namespaces.IsPrivate(configs.NEWCGROUP)
|
||||
hasRwCgroupfs := false
|
||||
if hasCgroupNS {
|
||||
for _, m := range config.Mounts {
|
||||
|
||||
Reference in New Issue
Block a user