From: Greg Ames Date: Thu, 6 Mar 2003 21:48:58 +0000 (+0000) Subject: Linux 2.4+: enable coredumps when Apache is started as root if X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4dc0df853a82d91d687d2d41f65163e1d7f282a5;p=apache Linux 2.4+: enable coredumps when Apache is started as root if CoreDumpDirectory is explicitly coded git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98908 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 9481968335..033d962f57 100644 --- 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 , Michael Schroepl ] diff --git a/configure.in b/configure.in index d7e23c662d..1a799433aa 100644 --- a/configure.in +++ b/configure.in @@ -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 \ ) diff --git a/docs/manual/mod/mpm_common.xml b/docs/manual/mod/mpm_common.xml index ac61a4dddd..f0a995bf8b 100644 --- a/docs/manual/mod/mpm_common.xml +++ b/docs/manual/mod/mpm_common.xml @@ -110,6 +110,8 @@ switch before dumping core 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.

+

Linux 2.4 and beyond: If you start Apache as root and you + explicitly code CoreDumpDirectory, Apache enables core dumps.

diff --git a/include/mpm_common.h b/include/mpm_common.h index 1c598b4807..5961680089 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -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 diff --git a/os/unix/unixd.c b/os/unix/unixd.c index 4f8b60bd34..11feda653c 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -89,6 +89,9 @@ #ifdef HAVE_SYS_SEM_H #include #endif +#ifdef HAVE_SYS_PRCTL_H +#include +#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; } diff --git a/server/mpm_common.c b/server/mpm_common.c index 4a3a1d562e..86e8ceba85 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -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