enable PR_SET_DUMPABLE in daemon process to enable core dumps

This commit is contained in:
Joe Orton 2012-10-17 14:37:44 +01:00
parent 76920be5e5
commit 6e3a0df92d
3 changed files with 52 additions and 5 deletions

View File

@ -0,0 +1,42 @@
--- mod_wsgi-3.4/configure.ac.dumpcore
+++ mod_wsgi-3.4/configure.ac
@@ -39,6 +39,8 @@ fi
AC_SUBST(APXS)
+AC_CHECK_FUNCS(prctl)
+
AC_MSG_CHECKING(Apache version)
HTTPD="`${APXS} -q SBINDIR`/`${APXS} -q TARGET`"
HTTPD_INCLUDEDIR="`${APXS} -q INCLUDEDIR`"
--- mod_wsgi-3.4/mod_wsgi.c.coredump
+++ mod_wsgi-3.4/mod_wsgi.c
@@ -139,6 +139,10 @@ typedef regmatch_t ap_regmatch_t;
#include <pwd.h>
#endif
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
#include "Python.h"
#if !defined(PY_VERSION_HEX)
@@ -10485,6 +10489,17 @@ static void wsgi_setup_access(WSGIDaemon
"mod_wsgi (pid=%d): Unable to change to uid=%ld.",
getpid(), (long)daemon->group->uid);
}
+
+#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
+ /* this applies to Linux 2.4+ */
+ if (ap_coredumpdir_configured) {
+ if (prctl(PR_SET_DUMPABLE, 1)) {
+ ap_log_error(APLOG_MARK, WSGI_LOG_ALERT(errno), wsgi_server,
+ "mod_wsgi (pid=%d): set dumpable failed - this child will not coredump"
+ " after software errors", getpid());
+ }
+ }
+#endif
}
static int wsgi_setup_socket(WSGIProcessGroup *process)

View File

@ -5,14 +5,14 @@
"Process '%s' has died, restarting.",
daemon->process.pid, daemon->group->name);
+ if (WIFEXITED(status)) {
+ ap_log_error(APLOG_MARK, WSGI_LOG_DEBUG(0),
+ ap_log_error(APLOG_MARK, WSGI_LOG_INFO(0),
+ wsgi_server, "mod_wsgi (pid=%d): "
+ "Process '%s' terminated normally, exit code %d",
+ daemon->process.pid, daemon->group->name,
+ WEXITSTATUS(status));
+ }
+ else if (WIFSIGNALED(status)) {
+ ap_log_error(APLOG_MARK, WSGI_LOG_DEBUG(0),
+ ap_log_error(APLOG_MARK, WSGI_LOG_INFO(0),
+ wsgi_server, "mod_wsgi (pid=%d): "
+ "Process '%s' terminated by signal %d",
+ daemon->process.pid, daemon->group->name,

View File

@ -6,7 +6,7 @@
Name: mod_wsgi
Version: 3.4
Release: 3%{?dist}
Release: 4%{?dist}
Summary: A WSGI interface for Python web applications in Apache
Group: System Environment/Libraries
@ -16,10 +16,10 @@ Source0: http://modwsgi.googlecode.com/files/%{name}-%{version}.tar.gz
Source1: wsgi.conf
Patch0: mod_wsgi-3.4-connsbh.patch
Patch1: mod_wsgi-3.4-procexit.patch
Patch2: mod_wsgi-3.4-coredump.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: httpd-devel
BuildRequires: python-devel
BuildRequires: httpd-devel, python-devel, autoconf
Requires: httpd-mmn = %{_httpd_mmn}
%description
@ -34,8 +34,10 @@ existing WSGI adapters for mod_python or CGI.
%setup -q
%patch0 -p1 -b .connsbh
%patch1 -p1 -b .procexit
%patch2 -p1 -b .coredump
%build
autoconf
export LDFLAGS="$RPM_LD_FLAGS -L%{_libdir}"
%configure --enable-shared --with-apxs=%{_httpd_apxs}
make %{?_smp_mflags}
@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Wed Oct 17 2012 Joe Orton <jorton@redhat.com> - 3.4-4
- enable PR_SET_DUMPABLE in daemon process to enable core dumps
* Wed Oct 17 2012 Joe Orton <jorton@redhat.com> - 3.4-3
- use a NULL c->sbh pointer with httpd 2.4 (possible fix for #867276)
- add logging for unexpected daemon process loss