mirror of https://github.com/containers/podman.git
podman: bump RLIMIT_NOFILE also without CAP_SYS_RESOURCE
If we are not able to make arbitrary changes to the RLIMIT_NOFILE when lacking CAP_SYS_RESOURCE, don't fail but bump the limit to the maximum allowed. In this way the same code path works with rootless mode. Closes: https://github.com/containers/libpod/issues/2123 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
0f6535cf6b
commit
a2c1a2df54
|
|
@ -148,16 +148,20 @@ func main() {
|
||||||
logrus.SetLevel(level)
|
logrus.SetLevel(level)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only if not rootless, set rlimits for open files.
|
|
||||||
// We open numerous FDs for ports opened
|
|
||||||
if !rootless.IsRootless() {
|
|
||||||
rlimits := new(syscall.Rlimit)
|
rlimits := new(syscall.Rlimit)
|
||||||
rlimits.Cur = 1048576
|
rlimits.Cur = 1048576
|
||||||
rlimits.Max = 1048576
|
rlimits.Max = 1048576
|
||||||
|
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil {
|
||||||
|
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil {
|
||||||
|
return errors.Wrapf(err, "error getting rlimits")
|
||||||
|
}
|
||||||
|
rlimits.Cur = rlimits.Max
|
||||||
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil {
|
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil {
|
||||||
return errors.Wrapf(err, "error setting new rlimits")
|
return errors.Wrapf(err, "error setting new rlimits")
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if rootless.IsRootless() {
|
||||||
logrus.Info("running as rootless")
|
logrus.Info("running as rootless")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// +build seccomp ostree selinux varlink exclude_graphdriver_devicemapper
|
// +build seccomp ostree selinux varlink exclude_graphdriver_devicemapper
|
||||||
|
|
||||||
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT
|
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
|
||||||
|
|
||||||
package libpod
|
package libpod
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue