httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: [RFC] Error directive to generate custom error messages from httpd.conf
Date Mon, 08 Nov 2010 01:35:06 GMT
On Sun, Nov 7, 2010 at 8:29 PM, Sander Temme <sctemme@apache.org> wrote:
>
> On Nov 7, 2010, at 4:35 PM, Jeff Trawick wrote:
>
>> This is handy when a module depends on another module at load time or
>> run time, and the config for that module needs to display a message
>> more helpful than the normal symbol-not-found or
>> optional-function-not-found or invalid-filter message.
>
> +1.  We also discussed last week the possibility that a module provides functionality
not captured in the config file, and server startup should fail if that module is not loaded.

The example I remember discussing was some module (or even just some
configuration snippet) that requires the INCLUDES filter to work.  I
don't think it is feasible for the core to make any checks, even if it
sees "AddOutputFilter INCLUDES .shtml" without mod_include available.
But somebody writing a config snippet to be installed along with some
application/module/static files could add a config time check using
IfModule and use the Error directive.

Were you thinking of something else?

>
>> With the Error directive:
>>
>> <IfModule !mod_include.c>
>> Error mod_foo requires mod_include!  Use the LoadModule directive to
>> load mod_include.
>> </IfModule>
>>
>>
>> $ ./httpd -t
>> Syntax error on line 486 of /home/trawick/inst/23/conf/httpd.conf:
>> mod_foo requires mod_include!  Use the LoadModule directive to load mod_include.
>>
>> Index: server/core.c
>> ===================================================================
>> --- server/core.c     (revision 1032266)
>> +++ server/core.c     (working copy)
>> @@ -1092,6 +1092,11 @@
>>     return NULL;
>> }
>>
>> +static const char *set_error(cmd_parms *cmd, void *dummy, const char *arg)
>> +{
>> +    return arg;
>> +}
>> +
>> #ifdef GPROF
>> static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
>> {
>> @@ -3432,6 +3437,8 @@
>>               "Define the existence of a variable.  Same as passing
>> -D to the command line."),
>> AP_INIT_TAKE1("UnDefine", unset_define, NULL, RSRC_CONF,
>>               "Undefine the existence of a variable. Undo a Define."),
>> +AP_INIT_RAW_ARGS("Error", set_error, NULL, OR_ALL,
>> +                 "Generate error message from within configuration"),
>> AP_INIT_RAW_ARGS("<If", ifsection, NULL, OR_ALL,
>>   "Container for directives to be conditionally applied"),
>
> +1
>
> Pardon my rust, but what actually makes the process error out?  Returning !nil?

yep

Mime
View raw message