]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Linux 2.4+: If Apache is started as root and you code
authorJeff Trawick <trawick@apache.org>
Tue, 13 Jan 2004 19:09:40 +0000 (19:09 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 13 Jan 2004 19:09:40 +0000 (19:09 +0000)
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

src/CHANGES
src/Configure
src/main/http_main.c

index 0fe39a9d6108208fa1b6925acfe7bc219a17644e..b4ee3e2b9f9a31ce0a251c2edafe6823c650e2a2 100644 (file)
@@ -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 <manniwood planet-save.com>, Jim Jagielski (backport)]
index f5d1db69dfcd44bd36251d83297e4cf1e6eae83f..5ebd86e653854a91ecb6242a2890ba5b2f35552a 100755 (executable)
@@ -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 <sys/prctl.h>
+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*)
index f58efdb8e1cbb80494ba484822251835d5e33559..38795f18717d8590ec7467eedebca6054cf9490f 100644 (file)
@@ -123,6 +123,9 @@ int ap_main(int argc, char *argv[]);
 #ifdef HAVE_BSTRING_H
 #include <bstring.h>           /* for IRIX, FD_SET calls bzero() */
 #endif
+#ifdef HAVE_SET_DUMPABLE /* certain levels of Linux */
+#include <sys/prctl.h>
+#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 */