From af558302645384b998333f214d0af37cb3a4ff26 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Thu, 20 Jan 2022 20:03:04 +0000 Subject: [PATCH] mod_unixd: Make CoreDumpDirectory work for FreeBSD 11+. PR 65819. FreeBSD 11+ coredumping requires tracing enabled via procctl(PROC_TRACE_CTL). Submitted by: David CARLIER Reviewed by: ylavic (by inspection) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897269 13f79535-47bb-0310-9956-ffa450edef68 --- changes-entries/CoreDumpDirectory-freebsd11.txt | 2 ++ configure.in | 2 ++ docs/log-message-tags/next-number | 2 +- modules/arch/unix/mod_unixd.c | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 changes-entries/CoreDumpDirectory-freebsd11.txt diff --git a/changes-entries/CoreDumpDirectory-freebsd11.txt b/changes-entries/CoreDumpDirectory-freebsd11.txt new file mode 100644 index 00000000000..e200f0cc027 --- /dev/null +++ b/changes-entries/CoreDumpDirectory-freebsd11.txt @@ -0,0 +1,2 @@ + *) mod_unixd: CoreDumpDirectory requires enabling tracing on FreeBSD 11+. + PR 65819. [David CARLIER ] diff --git a/configure.in b/configure.in index 9ba3ad46e66..d049ae9253e 100644 --- a/configure.in +++ b/configure.in @@ -476,6 +476,7 @@ pwd.h \ grp.h \ strings.h \ sys/prctl.h \ +sys/procctl.h \ sys/processor.h \ sys/sem.h \ sys/sdt.h \ @@ -533,6 +534,7 @@ getgrnam \ initgroups \ bindprocessor \ prctl \ +procctl \ timegm \ getpgid \ fopen64 \ diff --git a/docs/log-message-tags/next-number b/docs/log-message-tags/next-number index 427e445179f..daf369612ba 100644 --- a/docs/log-message-tags/next-number +++ b/docs/log-message-tags/next-number @@ -1 +1 @@ -10369 +10370 diff --git a/modules/arch/unix/mod_unixd.c b/modules/arch/unix/mod_unixd.c index 09343d368e2..4ce279856f9 100644 --- a/modules/arch/unix/mod_unixd.c +++ b/modules/arch/unix/mod_unixd.c @@ -50,6 +50,9 @@ #ifdef HAVE_SYS_PRCTL_H #include #endif +#ifdef HAVE_SYS_PROCCTL_H +#include +#endif #ifndef DEFAULT_USER #define DEFAULT_USER "#-1" @@ -201,6 +204,19 @@ AP_DECLARE(int) ap_unixd_setup_child(void) } } #endif +#if defined(HAVE_PROCCTL) && defined(PROC_TRACE_CTL) + /* FreeBSD 11 and above */ + if (ap_coredumpdir_configured) { + int enablecoredump = PROC_TRACE_CTL_ENABLE; + if (procctl(P_PID, 0, PROC_TRACE_CTL, &enablecoredump) != 0) { + rv = errno; + ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, APLOGNO(10369) + "set dumpable failed - this child will not coredump" + " after software errors"); + return rv; + } + } +#endif return OK; } -- 2.47.3