Support passing of Ulimits as -1 to mean max

Docker allows the passing of -1 to indicate the maximum limit
allowed for the current process.

Fixes: https://github.com/containers/podman/issues/19319

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-09-08 07:03:49 -04:00
parent 55b9ea3ec7
commit 18d6bb40d5
8 changed files with 65 additions and 3 deletions

View File

@ -1149,6 +1149,23 @@ EOF
assert "$output" =~ " ${nofile2} * ${nofile2} * files"
}
@test "podman run ulimit with -1" {
max=unlimited
if is_rootless; then
run ulimit -c -H
max=$output
fi
run_podman run --ulimit core=-1:-1 --rm $IMAGE grep core /proc/self/limits
assert "$output" =~ " ${max} * ${max} * bytes"
run_podman run --ulimit core=1000:-1 --rm $IMAGE grep core /proc/self/limits
assert "$output" =~ " 1000 * ${max} * bytes"
run_podman 125 run --ulimit core=-1:1000 --rm $IMAGE grep core /proc/self/limits
is "$output" "Error: ulimit option \"core=-1:1000\" requires name=SOFT:HARD, failed to be parsed: ulimit soft limit must be less than or equal to hard limit: soft: -1 (unlimited), hard: 1000"
}
@test "podman run bad --name" {
randomname=$(random_string 30)
run_podman 125 create --name "$randomname/bad" $IMAGE