return (uid_t) 0 == ruid && ruid == euid ? 0 : 1;
}
+/* Don't rely on PAM and reset the most important limits. */
static void sanitize_prlimits(void)
{
#ifdef HAVE_SYS_RESOURCE_H
struct rlimit lm = { .rlim_cur = 0, .rlim_max = 0 };
+ /* reset to zero */
setrlimit(RLIMIT_NICE, &lm);
setrlimit(RLIMIT_RTPRIO, &lm);
+
+ /* reset to unlimited */
+ lm.rlim_cur = RLIM_INFINITY;
+ lm.rlim_max = RLIM_INFINITY;
+ setrlimit(RLIMIT_FSIZE, &lm);
+
+ /* reset soft limit only */
+ getrlimit(RLIMIT_NOFILE, &lm);
+ if (lm.rlim_cur != FD_SETSIZE) {
+ lm.rlim_cur = FD_SETSIZE;
+ setrlimit(RLIMIT_NOFILE, &lm);
+ }
#endif
}
Note that *su* in all cases uses PAM (*pam_getenvlist*(3)) to do the final environment modification. Command-line options such as *--login* and *--preserve-environment* affect the environment before it is modified by PAM.
-Since version 2.38 *su* resets process resource limits RLIMIT_NICE and RLIMIT_RTPRIO to zero.
+Since version 2.38 *su* resets process resource limits RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_FSIZE and RLIMIT_NOFILE.
== OPTIONS