Fix a denial of service attack against mod_reqtimeout.
[Stefan Fritsch]
+ *) core: Add Error directive for aborting startup or htaccess processing
+ with a specified error message. [Jeff Trawick]
+
*) mod_rewrite: Fix the RewriteEngine directive to work within a
location. Previously, once RewriteEngine was switched on globally,
it was impossible to switch off. [Graham Leggett]
</usage>
</directivesynopsis>
+<directivesynopsis>
+<name>Error</name>
+<description>Abort configuration parsing with a custom error message</description>
+<syntax>Error <var>message</var></syntax>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context><context>.htaccess</context>
+</contextlist>
+<compatibility>2.3.9 and later</compatibility>
+
+<usage>
+ <p>If an error can be detected within the configuration, this
+ directive can be used to generate a custom error message, and halt
+ configuration parsing. The typical use is for reporting required
+ modules which are missing from the configuration.</p>
+
+ <example><title>Example</title>
+ # ensure that mod_include is loaded<br />
+ <IfModule !include_module><br />
+ Error mod_include is required by mod_foo. Load it with LoadModule.<br />
+ </IfModule><br />
+ <br />
+ # ensure that exactly one of SSL,NOSSL is defined<br />
+ <IfDefine SSL><br />
+ <IfDefine NOSSL><br />
+ Error Both SSL and NOSSL are defined. Define only one of them.<br />
+ </IfDefine><br />
+ </IfDefine><br />
+ <IfDefine !SSL><br />
+ <IfDefine !NOSSL><br />
+ Error Either SSL or NOSSL must be defined.<br />
+ </IfDefine><br />
+ </IfDefine><br />
+ </example>
+
+</usage>
+</directivesynopsis>
+
<directivesynopsis>
<name>ErrorDocument</name>
<description>What the server will return to the client
return NULL;
}
+static const char *generate_error(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ if (!arg || !*arg) {
+ return "The Error directive was used with no message.";
+ }
+
+ if (*arg == '"' || *arg == '\'') { /* strip off quotes */
+ apr_size_t len = strlen(arg);
+ char last = *(arg + len - 1);
+
+ if (*arg == last) {
+ return apr_pstrndup(cmd->pool, arg + 1, len - 2);
+ }
+ }
+
+ return arg;
+}
+
#ifdef GPROF
static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
{
"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", generate_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"),