Mailing List Archive

Re: svn commit: r1909135 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h server/core.c
On Fri, Apr 14, 2023 at 4:02?PM <minfrin@apache.org> wrote:
>
> Author: minfrin
> Date: Fri Apr 14 14:02:11 2023
> New Revision: 1909135
>
> URL: http://svn.apache.org/viewvc?rev=1909135&view=rev
> Log:
> core: Be explicit if an enclosing directive contains a path or a
> regex.

Currently all the tests (framework) are broken due to cmd->regex not
being properly stacked/scoped.
If cmd->regex is to be used to store the enclosing section's regex, it
should be saved and restored by *all* the the sections (much like
cmd->override is saved/restored using the old_overrides stack variable
in most sections). It should also be set to NULL when parsing
(sub-)sections with no possible regex, unless we want to inherit
cmd->regex there.

But for instance some like:
<Location ...>
<If ...>
# use /fake from <Location>
Alias /real
</If>
</Location>
won't work for Alias because <If> overwrites cmd->path with "*If".

Also, what about:
<DirectoryMatch ...>
<FilesMatch ...>
# which regex here?
</FilesMatch>
</DirectoryMatch>
Or:
<DirectoryMatch ...>
<Files ...>
# <DirectoryMatch>'s regex usable here?
</Files>
</DirectoryMatch>
?

Or third-party sections (unaware of cmd->regex) which contain
directives that depend on cmd->regex?

