From 8ab979d28fb3fa23ea4aeeb1841e52ba77c1f0d3 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Thu, 19 Feb 2004 11:19:43 +0000 Subject: [PATCH] Add a new directive EnableExceptionHook that must be specified for exception hooks to be called (in addition to the build time requirements). The 2.1-dev feature is now more aligned with the 1.3.30-dev feature, in that there is a build-time requirement as well as a configuration requirement. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102686 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 7 ++++--- include/mpm_common.h | 5 +++++ server/core.c | 4 ++++ server/mpm_common.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 08ac9f1eaf..efec25930d 100644 --- a/CHANGES +++ b/CHANGES @@ -97,9 +97,10 @@ Changes with Apache 2.1.0-dev directory, display the MPM name and some MPM properties. [Geoffrey Young ] - *) Add fatal exception hook for use by debug modules. The hook is only - available if the --enable-exception-hook configure parm is used. - [Jeff Trawick] + *) Add fatal exception hook for use by diagnostic modules. The hook + is only available if the --enable-exception-hook configure parm + is used and the EnableExceptionHook directive has been set to + "on". [Jeff Trawick] *) mod_ssl/mod_status: Re-enable support for output of SSL session cache information in server-status page. [Joe Orton] diff --git a/include/mpm_common.h b/include/mpm_common.h index 4636df5db1..13d7afd9bb 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -254,6 +254,11 @@ extern apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *pconf); extern apr_status_t ap_fatal_signal_child_setup(server_rec *s); #endif +#if AP_ENABLE_EXCEPTION_HOOK +extern const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + #ifdef __cplusplus } #endif diff --git a/server/core.c b/server/core.c index 826e5fe2db..2bd91f1355 100644 --- a/server/core.c +++ b/server/core.c @@ -3231,6 +3231,10 @@ AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF, AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF, "Maximum number of 1k blocks a particular childs allocator may hold."), #endif +#if AP_ENABLE_EXCEPTION_HOOK +AP_INIT_TAKE1("EnableExceptionHook", ap_mpm_set_exception_hook, NULL, RSRC_CONF, + "Controls whether exception hook may be called after a crash"), +#endif { NULL } }; diff --git a/server/mpm_common.c b/server/mpm_common.c index 5ccbaff4e5..d814984b5a 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -879,6 +879,34 @@ static pid_t parent_pid, my_pid; apr_pool_t *pconf; #if AP_ENABLE_EXCEPTION_HOOK + +static int exception_hook_enabled; + +const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy, + const char *arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + + if (cmd->server->is_virtual) { + return "EnableExceptionHook directive not allowed in "; + } + + if (strcasecmp(arg, "on") == 0) { + exception_hook_enabled = 1; + } + else if (strcasecmp(arg, "off") == 0) { + exception_hook_enabled = 0; + } + else { + return "parameter must be 'on' or 'off'"; + } + + return NULL; +} + APR_HOOK_STRUCT( APR_HOOK_LINK(fatal_exception) ) @@ -890,7 +918,8 @@ static void run_fatal_exception_hook(int sig) { ap_exception_info_t ei = {0}; - if (geteuid() != 0 && + if (exception_hook_enabled && + geteuid() != 0 && my_pid != parent_pid) { ei.sig = sig; ei.pid = my_pid; -- 2.50.1