Skip to content

Commit c9abefb

Browse files
author
Zhou Hao
authored
Merge pull request #480 from wking/linux-rlimits-extend-posix-rlimits
validate/validate: Linux rlimits extend the POSIX rlimits
2 parents 3a6f748 + 894cae7 commit c9abefb

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Diff for: validate/validate.go

+7-13
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import (
3030
const specConfig = "config.json"
3131

3232
var (
33-
defaultRlimits = []string{
33+
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
34+
posixRlimits = []string{
3435
"RLIMIT_AS",
3536
"RLIMIT_CORE",
3637
"RLIMIT_CPU",
@@ -40,24 +41,17 @@ var (
4041
"RLIMIT_STACK",
4142
}
4243

43-
defaultLinuxRlimits = []string{
44-
"RLIMIT_AS",
45-
"RLIMIT_CORE",
46-
"RLIMIT_CPU",
47-
"RLIMIT_DATA",
48-
"RLIMIT_FSIZE",
49-
"RLIMIT_LOCKS",
44+
// https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man2/getrlimit.2?h=man-pages-4.13
45+
linuxRlimits = append(posixRlimits, []string{
5046
"RLIMIT_MEMLOCK",
5147
"RLIMIT_MSGQUEUE",
5248
"RLIMIT_NICE",
53-
"RLIMIT_NOFILE",
5449
"RLIMIT_NPROC",
5550
"RLIMIT_RSS",
5651
"RLIMIT_RTPRIO",
5752
"RLIMIT_RTTIME",
5853
"RLIMIT_SIGPENDING",
59-
"RLIMIT_STACK",
60-
}
54+
}...)
6155

6256
configSchemaTemplate = "https://raw.githubusercontent.com/opencontainers/runtime-spec/v%s/schema/config-schema.json"
6357
)
@@ -879,14 +873,14 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
879873
}
880874

881875
if v.platform == "linux" {
882-
for _, val := range defaultLinuxRlimits {
876+
for _, val := range linuxRlimits {
883877
if val == rlimit.Type {
884878
return
885879
}
886880
}
887881
errs = multierror.Append(errs, fmt.Errorf("rlimit type %q is invalid", rlimit.Type))
888882
} else if v.platform == "solaris" {
889-
for _, val := range defaultRlimits {
883+
for _, val := range posixRlimits {
890884
if val == rlimit.Type {
891885
return
892886
}

0 commit comments

Comments
 (0)