You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2016/06/15 15:19:17 UTC

[Bug 59709] New: can't see reqenv variables from other modules.

https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

            Bug ID: 59709
           Summary: <If> can't see reqenv variables from other modules.
           Product: Apache httpd-2
           Version: 2.4.20
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: bugs@httpd.apache.org
          Reporter: ache@vniz.net

<If> is executed too early in the chain, so is little useful for reqenv
variables since can't see them from other modules, f.e. from mod_geoip2 which
sets them later. From other side, <SetEnvIfExpr> can see mod_geoip2 reqenv
variables well.

Please move <If> processing further in the chain at least to the stage where
<SetEnvIfExpr> is executed. Yes, I know workaround using <SetEnvIfExpr> and
mod_rewrite, but it looks too ugly for complex cases.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #2 from Andrey Chernov <ac...@vniz.net> ---
(In reply to Eric Covener from comment #1)
> I don't think what you suggest is wise, as it would delay the correct
> per-directory configuration being available to anything enclosed in <If>.
> 
> mod_geoip2 seems to run quite early when the config is server-wide, just
> like mod_setenvif. Have you tried mod_geoip2 w/o delaying the execution by
> putting it in per-directory config?

I have many virtual hosts and many directories, so run mod_geoip2 server-wide
once for all of them. I don't think that opening mod_geoip2 database in
per-(many)directory scope each time will speed things up.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|<If> can't see reqenv       |<If> can't see reqenv
                   |variables from other        |variables from some
                   |modules.                    |modules.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #3 from Eric Covener <co...@gmail.com> ---
(In reply to Andrey Chernov from comment #2)
> (In reply to Eric Covener from comment #1)
> > I don't think what you suggest is wise, as it would delay the correct
> > per-directory configuration being available to anything enclosed in <If>.
> > 
> > mod_geoip2 seems to run quite early when the config is server-wide, just
> > like mod_setenvif. Have you tried mod_geoip2 w/o delaying the execution by
> > putting it in per-directory config?
> 
> I have many virtual hosts and many directories, so run mod_geoip2
> server-wide once for all of them. I don't think that opening mod_geoip2
> database in per-(many)directory scope each time will speed things up.

I meant the opposite, but you already have the config that should set variables
early.  It's surprising that the variables are not available if you use it in
server scope already, but I didn't look at geoip2 in detail.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #5 from Andrey Chernov <ac...@vniz.net> ---
(In reply to Eric Covener from comment #4)
> from geoip2:
> 
>     /* we have two entry points, the header_parser hook, right before
>      * the authentication hook used for Dirctory specific enabled
> geoiplookups
>      * or right before directory rewrite rules.
>      */
>     ap_hook_header_parser(geoip_per_dir, NULL, aszSucc, APR_HOOK_FIRST);
> 
>     /* and the servectly wide hook, after reading the request. Perfecly
>      * suitable to serve serverwide mod_rewrite actions
>      */
>     ap_hook_post_read_request(geoip_post_read_request, NULL, aszSucc,
>                               APR_HOOK_MIDDLE);
> 
> ap_if_walk() should be between these two.

In geoip_per_dir(), after not founding per-directory config, it exits from the
hook:

dcfg = ap_get_module_config(r->per_dir_config, &geoip_module);
if (!dcfg) {
        return DECLINED;
}

What wrong happens, in case you'll move ap_if_walk() down to APR_HOOK_MIDDLE?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #7 from Andrey Chernov <ac...@vniz.net> ---
(In reply to Eric Covener from comment #6)
> (In reply to Andrey Chernov from comment #5)
> > (In reply to Eric Covener from comment #4)
> > > from geoip2:
> > > 
> > >     /* we have two entry points, the header_parser hook, right before
> > >      * the authentication hook used for Dirctory specific enabled
> > > geoiplookups
> > >      * or right before directory rewrite rules.
> > >      */
> > >     ap_hook_header_parser(geoip_per_dir, NULL, aszSucc, APR_HOOK_FIRST);
> > > 
> > >     /* and the servectly wide hook, after reading the request. Perfecly
> > >      * suitable to serve serverwide mod_rewrite actions
> > >      */
> > >     ap_hook_post_read_request(geoip_post_read_request, NULL, aszSucc,
> > >                               APR_HOOK_MIDDLE);
> > > 
> > > ap_if_walk() should be between these two.
> > 
> > In geoip_per_dir(), after not founding per-directory config, it exits from
> > the hook:
> > 
> > dcfg = ap_get_module_config(r->per_dir_config, &geoip_module);
> > if (!dcfg) {
> >         return DECLINED;
> > }
> > 
> 
> Can you elaborate on the relevance? It seems like this should no-op in your
> global/server config setup.

Sorry, wrong code pasted from geoip_per_dir(), really I mean that one:

 geoip_server_config_rec *cfg =
        ap_get_module_config(r->server->module_config, &geoip_module);
 if (cfg && cfg->GeoIPEnabled) {
        return DECLINED;
 }

I.e. if _server_ config exists and GeoIPEnabled (as in my case),
geoip_per_dir() exits from the hook with nothing processed.

> > What wrong happens, in case you'll move ap_if_walk() down to APR_HOOK_MIDDLE?
> 
> I don't understand the question -- ap_if_walk() is not run as part of any
> hook, it's run between hooks by the core of the server.  If it were delayed,
> modules that "newly" run before it wouldn't see their configuration enclosed
> in <if>.

It sound like who was first, chicken or egg:) Should modules affect <If> to
allow their results processed by it, or should <If> affect modules to be
configured per-directory? We lost something in any case. Just guessing, perhaps
running ap_if_walk() twice, early and later can solve it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #4 from Eric Covener <co...@gmail.com> ---
from geoip2:

    /* we have two entry points, the header_parser hook, right before
     * the authentication hook used for Dirctory specific enabled geoiplookups
     * or right before directory rewrite rules.
     */
    ap_hook_header_parser(geoip_per_dir, NULL, aszSucc, APR_HOOK_FIRST);

    /* and the servectly wide hook, after reading the request. Perfecly
     * suitable to serve serverwide mod_rewrite actions
     */
    ap_hook_post_read_request(geoip_post_read_request, NULL, aszSucc,
                              APR_HOOK_MIDDLE);

ap_if_walk() should be between these two.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from some modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

--- Comment #6 from Eric Covener <co...@gmail.com> ---
(In reply to Andrey Chernov from comment #5)
> (In reply to Eric Covener from comment #4)
> > from geoip2:
> > 
> >     /* we have two entry points, the header_parser hook, right before
> >      * the authentication hook used for Dirctory specific enabled
> > geoiplookups
> >      * or right before directory rewrite rules.
> >      */
> >     ap_hook_header_parser(geoip_per_dir, NULL, aszSucc, APR_HOOK_FIRST);
> > 
> >     /* and the servectly wide hook, after reading the request. Perfecly
> >      * suitable to serve serverwide mod_rewrite actions
> >      */
> >     ap_hook_post_read_request(geoip_post_read_request, NULL, aszSucc,
> >                               APR_HOOK_MIDDLE);
> > 
> > ap_if_walk() should be between these two.
> 
> In geoip_per_dir(), after not founding per-directory config, it exits from
> the hook:
> 
> dcfg = ap_get_module_config(r->per_dir_config, &geoip_module);
> if (!dcfg) {
>         return DECLINED;
> }
> 

Can you elaborate on the relevance? It seems like this should no-op in your
global/server config setup.

> What wrong happens, in case you'll move ap_if_walk() down to APR_HOOK_MIDDLE?

I don't understand the question -- ap_if_walk() is not run as part of any hook,
it's run between hooks by the core of the server.  If it were delayed, modules
that "newly" run before it wouldn't see their configuration enclosed in <if>.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59709] can't see reqenv variables from other modules.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59709

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #1 from Eric Covener <co...@gmail.com> ---
I don't think what you suggest is wise, as it would delay the correct
per-directory configuration being available to anything enclosed in <If>.

mod_geoip2 seems to run quite early when the config is server-wide, just like
mod_setenvif. Have you tried mod_geoip2 w/o delaying the execution by putting
it in per-directory config?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org