On Friday 24 February 2006 21:06, Philippe M. Chiasson wrote: > Yeah, I noticed, as it doesn't apply cleanly against svn HEAD. Could you > checkout http://svn.apache.org/repos/asf/perl/modperl/trunk/ and generate > your patch against it instead ? It'll make it much easier to > apply/test/review, thanks!
Here you are. All tests successful for Apache 2.2. For 2.0 make test hangs in protocol/pseudo_http 1/13. I have killed the test. All other tests were ok. Torsten
diff -Naur mod_perl/docs/api/Apache2/Access.pod mod_perl.new/docs/api/Apache2/Access.pod --- mod_perl/docs/api/Apache2/Access.pod 2006-02-24 21:26:14.761227618 +0100 +++ mod_perl.new/docs/api/Apache2/Access.pod 2006-02-24 21:29:11.088809666 +0100 @@ -20,6 +20,9 @@ # Apache AllowOverride value $allow_override = $r->allow_overrides(); + # which Options are allowed by AllowOverride (since Apache 2.2) + $allow_override_opts = $r->allow_override_opts(); + # auth name ("foo bar") $auth_name = $r->auth_name(); @@ -199,6 +202,54 @@ +=head2 C<allow_override_opts> + +Retrieve the bitmask of allowed C<Options> set by C<AllowOverride Options=...> +for this request + + $override_opts = $r->allow_override_opts(); + +Enabling single options was introduced in Apache 2.2. For Apache 2.0 this +function returns +C<L<Apache2::Const::OPT_UNSET|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_UNSET_>> | +C<L<Apache2::Const::OPT_ALL|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_ALL_>> | +C<L<Apache2::Const::OPT_INCNOEXEC|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_INCNOEXEC_>> | +C<L<Apache2::Const::OPT_SYM_OWNER|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_SYM_OWNER_>> | +C<L<Apache2::Const::OPT_MULTI|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_MULTI_>>, +which corresponds to the default value (if not set) for Apache 2.2. + +=over 4 + +=item obj: C<$r> +( C<L<Apache2::RequestRec object|docs::2.0::api::Apache2::RequestRec>> ) + +The current request + +=item ret: C<$override_opts> ( integer ) + +the override options bitmask. Normally used with bitlogic operators +against C<L<Apache2::Const :options +constants|docs::2.0::api::Apache2::Const/C__options_>>. + +=item since: 2.0.3 + +=back + +For example if the configuration for the current request was: + + AllowOverride Options=Indexes,ExecCGI + +The following applies: + + use Apache2::Const -compile => qw(:options); + $r->allow_override_opts & Apache2::Const::OPT_EXECCGI; # TRUE + $r->allow_override_opts & Apache2::Const::OPT_SYM_LINKS; # FALSE + + + + + + =head2 C<auth_name> Get/set the current Authorization realm (the per directory diff -Naur mod_perl/docs/api/Apache2/CmdParms.pod mod_perl.new/docs/api/Apache2/CmdParms.pod --- mod_perl/docs/api/Apache2/CmdParms.pod 2006-02-24 21:26:15.475132804 +0100 +++ mod_perl.new/docs/api/Apache2/CmdParms.pod 2006-02-24 21:29:11.090809400 +0100 @@ -48,6 +48,9 @@ # which allow-override bits are set $override = $parms->override; + # which Options are allowed by AllowOverride (since Apache 2.2) + $override = $parms->override_opts; + # the path this command is being invoked in $path = $parms->path; @@ -313,6 +316,37 @@ +=head2 C<override_opts> + +Which options are allowed to be overridden by C<.htaccess> files. This is +set by C<AllowOverride Options=...>. + + $override_opts = $parms->override_opts; + +Enabling single options was introduced with Apache 2.2. For Apache 2.0 this +function simply returns a bitmask with all options allowed. + +=over 4 + +=item obj: C<$parms> +( C<L<Apache2::CmdParms object|docs::2.0::api::Apache2::CmdParms>> ) + +=item ret: C<$override_opts> ( bitmask ) + +the bitmask, which can be tested against +C<L<Apache2::Const :options +constants|docs::2.0::api::Apache2::Const/C__override_>>. + +=item since: 2.0.3 + +=back + + + + + + + =head2 C<path> The current pathname/location/match of the block this command is in diff -Naur mod_perl/docs/api/Apache2/RequestUtil.pod mod_perl.new/docs/api/Apache2/RequestUtil.pod --- mod_perl/docs/api/Apache2/RequestUtil.pod 2006-02-24 21:26:17.532859517 +0100 +++ mod_perl.new/docs/api/Apache2/RequestUtil.pod 2006-02-24 21:53:21.415684633 +0100 @@ -109,6 +109,7 @@ $r->add_config($lines); $r->add_config($lines, $override); $r->add_config($lines, $override, $path); + $r->add_config($lines, $override, $path, $override_opts); Configuration directives are processed as if given in a C<E<lt>LocationE<gt>> block. @@ -123,8 +124,8 @@ An ARRAY reference containing configuration lines per element, without the new line terminators. -=item opt arg2: C<$override> ( C<L<APR::Const status -constant|docs::2.0::api::APR::Const>> ) +=item opt arg2: C<$override> ( C<L<Apache2::Const override +constant|docs::2.0::api::Apache2::Const>> ) Which allow-override bits are set @@ -137,11 +138,59 @@ This is the path of the C<E<lt>LocationE<gt>> block. Some directives need this, for example C<ProxyPassReverse>. +If an empty string is passed a C<NULL> pointer is passed further at C-level. +This is necessary to make something like this work: + + $r->add_config( [ + '<Directory />', + 'AllowOverride Options AuthConfig', + '</Directory>', + ], ~0, '' ); + +Note: C<AllowOverride> is valid only in directory context. + +B<Caution:> Some directives need a non-empty path otherwise they cause +segfaults. Thus, use the empty path with caution. + Default value is: C</> +=item opt arg4: C<$override_opts> ( C<L<Apache2::Const options +constant|docs::2.0::api::Apache2::Const>> ) + +Apache limits the applicable directives in certain situations with +C<AllowOverride>. With Apache 2.2 comes the possibility to enable or +disable single options, for example + + AllowOverride AuthConfig Options=ExecCGI,Indexes + +Internally, this directive is parsed into 2 bit fields that are represented +by the C<$override> and C<$override_opts> parameters to C<add_config>. +The above example is parsed into an C<$override> with 2 bits set, one for +C<AuthConfig> the other for C<Options> and an C<$override_opts> with +2 bits set for ExecCGI and Indexes. + +When applying other directives, for example C<AuthType> or C<Options> the +appropriate bits in C<$override> must be set. For the C<Options> directive +additionally C<$override_opts> bits must be set. + +The C<$override> and C<$override_opts> parameters to C<add_config> are +valid while applying C<$lines>. + +C<$override_opts> is new in Apache 2.2. The mod_perl implementation for +Apache 2.0 lets you pass the parameter but ignores it. + +Default for C<$override_opts> is: +C<L<Apache2::Const::OPT_UNSET|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_UNSET_>> | +C<L<Apache2::Const::OPT_ALL|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_ALL_>> | +C<L<Apache2::Const::OPT_INCNOEXEC|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_INCNOEXEC_>> | +C<L<Apache2::Const::OPT_SYM_OWNER|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_SYM_OWNER_>> | +C<L<Apache2::Const::OPT_MULTI|docs::2.0::api::Apache2::Const/C_Apache2__Const__OPT_MULTI_>> + +That means, all options are allowed. + =item ret: no return value -=item since: 2.0.00 +=item since: 2.0.00, C<$path> and C<$override_opts> since 2.0.3 =back @@ -150,10 +199,16 @@ For example: - use Apache2::ServerUtil (); - $r->add_config(['require valid-user']); + use Apache2::RequestUtil (); + use Apache2::Access (); + $r->add_config(['require valid-user']); + # this regards the current AllowOverride setting + $r->add_config(['AuthName secret', + 'AuthType Basic', + 'Options ExecCGI'], + $r->allow_override, $path, $r->allow_override_opts); diff -Naur mod_perl/src/modules/perl/modperl_config.c mod_perl.new/src/modules/perl/modperl_config.c --- mod_perl/src/modules/perl/modperl_config.c 2006-02-24 21:25:03.176734818 +0100 +++ mod_perl.new/src/modules/perl/modperl_config.c 2006-02-24 21:50:09.671060297 +0100 @@ -498,6 +498,7 @@ apr_pool_t *ptmp, int override, char *path, + int override_options, ap_conf_vector_t *conf, SV *lines) { @@ -513,6 +514,15 @@ parms.override = override; parms.path = path; parms.pool = p; +#if AP_SERVER_MAJORVERSION_NUMBER>2 || AP_SERVER_MINORVERSION_NUMBER>=2 + parms.override_opts = override_options==-1 + ? OPT_UNSET | + OPT_ALL | + OPT_INCNOEXEC | + OPT_SYM_OWNER | + OPT_MULTI + : override_options; +#endif if (ptmp) { parms.temp_pool = ptmp; @@ -559,6 +569,11 @@ parms->temp_pool, parms->override, parms->path, +#if AP_SERVER_MAJORVERSION_NUMBER>2 || AP_SERVER_MINORVERSION_NUMBER>=2 + parms->override_opts, +#else + -1, +#endif parms->context, lines); } @@ -569,7 +584,7 @@ int override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT); apr_pool_t *p = s->process->pconf; - return modperl_config_insert(aTHX_ s, p, NULL, override, NULL, + return modperl_config_insert(aTHX_ s, p, NULL, override, NULL, -1, s->lookup_defaults, lines); } @@ -577,20 +592,23 @@ request_rec *r, SV *lines, int override, - char *path) + char *path, + int override_options) { const char *errmsg; ap_conf_vector_t *dconf = ap_create_per_dir_config(r->pool); - /* The path argument of "/" is only required to be non-NULL - and "/" is as good a default as anything else */ if (!path) { + /* pass a non-NULL path if nothing else given and for compatibility */ path = "/"; + } else if (!*path) { + /* an empty string says a NULL pointer should be used here */ + path = NULL; } errmsg = modperl_config_insert(aTHX_ r->server, r->pool, r->pool, - override, path, + override, path, override_options, dconf, lines); if (errmsg) { diff -Naur mod_perl/src/modules/perl/modperl_config.h mod_perl.new/src/modules/perl/modperl_config.h --- mod_perl/src/modules/perl/modperl_config.h 2006-02-24 21:25:03.469695910 +0100 +++ mod_perl.new/src/modules/perl/modperl_config.h 2006-02-24 21:39:52.461715910 +0100 @@ -131,6 +131,7 @@ apr_pool_t *ptmp, int override, char *path, + int override_options, ap_conf_vector_t *conf, SV *lines); @@ -143,7 +144,8 @@ request_rec *r, SV *lines, int override, - char *path); + char *path, + int override_options); int modperl_config_is_perl_option_enabled(pTHX_ request_rec *r, server_rec *s, const char *name); diff -Naur mod_perl/t/api/add_config.t mod_perl.new/t/api/add_config.t --- mod_perl/t/api/add_config.t 1970-01-01 01:00:00.000000000 +0100 +++ mod_perl.new/t/api/add_config.t 2006-02-24 21:29:11.105807409 +0100 @@ -0,0 +1,13 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::TestRequest qw(GET_BODY_ASSERT); +use Apache::Test; +use Apache::TestUtil; + +my $module = 'TestAPI::add_config'; +my $url = Apache::TestRequest::module2url($module, + {path => '/TestAPI__add_config/'}); + +t_debug("connecting to $url"); +print GET_BODY_ASSERT $url; diff -Naur mod_perl/t/htdocs/TestAPI__add_config/htaccess mod_perl.new/t/htdocs/TestAPI__add_config/htaccess --- mod_perl/t/htdocs/TestAPI__add_config/htaccess 1970-01-01 01:00:00.000000000 +0100 +++ mod_perl.new/t/htdocs/TestAPI__add_config/htaccess 2006-02-24 21:29:11.106807276 +0100 @@ -0,0 +1 @@ +TestAddConfig Htaccess diff -Naur mod_perl/t/response/TestAPI/add_config.pm mod_perl.new/t/response/TestAPI/add_config.pm --- mod_perl/t/response/TestAPI/add_config.pm 1970-01-01 01:00:00.000000000 +0100 +++ mod_perl.new/t/response/TestAPI/add_config.pm 2006-02-24 21:29:11.107807143 +0100 @@ -0,0 +1,136 @@ +package TestAPI::add_config; + +use strict; +use warnings FATAL => 'all'; + +use Apache2::Access (); +use Apache2::CmdParms (); +use Apache2::RequestUtil (); +use Apache2::Directive (); +use Apache2::ServerUtil (); +use base qw(Apache2::Module); + +use Apache::Test; +use Apache::TestUtil; + +use Apache2::Const -compile => qw( + OK DECLINED + :options +); + +use constant KEY => "TestAddConfig"; + +my @directives = ( + { + name => +KEY, + cmd_data => 'cmd_data', + errmsg => 'errmsg', + }, +); + +Apache2::Module::add(__PACKAGE__, [EMAIL PROTECTED]); + +my @methods = qw(override_opts); + +sub TestAddConfig { + my ($self, $parms, $args) = @_; + my $srv_cfg = $self->get_config($parms->server); + $srv_cfg->{override_opts} = $parms->override_opts(); +} + + + +### map2storage handler ### +sub map2storage { + my ($r) = @_; + + (my $av=Apache2::ServerUtil::get_server_version)=~s!.+/!v!; + $av=eval $av; + + my $o=($av ge v2.2.0 ? '=All,SymLinksIfOwnerMatch' : ''); + + eval { + $r->add_config(['AllowOverride All Options'.$o]); + }; + # NOTE: pnotes simply increments a variable's reference counter. + # Hence, this strange do{} block is necessary to copy [EMAIL PROTECTED] + $r->pnotes(add_config1=>do{my $e="$@"}); + + eval { + $r->add_config(['Options ExecCGI'], -1, '/', 0); + }; + $r->pnotes(add_config2=>do{my $e="$@"}); + + eval { + $r->add_config(['<Directory /'.$r->document_root.'/TestAPI__add_config>', + 'AllowOverride All Options'.$o, + '</Directory>'], -1, ''); + }; + $r->pnotes(add_config4=>do{my $e="$@"}); + + return Apache2::Const::DECLINED; +} + + + +### fixup handler ### +sub fixup { + my ($r) = @_; + + eval { + $r->add_config(['Options ExecCGI'], -1, '/', + Apache2::Const::OPT_EXECCGI); + }; + $r->pnotes(add_config3=>do{my $e="$@"}); + + return Apache2::Const::DECLINED; +} + + + +### response handler ### +sub handler : method { + my ($self, $r) = @_; + my $cf = $self->get_config($r->server); + + plan $r, tests => 7; + + (my $av=Apache2::ServerUtil::get_server_version)=~s!.+/!v!; + $av=eval $av; + + ok t_cmp $r->pnotes('add_config1'), qr!.+\n!, 'add_config 1'; + ok t_cmp $r->pnotes('add_config2'), + ($av ge v2.2.0 ? qr!.+\n! : ''), + 'add_config 2'; + ok t_cmp $r->pnotes('add_config3'), '', 'add_config 3'; + ok t_cmp $r->pnotes('add_config4'), '', 'add_config 4'; + + my $expect=($av ge v2.2.0 ? 0 : Apache2::Const::OPT_UNSET | + Apache2::Const::OPT_INCNOEXEC | + Apache2::Const::OPT_MULTI) | + Apache2::Const::OPT_ALL | + Apache2::Const::OPT_SYM_OWNER; + + ok t_cmp $cf->{override_opts}, $expect, 'Apache2::CmdParms::override_opts'; + ok t_cmp $r->allow_override_opts, $expect, 'Apache2::Access::allow_override_opts'; + ok t_cmp $r->allow_options, Apache2::Const::OPT_EXECCGI, 'result of add_config 3'; + + return Apache2::Const::OK; +} + +1; +__END__ + +# APACHE_TEST_CONFIG_ORDER 950 + +<NoAutoConfig> + <VirtualHost TestAPI::add_config> + PerlModule TestAPI::add_config + + AccessFileName htaccess + SetHandler modperl + PerlResponseHandler TestAPI::add_config + PerlMapToStorageHandler TestAPI::add_config::map2storage + PerlFixupHandler TestAPI::add_config::fixup + </VirtualHost> +</NoAutoConfig> diff -Naur mod_perl/xs/Apache2/Access/Apache2__Access.h mod_perl.new/xs/Apache2/Access/Apache2__Access.h --- mod_perl/xs/Apache2/Access/Apache2__Access.h 2006-02-24 21:25:08.740995821 +0100 +++ mod_perl.new/xs/Apache2/Access/Apache2__Access.h 2006-02-24 21:31:33.193937047 +0100 @@ -81,7 +81,7 @@ modperl_config_insert_request(aTHX_ r, newRV_noinc((SV*)config), OR_AUTHCFG, - NULL); + NULL, -1); if (errmsg) { Perl_warn(aTHX_ "Can't change %s to '%s'\n", directive, val); @@ -141,3 +141,15 @@ } }); } + +static MP_INLINE +int mpxs_Apache2__RequestRec_allow_override_opts(pTHX_ request_rec *r) +{ +#if AP_SERVER_MAJORVERSION_NUMBER>2 || AP_SERVER_MINORVERSION_NUMBER>=2 + return + ((core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module))->override_opts; +#else + return OPT_UNSET | OPT_ALL | OPT_INCNOEXEC | OPT_SYM_OWNER | OPT_MULTI; +#endif +} diff -Naur mod_perl/xs/Apache2/CmdParms/Apache2__CmdParms.h mod_perl.new/xs/Apache2/CmdParms/Apache2__CmdParms.h --- mod_perl/xs/Apache2/CmdParms/Apache2__CmdParms.h 2006-02-24 21:25:08.883976832 +0100 +++ mod_perl.new/xs/Apache2/CmdParms/Apache2__CmdParms.h 2006-02-24 21:29:11.111806612 +0100 @@ -35,3 +35,13 @@ Perl_croak(aTHX_ "$parms->add_config() has failed: %s", errmsg); } } + +static MP_INLINE +int mpxs_Apache2__CmdParms_override_opts(pTHX_ cmd_parms *parms) +{ +#if AP_SERVER_MAJORVERSION_NUMBER>2 || AP_SERVER_MINORVERSION_NUMBER>=2 + return (modperl_module_cmd_data_t *)parms->override_opts; +#else + return OPT_UNSET | OPT_ALL | OPT_INCNOEXEC | OPT_SYM_OWNER | OPT_MULTI; +#endif +} diff -Naur mod_perl/xs/Apache2/RequestUtil/Apache2__RequestUtil.h mod_perl.new/xs/Apache2/RequestUtil/Apache2__RequestUtil.h --- mod_perl/xs/Apache2/RequestUtil/Apache2__RequestUtil.h 2006-02-24 21:25:08.364045884 +0100 +++ mod_perl.new/xs/Apache2/RequestUtil/Apache2__RequestUtil.h 2006-02-24 21:33:26.010954271 +0100 @@ -303,10 +303,12 @@ static MP_INLINE void mpxs_Apache2__RequestRec_add_config(pTHX_ request_rec *r, SV *lines, - int override, char *path) + int override, char *path, + int override_options) { const char *errmsg = modperl_config_insert_request(aTHX_ r, lines, - override, path); + override, path, + override_options); if (errmsg) { Perl_croak(aTHX_ "$r->add_config() has failed: %s", errmsg); } diff -Naur mod_perl/xs/maps/apache2_structures.map mod_perl.new/xs/maps/apache2_structures.map --- mod_perl/xs/maps/apache2_structures.map 2006-02-24 21:25:05.046486494 +0100 +++ mod_perl.new/xs/maps/apache2_structures.map 2006-02-24 21:29:11.116805948 +0100 @@ -246,6 +246,7 @@ < cmd < context ! err_directive +- override_opts </cmd_parms> !<ap_mgmt_item_t> diff -Naur mod_perl/xs/maps/modperl_functions.map mod_perl.new/xs/maps/modperl_functions.map --- mod_perl/xs/maps/modperl_functions.map 2006-02-24 21:25:05.269456881 +0100 +++ mod_perl.new/xs/maps/modperl_functions.map 2006-02-24 21:35:47.489165319 +0100 @@ -30,7 +30,7 @@ mpxs_Apache2__RequestRec_location mpxs_Apache2__RequestRec_as_string mpxs_Apache2__RequestRec_pnotes | | r, key=Nullsv, val=Nullsv - mpxs_Apache2__RequestRec_add_config | | r, lines, override=OR_AUTHCFG, path=NULL + mpxs_Apache2__RequestRec_add_config | | r, lines, override=OR_AUTHCFG, path=NULL, override_options=-1 mpxs_Apache2__RequestRec_document_root | | r, new_root=Nullsv mpxs_Apache2__RequestRec_child_terminate @@ -152,6 +152,10 @@ ap_method_is_limited mpxs_Apache2__CmdParms_info mpxs_Apache2__CmdParms_add_config + mpxs_Apache2__CmdParms_override_opts MODULE=Apache2::MPM PACKAGE=Apache2::MPM BOOT=1 mpxs_Apache2__MPM_query + +MODULE=Apache2::Access PACKAGE=guess + mpxs_Apache2__RequestRec_allow_override_opts diff -Naur mod_perl/xs/tables/current/ModPerl/FunctionTable.pm mod_perl.new/xs/tables/current/ModPerl/FunctionTable.pm --- mod_perl/xs/tables/current/ModPerl/FunctionTable.pm 2006-02-24 21:25:09.827851474 +0100 +++ mod_perl.new/xs/tables/current/ModPerl/FunctionTable.pm 2006-02-24 21:38:13.303830261 +0100 @@ -1371,6 +1371,10 @@ 'name' => 'path' }, { + 'type' => 'int', + 'name' => 'override_options' + }, + { 'type' => 'ap_conf_vector_t *', 'name' => 'conf' }, @@ -1421,6 +1425,10 @@ { 'type' => 'char *', 'name' => 'path' + }, + { + 'type' => 'int', + 'name' => 'override_options' } ] }, @@ -6109,6 +6117,20 @@ ] }, { + 'return_type' => 'int', + 'name' => 'mpxs_Apache2__CmdParms_override_opts', + 'args' => [ + { + 'type' => 'PerlInterpreter *', + 'name' => 'my_perl' + }, + { + 'type' => 'cmd_parms *', + 'name' => 'parms' + } + ] + }, + { 'return_type' => 'void', 'name' => 'mpxs_Apache2__Connection_add_input_filter', 'args' => [ @@ -6644,6 +6666,10 @@ { 'type' => 'char *', 'name' => 'path' + }, + { + 'type' => 'int', + 'name' => 'override_options' } ] }, @@ -6684,6 +6710,20 @@ ] }, { + 'return_type' => 'int', + 'name' => 'mpxs_Apache2__RequestRec_allow_override_opts', + 'args' => [ + { + 'type' => 'PerlInterpreter *', + 'name' => 'my_perl' + }, + { + 'type' => 'request_rec *', + 'name' => 'r' + } + ] + }, + { 'return_type' => 'SV *', 'name' => 'mpxs_Apache2__RequestRec_as_string', 'args' => [
pgpltFHflXil9.pgp
Description: PGP signature