I'm not saying it's a bad idea but it needs more changes than this
commit, changes that spread all over the code base it seems (modules
can have their sections too), something like:
$ grep -r 'AP_INIT\w\+("<' server/ modules/ 2>/dev/null
server/core.c:AP_INIT_RAW_ARGS("<Directory", dirsection, NULL, RSRC_CONF,
server/core.c:AP_INIT_RAW_ARGS("<Location", urlsection, NULL, RSRC_CONF,
server/core.c:AP_INIT_RAW_ARGS("<VirtualHost", virtualhost_section,
NULL, RSRC_CONF,
server/core.c:AP_INIT_RAW_ARGS("<Files", filesection, NULL, OR_ALL,
server/core.c:AP_INIT_RAW_ARGS("<Limit", ap_limit_section, NULL,
OR_LIMIT | OR_AUTHCFG,
server/core.c:AP_INIT_RAW_ARGS("<LimitExcept", ap_limit_section, (void*)1,
server/core.c:AP_INIT_RAW_ARGS("<IfModule", start_cond_section, (void
*)test_ifmod_section,
server/core.c:AP_INIT_RAW_ARGS("<IfDefine", start_cond_section, (void
*)test_ifdefine_section,
server/core.c:AP_INIT_RAW_ARGS("<IfFile", start_cond_section, (void
*)test_iffile_section,
server/core.c:AP_INIT_RAW_ARGS("<IfDirective", start_cond_section,
(void *)test_ifdirective_section,
server/core.c:AP_INIT_RAW_ARGS("<IfSection", start_cond_section, (void
*)test_ifsection_section,
server/core.c:AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection,
(void*)1, RSRC_CONF,
server/core.c:AP_INIT_RAW_ARGS("<LocationMatch", urlsection, (void*)1,
RSRC_CONF,
server/core.c:AP_INIT_RAW_ARGS("<FilesMatch", filesection, (void*)1, OR_ALL,
server/core.c:AP_INIT_RAW_ARGS("<If", ifsection, COND_IF, OR_ALL,
server/core.c:AP_INIT_RAW_ARGS("<ElseIf", ifsection, COND_ELSEIF, OR_ALL,
server/core.c:AP_INIT_RAW_ARGS("<Else", ifsection, COND_ELSE, OR_ALL,
modules/metadata/mod_version.c: AP_INIT_TAKE123("<IfVersion",
start_ifversion, NULL, EXEC_ON_READ | OR_ALL,
modules/aaa/mod_authn_core.c:
AP_INIT_RAW_ARGS("<AuthnProviderAlias", authaliassection, NULL,
RSRC_CONF,
modules/aaa/mod_authz_core.c:
AP_INIT_RAW_ARGS("<AuthzProviderAlias", authz_require_alias_section,
modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireAll",
add_authz_section, NULL, OR_AUTHCFG,
modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireAny",
add_authz_section, NULL, OR_AUTHCFG,
modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireNotAll",
add_authz_section, NULL, OR_AUTHCFG,
modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireNone",
add_authz_section, NULL, OR_AUTHCFG,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookPreTranslateName",
register_pre_trans_name_block, NULL,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookTranslateName",
register_translate_name_block,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookFixups",
register_fixups_block, NULL,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookMapToStorage",
register_map_to_storage_block,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookCheckUserID",
register_check_user_id_block,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookTypeChecker",
register_type_checker_block, NULL,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookAccessChecker",
register_access_checker_block,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookAuthChecker",
register_auth_checker_block, NULL,
modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaQuickHandler",
register_quick_block, NULL,
modules/proxy/mod_proxy.c: AP_INIT_RAW_ARGS("<Proxy", proxysection,
NULL, RSRC_CONF,
modules/proxy/mod_proxy.c: AP_INIT_RAW_ARGS("<ProxyMatch",
proxysection, (void*)1, RSRC_CONF,
(possibly not all of them need care though)

Maybe we only want to check that the parent directive is a <Location>
with Alias for now?


Regards;
Yann.
Re: svn commit: r1909135 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h server/core.c [ In reply to ]
On Wed, Apr 19, 2023 at 08:08:49PM +0200, Yann Ylavic wrote:
> On Fri, Apr 14, 2023 at 4:02?PM <minfrin@apache.org> wrote:
> >
> > Author: minfrin
> > Date: Fri Apr 14 14:02:11 2023
> > New Revision: 1909135
> >
> > URL: http://svn.apache.org/viewvc?rev=1909135&view=rev
> > Log:
> > core: Be explicit if an enclosing directive contains a path or a
> > regex.
>
> Currently all the tests (framework) are broken due to cmd->regex not
> being properly stacked/scoped.

Trunk has been broken for a week, Graham could you move this work to a
branch or PR until the regressions are fixed?

Regards, Joe
Re: svn commit: r1909135 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h server/core.c [ In reply to ]
On 19 Apr 2023, at 19:08, Yann Ylavic <ylavic.dev@gmail.com> wrote:

> Currently all the tests (framework) are broken due to cmd->regex not
> being properly stacked/scoped.
> If cmd->regex is to be used to store the enclosing section's regex, it
> should be saved and restored by *all* the the sections (much like
> cmd->override is saved/restored using the old_overrides stack variable
> in most sections). It should also be set to NULL when parsing
> (sub-)sections with no possible regex, unless we want to inherit
> cmd->regex there.

This is done in r1909356.

>
> But for instance some like:
> <Location ...>
> <If ...>
> # use /fake from <Location>
> Alias /real
> </If>
> </Location>
> won't work for Alias because <If> overwrites cmd->path with "*If".

I just found that - that’s definitely broken, it means you can’t do this:

<Location /svn/extra>
<If [something]>
DAV svn
SVNPath /home/trac/svn/extra
</If>
</Location>

Looks like the same effect as the Alias bug, where every url is mapped to “*If”.

> Also, what about:
> <DirectoryMatch ...>
> <FilesMatch ...>
> # which regex here?
> </FilesMatch>
> </DirectoryMatch>

In the above “which regex here” would be FilesMatch, which wouldn’t change.

> Or:
> <DirectoryMatch ...>
> <Files ...>
> # <DirectoryMatch>'s regex usable here?
> </Files>
> </DirectoryMatch>
> ?

Combining regexes is probably a step too far. Right now DirectoryMatch’s regex isn’t usable at the point as the DirectoryMatch regex is not passed across Files. This behaviour doesn't change.

> Or third-party sections (unaware of cmd->regex) which contain
> directives that depend on cmd->regex?

Again there would be no change to behaviour that I can see, the regex was hidden before and the raw path (containing the regex) would be used, now cmd->regex would be set to NULL and the raw path (containing the regex) would be used.

> I'm not saying it's a bad idea but it needs more changes than this
> commit, changes that spread all over the code base it seems (modules
> can have their sections too), something like:
> $ grep -r 'AP_INIT\w\+("<' server/ modules/ 2>/dev/null
> server/core.c:AP_INIT_RAW_ARGS("<Directory", dirsection, NULL, RSRC_CONF,
> server/core.c:AP_INIT_RAW_ARGS("<Location", urlsection, NULL, RSRC_CONF,
> server/core.c:AP_INIT_RAW_ARGS("<VirtualHost", virtualhost_section,
> NULL, RSRC_CONF,
[snip]

cmd->regex is a function of cmd->path, so only places that touch cmd->path need touch cmd->regex, and this seems to be directory, location and file.

<If> seems broken right now, need to fix that separately.

> Maybe we only want to check that the parent directive is a <Location>
> with Alias for now?

Right now it’s limited to not-in-directory:

https://github.com/apache/httpd/blob/trunk/modules/mappers/mod_alias.c#L146

If this is too difficult to backport it isn't the end of the world, the main thing is that it's fixed for the future.

Regards,
Graham