Skip to content

Commit

Permalink
podman: bump RLIMIT_NOFILE also without CAP_SYS_RESOURCE
Browse files Browse the repository at this point in the history
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: #2123

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Jan 10, 2019
1 parent 0f6535c commit a2c1a2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,20 @@ func main() {
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.Cur = 1048576
rlimits.Max = 1048576
rlimits := new(syscall.Rlimit)
rlimits.Cur = 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 {
return errors.Wrapf(err, "error setting new rlimits")
}
} else {
}

if rootless.IsRootless() {
logrus.Info("running as rootless")
}

Expand Down
2 changes: 1 addition & 1 deletion libpod/container_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2c1a2d

Please sign in to comment.