Skip to content

Commit 2a94c36

Browse files
committed
validator: unbreak sysctl net.* validation
When changing this validation, the code actually allowing the validation to pass was removed. This meant that any net.* sysctl would always fail to validate. Fixes: bc84f83 ("fix moby/moby#27484") Reported-by: Justin Cormack <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]>
1 parent d6b68e8 commit 2a94c36

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libcontainer/configs/validate/validator.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ func (v *ConfigValidator) sysctl(config *configs.Config) error {
125125
}
126126
}
127127
if strings.HasPrefix(s, "net.") {
128-
if !config.Namespaces.Contains(configs.NEWNET) {
129-
return fmt.Errorf("sysctl %q is not allowed in the hosts network namespace", s)
130-
}
131-
if path := config.Namespaces.PathOf(configs.NEWNET); path != "" {
132-
if err := checkHostNs(s, path); err != nil {
133-
return err
128+
if config.Namespaces.Contains(configs.NEWNET) {
129+
if path := config.Namespaces.PathOf(configs.NEWNET); path != "" {
130+
if err := checkHostNs(s, path); err != nil {
131+
return err
132+
}
134133
}
134+
continue
135+
} else {
136+
return fmt.Errorf("sysctl %q is not allowed in the hosts network namespace", s)
135137
}
136138
}
137139
return fmt.Errorf("sysctl %q is not in a separate kernel namespace", s)

0 commit comments

Comments
 (0)