Commit Graph

21 Commits

Author SHA1 Message Date
Todd C. Miller
19065cb221 Use strtoul() on systems without strtoull().
We can assume that systems without strtoull() have 32-bit resource limits.
2021-11-08 18:21:15 -07:00
Todd C. Miller
74ef983f60 Add front-end support for setting resouce limits.
The special value "user" means preserve the invoking user's limit.
The value "default" means don't override the default limit for the
user as assigned by the system (PAM, loging.conf, userdb, etc).
2021-11-08 18:21:11 -07:00
Todd C. Miller
b0ae7a566b Avoid using RLIM_INFINITY for the nofile soft limit to prevent
closefrom_fallback() from closing too many file descriptors.
2021-07-23 15:10:46 -06:00
Todd C. Miller
51cbc626f8 Fix debug message when prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) fails.
GitHub issue #101
2021-05-03 12:40:23 -06:00
Todd C. Miller
6717415e73 Add minimum value to consider when overriding resource limits.
Currently only used for RLIMIT_DATA and RLIMIT_AS.

This works around a problem on HP-UX where setting RLIMIT_DATA
changes the resource limits for both 32-bit and 64-bit processes.
HP-UX processes start out with RLIMIT_DATA set based on the values
of the maxdsiz and maxdsiz_64bit kernel tunables, depending on
whether they are 32-bit or 64-bit.  By default this limit is 1GB
for 32-bit processes and 4GB for 64-bit.  However, once RLIMIT_DATA
is changed, it does not appear to be possible to restore the old
values.  This can result in a 64-bit process that is executed by a
32-bit shell getting the 32-bit RLIMIT_DATA instead of the 64-bit
one.  Bug #973
2021-04-20 14:31:40 -06:00
Todd C. Miller
0106343032 Use correct size for curlim and maxlim. 2020-09-03 10:20:28 -06:00
Todd C. Miller
c4a579cf8a Pass resource limits values to the plugin in user_info[]
Sudo resets the resource limits early in its execution so
the plugin cannot tell what the original limits were itself.
2020-08-31 16:37:01 -06:00
Todd C. Miller
84e6e6ccf9 Update copyright year on some files where it was out of date. 2020-08-31 14:09:36 -06:00
Todd C. Miller
446ae3f507 Include string.h unconditionally and only use strings.h for strn?casecmp()
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800 We no longer need to include headers we don't use for sudo*.h files.
Previously we needed to include headers required by the various
sudo*h files.  Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
712afe0319 Ignore a failure to restore the RLIMIT_CORE resource limit.
Linux containers don't allow RLIMIT_CORE to be set back to RLIM_INFINITY
if we set the limit to zero, even for root.  This is not a problem
outside the container.
2020-03-14 11:13:55 -06:00
Todd C. Miller
1e25d03c98 Use 64-bit resource limits on AIX. 2019-12-25 16:39:11 -07:00
Todd C. Miller
dfabda3d49 When restoring old resource limits, try to recover if we receive
EINVAL.  On NetBSD, setrlimit(2) can return EINVAL if the new soft
limit is lower than the current resource usage.  This can be a
problem when restoring the old stack limit if sudo has raised it.
2019-12-25 13:48:04 -07:00
Todd C. Miller
dbc905fdf8 Sudo doesn't require such a large stack. 2019-12-25 13:13:20 -07:00
Todd C. Miller
486ee2b71f debug_decl and debug_decl_vars now require a semicolon at the end. 2019-12-22 08:48:16 -07:00
Todd C. Miller
4392b5726e Output the name of the limit when warning about setrlimit or getrlimit.
From Kimmo Suominen.
2019-12-18 09:42:14 -07:00
Todd C. Miller
9309ca0074 Simplify resource limit fallback logic a bit. 2019-11-12 07:26:14 -07:00
Todd C. Miller
f3ebe5025a Don't set the RLIMIT_STACK soft/hard limits to unlimited.
Use 8Mb for soft and 64Mb for hard.
Works around issues on macOS and docker.  See also Bug #908
2019-11-11 17:57:10 -07:00
Todd C. Miller
0d8062c100 macOS does not allow rlim_cur to be set to RLIM_INFINITY for RLIMIT_NOFILE.
We need to use OPEN_MAX instead as per the macOS setrlimit manual.
Bug #904
2019-10-29 08:28:52 -06:00
Todd C. Miller
5391ee2d5e Not all systems support RLIMIT_NPROC and RLIMIT_RSS 2019-10-21 16:03:10 -06:00
Todd C. Miller
e80079eaa8 Set resource limits in the sudo process to unlimited.
We don't want sudo to be limited by the caller's resource limits.
The original resource limits are restore before session setup.
2019-10-21 11:41:48 -06:00