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 275ff18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ 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 {
logrus.Info("running as rootless")
}

// Be sure we can create directories with 0755 mode.
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 275ff18

Please sign in to comment.