Skip to content

Commit 5f5783d

Browse files
Merge pull request #24547 from giuseppe/clamp-limits-userns
spec: clamp rlimits in a userns
2 parents f41eab2 + 0a69aef commit 5f5783d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

libpod/container_internal_common.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
662662
// setup rlimits
663663
nofileSet := false
664664
nprocSet := false
665-
isRootless := rootless.IsRootless()
666665
isRunningInUserNs := unshare.IsRootless()
667666
if isRunningInUserNs && g.Config.Process != nil && g.Config.Process.OOMScoreAdj != nil {
668667
var err error
@@ -682,7 +681,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
682681
if !nofileSet {
683682
max := rlimT(define.RLimitDefaultValue)
684683
current := rlimT(define.RLimitDefaultValue)
685-
if isRootless {
684+
if isRunningInUserNs {
686685
var rlimit unix.Rlimit
687686
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
688687
logrus.Warnf("Failed to return RLIMIT_NOFILE ulimit %q", err)
@@ -699,7 +698,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
699698
if !nprocSet {
700699
max := rlimT(define.RLimitDefaultValue)
701700
current := rlimT(define.RLimitDefaultValue)
702-
if isRootless {
701+
if isRunningInUserNs {
703702
var rlimit unix.Rlimit
704703
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
705704
logrus.Warnf("Failed to return RLIMIT_NPROC ulimit %q", err)

0 commit comments

Comments
 (0)