Blob Blame History Raw
diff -up sudo-1.8.6p7/src/exec.c.nproc-nowait sudo-1.8.6p7/src/exec.c
--- sudo-1.8.6p7/src/exec.c.nproc-nowait	2016-05-11 12:56:58.694022525 +0200
+++ sudo-1.8.6p7/src/exec.c	2016-05-11 12:56:58.759021618 +0200
@@ -298,6 +298,7 @@ sudo_execute(struct command_details *det
      */
     if (details->flags & CD_DONTWAIT) {
         if (exec_setup(details, NULL, -1) == true) {
+            restore_nproc();
             /* headed for execve() */
             sudo_debug_execve(SUDO_DEBUG_INFO, details->command,
                               details->argv, details->envp);
diff -up sudo-1.8.6p7/src/sudo.c.nproc-nowait sudo-1.8.6p7/src/sudo.c
--- sudo-1.8.6p7/src/sudo.c.nproc-nowait	2016-05-11 12:56:58.758021632 +0200
+++ sudo-1.8.6p7/src/sudo.c	2016-05-11 13:12:21.833116202 +0200
@@ -145,6 +145,7 @@ static struct rlimit corelimit;
 #endif /* RLIMIT_CORE */
 #if defined(__linux__)
 static struct rlimit nproclimit;
+static struct rlimit orig_nproc_limit;
 #endif
 
 int
@@ -853,6 +854,17 @@ unlimit_nproc(void)
 	debug_return;
 }
 
+void restore_nproc(void)
+{
+    debug_decl(restore_nproc, SUDO_DEBUG_EXEC);
+#if defined(__linux__)
+    if (setrlimit(RLIMIT_NPROC, &orig_nproc_limit) != 0) {
+	errorx(1, _("Cannot restore nproc rlimit: errno=%d"), errno);
+    }
+#endif
+    debug_return;
+}
+
 #ifdef HAVE_PROJECT_H
 static void
 set_project(struct passwd *pw)
@@ -1089,6 +1101,7 @@ exec_setup(struct command_details *detai
      */
 #if defined(__linux__) && defined(_SC_CHILD_MAX)
     {
+	getrlimit(RLIMIT_NPROC, &orig_nproc_limit);
 	struct rlimit rl;
 	long l;
 	errno = 0;