From: Eric Covener Date: Fri, 30 Jan 2015 17:17:12 +0000 (+0000) Subject: Block Define/Undefine from per-directory context, because they will X-Git-Tag: 2.5.0-alpha~3496 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adcd01df7ca66073870d0e0cc36e05c2cb7a5b89;p=apache Block Define/Undefine from per-directory context, because they will fire while the block is read not when it evaluates for a given request. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1656063 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 04bf2b5a76..c1f0270e95 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) core: Define and UnDefine are no longer permitted in + directory context. Previously they would always be evaulated + as the configuration was read without regard for the directory + context. [Eric Covener] + *) config: For directives that do not expect any arguments, enforce that none are specified in the configuration file. [Joachim Zobel , Eric Covener] diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml index 324d1c5f79..2f1c51970e 100644 --- a/docs/manual/mod/core.xml +++ b/docs/manual/mod/core.xml @@ -717,7 +717,7 @@ which no other media type configuration could be found. Define a variable Define parameter-name [parameter-value] server configvirtual host -directory +

In its one parameter form, Define is equivalent @@ -746,6 +746,10 @@ DocumentRoot /var/www/${servername}/htdocs

Variable names may not contain colon ":" characters, to avoid clashes with RewriteMap's syntax.

+ +

While this directive is supported in virtual host context, + the changes it makes are visible to any later configuration + directives, beyond any enclosing virtual host

@@ -4291,7 +4295,8 @@ certain events before failing a request UnDefine Undefine the existence of a variable UnDefine parameter-name -server config +server config +virtual host

Undoes the effect of a Define or @@ -4299,6 +4304,9 @@ certain events before failing a request

This directive can be used to toggle the use of IfDefine sections without needing to alter -D arguments in any startup scripts.

+

While this directive is supported in virtual host context, + the changes it makes are visible to any later configuration + directives, beyond any enclosing virtual host

diff --git a/server/core.c b/server/core.c index 2cad01bbc6..6092e1e7ce 100644 --- a/server/core.c +++ b/server/core.c @@ -1332,9 +1332,10 @@ static void init_config_defines(apr_pool_t *pconf) static const char *set_define(cmd_parms *cmd, void *dummy, const char *name, const char *value) { - const char *err = ap_check_cmd_context(cmd, NOT_IN_HTACCESS); - if (err) - return err; + if (cmd->parent && strcasecmp(cmd->parent->directive, "pool, "Define is not valid in ", cmd->parent->directive, " context", NULL); + } + if (ap_strchr_c(name, ':') != NULL) return "Variable name must not contain ':'"; @@ -1358,9 +1359,10 @@ static const char *unset_define(cmd_parms *cmd, void *dummy, { int i; char **defines; - const char *err = ap_check_cmd_context(cmd, NOT_IN_HTACCESS); - if (err) - return err; + if (cmd->parent && strcasecmp(cmd->parent->directive, "pool, "Define is not valid in ", cmd->parent->directive, " context", NULL); + } + if (ap_strchr_c(name, ':') != NULL) return "Variable name must not contain ':'"; @@ -4181,9 +4183,9 @@ AP_INIT_TAKE1("AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO, "The name of the default charset to add to any Content-Type without one or 'Off' to disable"), AP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO, "Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"), -AP_INIT_TAKE12("Define", set_define, NULL, EXEC_ON_READ|ACCESS_CONF|RSRC_CONF, +AP_INIT_TAKE12("Define", set_define, NULL, EXEC_ON_READ|RSRC_CONF, "Define a variable, optionally to a value. Same as passing -D to the command line."), -AP_INIT_TAKE1("UnDefine", unset_define, NULL, EXEC_ON_READ|ACCESS_CONF|RSRC_CONF, +AP_INIT_TAKE1("UnDefine", unset_define, NULL, EXEC_ON_READ|RSRC_CONF, "Undefine the existence of a variable. Undo a Define."), AP_INIT_RAW_ARGS("Error", generate_message, (void*) APLOG_ERR, OR_ALL, "Generate error message from within configuration."),