Eamon Daly wrote: > 1. Problem Description: > > If I declare a <Perl> section in httpd.conf, then define > a virtual host with "PerlOptions +Parent", httpd dies with > a segfault on subsequent PerlRequires. This works in 2.0.1. > Here's a minimal example, tacked on to the end of the > default httpd.conf: > > --- httpd.conf --- > > <Perl> > 1; > </Perl> > > <VirtualHost _default_:80> > ServerAdmin [EMAIL PROTECTED] > DocumentRoot /www/docs/dummy-host.example.com > ServerName dummy-host.example.com > ErrorLog logs/dummy-host.example.com-error_log > CustomLog logs/dummy-host.example.com-access_log common > PerlOptions +Parent > PerlRequire /etc/httpd/conf/startup.pl > </VirtualHost> > > --- startup.pl --- > > use strict; > > 1; > > Is this just bad syntax on our part that luckily Just > Worked or is this broken behavior in 2.0.2?
This is certainly a bug and was, if not introduced, aggravated by this change
of mine [291193].
It exposed a bug in the implementation of "PerlSwitches +inherit" [1], which led
me to realize that it was broken. This bit of code is seriously wrong:
in src/modules/perl/modperl_cmd.c:
if (add->argv->nelts == 2 && strEQ(((char **)add->argv->elts)[1],
"+inherit")) {
That's making quite a few incorrect assumptions. Like that the '+inherit' option
would always be the second one, and only recognized if it was the second one.
On top of that, specifying
PerlSwitches +inherit
in your httpd.conf, it would end up in the argv that's passed to perl_parse(),
so you'd
end up with this lovely startup error:
Can't open perl script "+inherit": No such file or directory
perl_parse: No such file or directory
After some initial tinkering, I think the following patch is a much better
solution.
I've made the switch inheriting option a proper per-server config, and I skip
adding
it to perl's argv[].
Let me know if this solves your problem.
1 - http://perl.apache.org/docs/2.0/user/config/config.html#C_Clone_
291193 - (http://svn.apache.org/viewcvs.cgi?rev=291193&view=rev)
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: src/modules/perl/modperl_config.c
===================================================================
--- src/modules/perl/modperl_config.c (revision 370942)
+++ src/modules/perl/modperl_config.c (working copy)
@@ -302,9 +302,7 @@
merge_item(perl);
#endif
- if (add->argv->nelts == 2 &&
- strEQ(((char **)add->argv->elts)[1], "+inherit"))
- {
+ if (MpSrvINHERIT(add)) {
/* only inherit base PerlSwitches if explicitly told to */
mrg->argv = base->argv;
}
Index: src/modules/perl/modperl_cmd.c
===================================================================
--- src/modules/perl/modperl_cmd.c (revision 370942)
+++ src/modules/perl/modperl_cmd.c (working copy)
@@ -156,7 +156,13 @@
return modperl_cmd_too_late(parms);
}
MP_TRACE_d(MP_FUNC, "arg = %s\n", arg);
- modperl_config_srv_argv_push(arg);
+
+ if(0 == strncasecmp(arg, "+inherit", 8)) {
+ modperl_cmd_options(parms, mconfig, "+Inherit");
+ }
+ else {
+ modperl_config_srv_argv_push(arg);
+ }
return NULL;
}
Index: t/conf/extra.last.conf.in
===================================================================
--- t/conf/extra.last.conf.in (revision 370942)
+++ t/conf/extra.last.conf.in (working copy)
@@ -94,3 +94,11 @@
=cut
PerlSetVar TestDirective__pod_cut_worked yes
+
+#This used to trigger a segfault on startup
+#See http://article.gmane.org/gmane.comp.apache.mod-perl/22750
+<VirtualHost inherit>
+ PerlSwitches +inherit
+ PerlOptions +Parent
+ Perl 1
+</VirtualHost>
Index: lib/ModPerl/Code.pm
===================================================================
--- lib/ModPerl/Code.pm (revision 370942)
+++ lib/ModPerl/Code.pm (working copy)
@@ -137,7 +137,7 @@
my @ithread_opts = qw(CLONE PARENT);
my %flags = (
Srv => ['NONE', @ithread_opts, qw(ENABLE AUTOLOAD MERGE_HANDLERS),
- @hook_flags, 'UNSET'],
+ @hook_flags, 'UNSET','INHERIT'],
Dir => [qw(NONE PARSE_HEADERS SETUP_ENV MERGE_HANDLERS GLOBAL_REQUEST UNSET)],
Req => [qw(NONE SET_GLOBAL_REQUEST PARSE_HEADERS SETUP_ENV
CLEANUP_REGISTERED PERL_SET_ENV_DIR PERL_SET_ENV_SRV)],
Index: Changes
===================================================================
--- Changes (revision 370942)
+++ Changes (working copy)
@@ -12,6 +12,9 @@
=item 2.0.3-dev
+Fix 'PerlSwitches +inherit' that got broken somewhere along
+the way to 2.0 [Gozer]
+
Add perl API corresponding to User and Group directives in httpd.conf:
Apache2::ServerUtil->user_id and Apache2::ServerUtil->group_id
[Stas]
signature.asc
Description: OpenPGP digital signature
