[sudo-users] Sudo and ulimits
Todd C. Miller
Todd.Miller at courtesan.com
Sat Jan 26 18:47:48 EST 2008
Can you try the following diff and see if it works around the
problem?
- todd
Index: sudo.c
===================================================================
RCS file: /home/cvs/courtesan/sudo/sudo.c,v
retrieving revision 1.369.2.34
diff -u -r1.369.2.34 sudo.c
--- sudo.c 13 Dec 2007 14:12:49 -0000 1.369.2.34
+++ sudo.c 26 Jan 2008 23:46:42 -0000
@@ -146,6 +146,9 @@
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
static struct rlimit corelimit;
#endif /* RLIMIT_CORE && !SUDO_DEVEL */
+#if defined(RLIMIT_NPROC)
+static struct rlimit nproclimit;
+#endif /* RLIMIT_NPROC */
#ifdef HAVE_LOGIN_CAP_H
login_cap_t *lc;
#endif /* HAVE_LOGIN_CAP_H */
@@ -400,10 +403,13 @@
if (def_umask != 0777)
(void) umask(def_umask);
- /* Restore coredumpsize resource limit. */
+ /* Restore resource limits. */
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
(void) setrlimit(RLIMIT_CORE, &corelimit);
-#endif /* RLIMIT_CORE && !SUDO_DEVEL */
+#endif
+#if defined(RLIMIT_NPROC)
+ (void) setrlimit(RLIMIT_NPROC, &nproclimit);
+#endif
/* Become specified user or root if executing a command. */
if (ISSET(sudo_mode, MODE_RUN))
@@ -992,9 +998,20 @@
initial_setup()
{
int miss[3], devnull = -1;
-#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
struct rlimit rl;
+#if defined(RLIMIT_NPROC)
+ /*
+ * Unlimit the number of processes
+ */
+ (void) getrlimit(RLIMIT_NPROC, &nproclimit);
+ rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
+ if (setrlimit(RLIMIT_NPROC, &rl)) {
+ rl.rlim_cur = rl.rlim_max = nproclimit.rlim_max;
+ (void)setrlimit(RLIMIT_NPROC, &rl);
+ }
+#endif /* RLIMIT_NPROC */
+#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
/*
* Turn off core dumps.
*/
More information about the sudo-users
mailing list