]> granicus.if.org Git - apache/commitdiff
Linux 2.4+: enable coredumps when Apache is started as root if
authorGreg Ames <gregames@apache.org>
Thu, 6 Mar 2003 21:48:58 +0000 (21:48 +0000)
committerGreg Ames <gregames@apache.org>
Thu, 6 Mar 2003 21:48:58 +0000 (21:48 +0000)
            CoreDumpDirectory is explicitly coded

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98908 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
configure.in
docs/manual/mod/mpm_common.xml
include/mpm_common.h
os/unix/unixd.c
server/mpm_common.c

diff --git a/CHANGES b/CHANGES
index 948196833527d39694d79326c00e947067063373..033d962f5712c96cd0270d689555033baa7c919f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Linux 2.4+: enable coredumps when Apache is started as root
+     if CoreDumpDir is configured [Greg Ames]
+
   *) you can now specify the compression level for mod_deflate. 
      [Ian Holsman, Stephen Pierzchala <stephen@pierzchala.com>, 
      Michael Schroepl <Michael.Schroepl@telekurs.de>]
index d7e23c662d0f19a4ce2a2b79a7cb1113578ce753..1a799433aab8a47be2c951f344eec811506d8ecc 100644 (file)
@@ -268,6 +268,7 @@ sys/socket.h \
 pwd.h \
 grp.h \
 strings.h \
+sys/prctl.h \
 sys/processor.h \
 sys/sem.h
 )
@@ -289,6 +290,7 @@ getpwnam \
 getgrnam \
 initgroups \
 bindprocessor \
+prctl \
 timegm \
 )
 
index ac61a4ddddfd7c520918d3974d817cbd4db65e72..f0a995bf8b9ef2c55608c2240669001b2a7ac437 100644 (file)
@@ -110,6 +110,8 @@ switch before dumping core</description>
     as, core dumps won't normally get written. If you want a core
     dump for debugging, you can use this directive to place it in a
     different location.</p>
+    <p>Linux 2.4 and beyond: If you start Apache as root and you
+    explicitly code CoreDumpDirectory, Apache enables core dumps.</p>
 </usage>
 </directivesynopsis>
 
index 1c598b480755099f840729ca64f0e5d820212390..59616800897f73a2eae9e89f043b7a693e9eff0c 100644 (file)
@@ -276,6 +276,7 @@ const char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
  */
 #ifdef AP_MPM_WANT_SET_COREDUMPDIR
 extern char ap_coredump_dir[MAX_STRING_LEN];
+extern int ap_coredumpdir_configured;
 const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
                                    const char *arg);
 #endif
index 4f8b60bd34a105a4c0663b812cdad65330f7b6c6..11feda653c327f32d97cf23d8a3169e4659829ca 100644 (file)
@@ -89,6 +89,9 @@
 #ifdef HAVE_SYS_SEM_H
 #include <sys/sem.h>
 #endif
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 
 unixd_config_rec unixd_config;
 
@@ -181,6 +184,18 @@ AP_DECLARE(int) unixd_setup_child(void)
                     (long) unixd_config.user_id);
        return -1;
     }
+#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) 
+    /* this applies to Linux 2.4+ */
+#ifdef AP_MPM_WANT_SET_COREDUMPDIR
+    if (ap_coredumpdir_configured) {
+        if (prctl(PR_SET_DUMPABLE, 1)) {
+            ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
+                         "set dumpable failed - this child will not coredump"
+                         " after software errors");
+        }
+    }
+#endif
+#endif
 #endif
     return 0;
 }
index 4a3a1d562ed3e476b0dceee628d4fd344bb9da41..86e8ceba853f9f53580eab9a518e52cdcafd1ac4 100644 (file)
@@ -630,6 +630,7 @@ const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
 
 #ifdef AP_MPM_WANT_SET_COREDUMPDIR
 char ap_coredump_dir[MAX_STRING_LEN];
+int ap_coredumpdir_configured;
 
 const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
                                    const char *arg)
@@ -656,6 +657,7 @@ const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
                            " is not a directory", NULL);
     }
     apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
+    ap_coredumpdir_configured = 1;
     return NULL;
 }
 #endif