Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 96444 invoked from network); 8 Nov 2010 13:16:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Nov 2010 13:16:03 -0000 Received: (qmail 28615 invoked by uid 500); 8 Nov 2010 13:16:34 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 28420 invoked by uid 500); 8 Nov 2010 13:16:32 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 28413 invoked by uid 99); 8 Nov 2010 13:16:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Nov 2010 13:16:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Nov 2010 13:16:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AAFE023888EC; Mon, 8 Nov 2010 13:15:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1032565 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/core.xml server/core.c Date: Mon, 08 Nov 2010 13:15:17 -0000 To: cvs@httpd.apache.org From: trawick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101108131517.AAFE023888EC@eris.apache.org> Author: trawick Date: Mon Nov 8 13:15:17 2010 New Revision: 1032565 URL: http://svn.apache.org/viewvc?rev=1032565&view=rev Log: Add Error directive for aborting startup or htaccess processing with a specified error message. Be nice and strip off any quotes, which aren't necessary. Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/docs/manual/mod/core.xml httpd/httpd/trunk/server/core.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1032565&r1=1032564&r2=1032565&view=diff ============================================================================== --- httpd/httpd/trunk/CHANGES [utf-8] (original) +++ httpd/httpd/trunk/CHANGES [utf-8] Mon Nov 8 13:15:17 2010 @@ -6,6 +6,9 @@ Changes with Apache 2.3.9 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] Modified: httpd/httpd/trunk/docs/manual/mod/core.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=1032565&r1=1032564&r2=1032565&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/mod/core.xml (original) +++ httpd/httpd/trunk/docs/manual/mod/core.xml Mon Nov 8 13:15:17 2010 @@ -890,6 +890,43 @@ version 2.3.9. +Error +Abort configuration parsing with a custom error message +Error message +server configvirtual host +directory.htaccess + +2.3.9 and later + + +

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.

+ + Example + # ensure that mod_include is loaded
+ <IfModule !include_module>
+ Error mod_include is required by mod_foo. Load it with LoadModule.
+ </IfModule>
+
+ # ensure that exactly one of SSL,NOSSL is defined
+ <IfDefine SSL>
+ <IfDefine NOSSL>
+ Error Both SSL and NOSSL are defined. Define only one of them.
+ </IfDefine>
+ </IfDefine>
+ <IfDefine !SSL>
+ <IfDefine !NOSSL>
+ Error Either SSL or NOSSL must be defined.
+ </IfDefine>
+ </IfDefine>
+
+ +
+
+ + ErrorDocument What the server will return to the client in case of an error Modified: httpd/httpd/trunk/server/core.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1032565&r1=1032564&r2=1032565&view=diff ============================================================================== --- httpd/httpd/trunk/server/core.c (original) +++ httpd/httpd/trunk/server/core.c Mon Nov 8 13:15:17 2010 @@ -1092,6 +1092,25 @@ static const char *unset_define(cmd_parm 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) { @@ -3432,6 +3451,8 @@ AP_INIT_TAKE1("Define", set_define, NULL "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("