]> granicus.if.org Git - sudo/commitdiff
Don't change rl.rlim_max for RLIMIT_CORE. We need only set rl.rlim_cur
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 9 Apr 2003 20:13:04 +0000 (20:13 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 9 Apr 2003 20:13:04 +0000 (20:13 +0000)
to 0 to turn off core dumps.  This may be needed for the RLIMIT_CORE
restoration on some OSes.

sudo.c

diff --git a/sudo.c b/sudo.c
index 315a24589c0bbd50dbfc1c378cef9ec3ddbf8b18..f00beb7524cdfa51e4752f9e67bee41b54268cee 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -138,7 +138,7 @@ uid_t timestamp_uid;
 extern int errorlineno;
 #if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
 static struct rlimit corelimit;
-#endif /* RLIMIT_CORE */
+#endif /* RLIMIT_CORE && !SUDO_DEVEL */
 #ifdef HAVE_LOGIN_CAP_H
 login_cap_t *lc;
 #endif /* HAVE_LOGIN_CAP_H */
@@ -391,7 +391,7 @@ main(argc, argv, envp)
        /* Restore coredumpsize resource limit. */
 #if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
        (void) setrlimit(RLIMIT_CORE, &corelimit);
-#endif /* RLIMIT_CORE */
+#endif /* RLIMIT_CORE && !SUDO_DEVEL */
 
        /* Become specified user or root. */
        set_perms(PERM_RUNAS);
@@ -862,9 +862,10 @@ initial_setup()
      * Turn off core dumps.
      */
     (void) getrlimit(RLIMIT_CORE, &corelimit);
-    rl.rlim_cur = rl.rlim_max = 0;
+    memcpy(&rl, &corelimit, sizeof(struct rlimit));
+    rl.rlim_cur = 0;
     (void) setrlimit(RLIMIT_CORE, &rl);
-#endif /* RLIMIT_CORE */
+#endif /* RLIMIT_CORE && !SUDO_DEVEL */
 
     /*
      * Close any open fd's other than stdin, stdout and stderr.