Rather than using multiple symbols (HAVE_SYS_PRCTL_H, HAVE_PRCTL), which would add to the CFLAGS, there is a single symbol HAVE_SET_DUMPABLE which is defined via CFLAGS if all prerequisites are met.

testing:

Fedora Core 1: verified that feature was recognized and that the new code was required to get a coredump

RedHat 6.1: verified that feature was not recognized

Solaris 9: verfied that feature test was bypassed since platform != linux, and http_main.c compiles with no error

Index: src/Configure
===================================================================
RCS file: /home/cvs/apache-1.3/src/Configure,v
retrieving revision 1.466
diff -u -r1.466 Configure
--- src/Configure       1 Jan 2004 13:32:53 -0000       1.466
+++ src/Configure       13 Jan 2004 14:17:54 -0000
@@ -1624,6 +1624,13 @@
        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: src/main/http_main.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.606
diff -u -r1.606 http_main.c
--- src/main/http_main.c        1 Jan 2004 13:32:54 -0000       1.606
+++ src/main/http_main.c        13 Jan 2004 14:18:02 -0000
@@ -123,6 +123,9 @@
 #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 @@
 
 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;
@@ -4282,6 +4286,18 @@
        ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf,
                    "setuid: unable to change to uid: %ld", (long) ap_user_id);
        clean_child_exit(APEXIT_CHILDFATAL);
+    }
+#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
 

Reply via email to