mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
rlimit-util: tweak setrlimit_closest() a bit
POSIX doesn't declare too clearly how RLIM_INFINITY is set. Let's hence filter it out explicitly early on, just as safety precaution should it be defined weirdly on some arch, for example negative or below the maximum value of the rlim_t type.
This commit is contained in:
parent
37bc14de5b
commit
114c55f2d5
@ -33,6 +33,11 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
|
||||
if (getrlimit(resource, &highest) < 0)
|
||||
return -errno;
|
||||
|
||||
/* If the hard limit is unbounded anyway, then the EPERM had other reasons, let's propagate the original EPERM
|
||||
* then */
|
||||
if (highest.rlim_max == RLIM_INFINITY)
|
||||
return -EPERM;
|
||||
|
||||
fixed.rlim_cur = MIN(rlim->rlim_cur, highest.rlim_max);
|
||||
fixed.rlim_max = MIN(rlim->rlim_max, highest.rlim_max);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user