Re: svn commit: r1406495 - in /httpd/httpd/trunk: CHANGES include/http_config.h server/core.c

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: svn commit: r1406495 - in /httpd/httpd/trunk: CHANGES include/http_config.h server/core.c

Eric Covener
Does anyone recall what kind of directives were misbehaving?  It seems
like many things that work in Location/LocationMatch but not
Directory/Files would tend to work with <If>

The single-arg form of Alias for example gets caught up in this check

    if (!file_req) {
       if ((access_status = ap_location_walk(r))) {
           return access_status;
       }
       if ((access_status = ap_if_walk(r))) {
           return access_status;
       }

       d = ap_get_core_module_config(r->per_dir_config);
       if (d->log) {
           r->log = d->log;
       }

       if ((access_status = ap_run_translate_name(r))) {
           return decl_die(access_status, "translate", r);
       }
   }

   /* Reset to the server default config prior to running map_to_storage
    */
   r->per_dir_config = r->server->lookup_defaults;

   if ((access_status = ap_run_map_to_storage(r))) {
       /* This request wasn't in storage (e.g. TRACE) */
       return access_status;
   }

On Wed, Nov 7, 2012 at 3:33 AM,  <[hidden email]> wrote:

> Author: sf
> Date: Wed Nov  7 08:33:05 2012
> New Revision: 1406495
>
> URL: http://svn.apache.org/viewvc?rev=1406495&view=rev
> Log:
> Make ap_check_cmd_context() treat <If> sections like <File> sections.
> This is necessary to properly disallow directives that don't work in
> <If>.
>
> A separate NOT_IN_IF flag may be nicer, but would create much more
> hassle when being backported to 2.4.
>
> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/include/http_config.h
>     httpd/httpd/trunk/server/core.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1406495&r1=1406494&r2=1406495&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Nov  7 08:33:05 2012
> @@ -1,6 +1,9 @@
>                                                           -*- coding: utf-8 -*-
>  Changes with Apache 2.5.0
>
> +  *) Be more correct about rejecting directives that cannot work in <If>
> +     sections. [Stefan Fritsch]
> +
>    *) core: Fix directives like LogLevel that need to know if they are invoked
>       at virtual host context or in Directory/Files/Location/If sections to
>       work properly in If sections that are not in a Directory/Files/Location.
>
> Modified: httpd/httpd/trunk/include/http_config.h
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=1406495&r1=1406494&r2=1406495&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/include/http_config.h (original)
> +++ httpd/httpd/trunk/include/http_config.h Wed Nov  7 08:33:05 2012
> @@ -901,11 +901,11 @@ AP_DECLARE(const char *) ap_check_cmd_co
>  #define  NOT_IN_LIMIT           0x02 /**< Forbidden in &lt;Limit&gt; */
>  #define  NOT_IN_DIRECTORY       0x04 /**< Forbidden in &lt;Directory&gt; */
>  #define  NOT_IN_LOCATION        0x08 /**< Forbidden in &lt;Location&gt; */
> -#define  NOT_IN_FILES           0x10 /**< Forbidden in &lt;Files&gt; */
> +#define  NOT_IN_FILES           0x10 /**< Forbidden in &lt;Files&gt; or &lt;If&gt;*/
>  #define  NOT_IN_HTACCESS        0x20 /**< Forbidden in .htaccess files */
> -/** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;*/
> +/** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;&lt;If&gt;*/
>  #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
> -/** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt; */
> +/** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;/&lt;If&gt; */
>  #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
>
>  /** @} */
>
> Modified: httpd/httpd/trunk/server/core.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1406495&r1=1406494&r2=1406495&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/core.c (original)
> +++ httpd/httpd/trunk/server/core.c Wed Nov  7 08:33:05 2012
> @@ -1144,7 +1144,10 @@ AP_DECLARE(const char *) ap_check_cmd_co
>                  || (found = find_parent(cmd->directive, "<LocationMatch"))))
>          || ((forbidden & NOT_IN_FILES)
>              && ((found = find_parent(cmd->directive, "<Files"))
> -                || (found = find_parent(cmd->directive, "<FilesMatch"))))) {
> +                || (found = find_parent(cmd->directive, "<FilesMatch"))
> +                || (found = find_parent(cmd->directive, "<If"))
> +                || (found = find_parent(cmd->directive, "<ElseIf"))
> +                || (found = find_parent(cmd->directive, "<Else"))))) {
>          return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
>                             " cannot occur within ", found->directive,
>                             "> section", NULL);
>
>



--
Eric Covener
[hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: svn commit: r1406495 - in /httpd/httpd/trunk: CHANGES include/http_config.h server/core.c

Stefan Fritsch
On Tuesday, 11 July 2017 15:20:44 CEST Eric Covener wrote:
> Does anyone recall what kind of directives were misbehaving?

Sorry, I don't remember. But maybe all directives that expect useful
information in cmd_parms->path ? This is always "*If" in If-Sections.

Cheers,
Stefan

> It seems
> like many things that work in Location/LocationMatch but not
> Directory/Files would tend to work with <If>
>
> The single-arg form of Alias for example gets caught up in this check
>
>     if (!file_req) {
>        if ((access_status = ap_location_walk(r))) {
>            return access_status;
>        }
>        if ((access_status = ap_if_walk(r))) {
>            return access_status;
>        }
>
>        d = ap_get_core_module_config(r->per_dir_config);
>        if (d->log) {
>            r->log = d->log;
>        }
>
>        if ((access_status = ap_run_translate_name(r))) {
>            return decl_die(access_status, "translate", r);
>        }
>    }
>
>    /* Reset to the server default config prior to running map_to_storage
>     */
>    r->per_dir_config = r->server->lookup_defaults;
>
>    if ((access_status = ap_run_map_to_storage(r))) {
>        /* This request wasn't in storage (e.g. TRACE) */
>        return access_status;
>    }

Loading...