From: Jeff Trawick Date: Tue, 13 Jan 2004 19:09:40 +0000 (+0000) Subject: Linux 2.4+: If Apache is started as root and you code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18fbf118d61e6fa6adff4bd4485b2b76493e724a;p=thirdparty%2Fapache%2Fhttpd.git Linux 2.4+: If Apache is started as root and you code CoreDumpDirectory, coredumps are enabled via the prctl() syscall. Backport of a 2.x feature by Greg Ames. Submitted by: Jeff Trawick Reviewed by: Joe Orton, Jim Jagielski git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@102322 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index 0fe39a9d610..b4ee3e2b9f9 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 1.3.30 + *) Linux 2.4+: If Apache is started as root and you code + CoreDumpDirectory, coredumps are enabled via the prctl() syscall. + Backport of a 2.x feature by Greg Ames. [Jeff Trawick] + *) Fix bug causing core dump when using CookieTracking without specifying a CookieName directly. Bugz# 24483. [Manni Wood , Jim Jagielski (backport)] diff --git a/src/Configure b/src/Configure index f5d1db69dfc..5ebd86e6538 100755 --- a/src/Configure +++ b/src/Configure @@ -1624,6 +1624,13 @@ case "$PLAT" in if ./helpers/TestCompile lib crypt; then LIBS="$LIBS -lcrypt" fi + # see if prctl(PR_SET_DUMPABLE) is available + if TCADDINCL='#include +static int required_flag = PR_SET_DUMPABLE;' ./helpers/TestCompile sizeof required_flag ; then + if ./helpers/TestCompile func prctl; then + CFLAGS="$CFLAGS -DHAVE_SET_DUMPABLE" + fi + fi ;; *-dg-dgux*) diff --git a/src/main/http_main.c b/src/main/http_main.c index f58efdb8e1c..38795f18717 100644 --- a/src/main/http_main.c +++ b/src/main/http_main.c @@ -123,6 +123,9 @@ int ap_main(int argc, char *argv[]); #ifdef HAVE_BSTRING_H #include /* for IRIX, FD_SET calls bzero() */ #endif +#ifdef HAVE_SET_DUMPABLE /* certain levels of Linux */ +#include +#endif #ifdef MULTITHREAD /* special debug stuff -- PCS */ @@ -309,7 +312,8 @@ static listen_rec *head_listener; API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]=""; API_VAR_EXPORT char ap_server_confname[MAX_STRING_LEN]=""; -API_VAR_EXPORT char ap_coredump_dir[MAX_STRING_LEN]=""; +#define DEFAULT_COREDUMP_DIR "" +API_VAR_EXPORT char ap_coredump_dir[MAX_STRING_LEN]=DEFAULT_COREDUMP_DIR; API_VAR_EXPORT array_header *ap_server_pre_read_config=NULL; API_VAR_EXPORT array_header *ap_server_post_read_config=NULL; @@ -4285,6 +4289,18 @@ static void child_main(int child_num_arg) } #endif +#ifdef HAVE_SET_DUMPABLE + if (strcmp(ap_coredump_dir, DEFAULT_COREDUMP_DIR)) { + /* user set CoredumpDirectory, so they want to get core dumps + */ + if (prctl(PR_SET_DUMPABLE, 1)) { + ap_log_error(APLOG_MARK, APLOG_ALERT, NULL, + "set dumpable failed - this child will not coredump" + " after software errors"); + } + } +#endif + ap_child_init_modules(pchild, server_conf); /* done with the initialization critical section */