This issue has been discussed on the MP mailing list and I have developed an Apache::Test that shows the problem (probably not the best test ever written). The scenario is that a request to one folder (A) that does a PerlSetEnv with an AuthenHandler to an html page when another request comes in on the same process to a different folder (B) the variable set with PerlSetEnv for folder A still exists…see diffs/files below
Index: t/conf/extra.conf.in
===================================================================
--- t/conf/extra.conf.in (revision 193135)
+++ t/conf/extra.conf.in (working copy)
@@ -104,3 +104,28 @@
</Location>
</IfModule>
</VirtualHost>
+
+<Directory @ServerRoot@/htdocs/env/A/>
+ <Files ~ "\.pl$">
+ SetHandler perl-script
+ PerlHandler ModPerl::Registry
+ Options ExecCGI
+ allow from all
+ PerlSendHeader ON
+ </Files>
+ PerlSetEnv FOO "BAR"
+ AuthName "A"
+ AuthType A
+ PerlAuthenHandler 'sub {use Apache2::Const qw{OK}; return OK;}'
+ require valid-user
+</Directory>
+
+<Directory @ServerRoot@/htdocs/env/B/>
+ <Files ~ "\.pl$">
+ SetHandler perl-script
+ PerlHandler ModPerl::Registry
+ Options ExecCGI
+ allow from all
+ PerlSendHeader ON
+ </Files>
+</Directory>
NEW FILES
--- /dev/null 2005-06-13 09:09:25.156892824 -0400
+++ t/env/PerlSetEnv.t 2005-06-23 07:45:00.910652256 -0400
@@ -0,0 +1,30 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+
+plan tests => 5, have_lwp;
+
+#my $envContent = GET_BODY '/env/A/test.pl';
+#print $envContent;
+#ok ($envContent eq 'BAR');
+
+my $content = GET_BODY '/env/A/test.html';
+chomp $content;
+ok ($content eq 'empty');
+
+$content = GET_BODY '/env/A/test.html';
+chomp $content;
+ok ($content eq 'empty');
+
+my $content2 = GET_BODY '/env/B/test.pl';
+ok ($content2 eq '');
+
+my $content3 = GET_BODY '/env/B/test.pl';
+print $content3;
+ok ($content3 eq '');
+
+my $content4 = GET_BODY '/env/B/test.pl';
+print $content4;
+ok ($content4 eq '');
--- /dev/null 2005-06-13 09:09:25.156892824 -0400
+++ t/htdocs/env/A/test.html 2005-06-23 07:46:39.155266357 -0400
@@ -0,0 +1 @@
+empty
--- /dev/null 2005-06-13 09:09:25.156892824 -0400
+++ t/htdocs/env/A/test.pl 2005-06-23 07:46:55.825807224 -0400
@@ -0,0 +1,2 @@
+print "Content-type: text/html\n\n";
+print $ENV{FOO};
--- /dev/null 2005-06-13 09:09:25.156892824 -0400
+++ t/htdocs/env/B/test.pl 2005-06-23 07:47:05.334833962 -0400
@@ -0,0 +1,3 @@
+print "Content-type: text/html\n\n";
+print $ENV{FOO};
Here are my test results.
t/env/PerlSetEnv....NOK 3# Failed test 3 in t/env/PerlSetEnv.t at line 22
# Failed test 4 in t/env/PerlSetEnv.t at line 26
# Failed test 5 in t/env/PerlSetEnv.t at line 30
t/env/PerlSetEnv....FAILED tests 3-5
Failed 3/5 tests, 40.00% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/env/PerlSetEnv.t 5 3 60.00% 3-5
Failed 1/1 test scripts, 0.00% okay. 3/5 subtests failed, 40.00% okay.
Possible Fix (there may be a better way but this passed all tests):
Index: src/modules/perl/modperl_config.c
===================================================================
--- src/modules/perl/modperl_config.c (revision 193135)
+++ src/modules/perl/modperl_config.c (working copy)
@@ -369,7 +369,13 @@
/* undo changes to %ENV caused by +SetupEnv, perl-script, or
* $r->subprocess_env, so the values won't persist */
- if (MpReqSETUP_ENV(rcfg)) {
+ if (MpReqSETUP_ENV(rcfg) || MpReqPERL_SET_ENV_SRV(rcfg) || MpReqPERL_SET_ENV_DIR(rcfg)) {
+ /*
+ * inside this function we check again if MpReqSETUP_ENV is till on
+ * it may not be on if we are in here from SET_ENV_DIR or SET_ENV_SRV
+ * so just set it on
+ */
+ MpReqSETUP_ENV_On(rcfg);
modperl_env_request_unpopulate(aTHX_ r);
}
Brian Becker
