Blame SOURCES/sudo-1.8.6p7-nproc-nowait.patch

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