stas 2003/02/03 22:52:15 Modified: . Changes todo missing_old_features.txt src/modules/perl mod_perl.c t/modperl .cvsignore Added: t/response/TestModperl taint.pm Log: perl 5.7.3+ has a built-in ${^TAINT} to test whether running under -(T|t). Backport ${^TAINT} for mod_perl running under 5.6.0-5.7.3, (what used to be $Apache::__T. $Apache::__T is available too, but deprecated. + tests Revision Changes Path 1.121 +5 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.120 retrieving revision 1.121 diff -u -r1.120 -r1.121 --- Changes 3 Feb 2003 22:56:19 -0000 1.120 +++ Changes 4 Feb 2003 06:52:15 -0000 1.121 @@ -10,6 +10,11 @@ =item 1.99_09-dev +perl 5.7.3+ has a built-in ${^TAINT} to test whether running under +-(T|t). Backport ${^TAINT} for mod_perl running under 5.6.0-5.7.3, +(what used to be $Apache::__T. $Apache::__T is available too, but +deprecated. [Stas] + add PerlChildExitHandler implementation [Stas] add PerlCleanupHandler implementation + test [Stas] 1.26 +0 -3 modperl-2.0/todo/missing_old_features.txt Index: missing_old_features.txt =================================================================== RCS file: /home/cvs/modperl-2.0/todo/missing_old_features.txt,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- missing_old_features.txt 3 Feb 2003 22:56:19 -0000 1.25 +++ missing_old_features.txt 4 Feb 2003 06:52:15 -0000 1.26 @@ -24,9 +24,6 @@ - ... others ... -- Apache::__T flag which tells whether we run under -T (in 5.8.0 can check - ${^TAINT}) - core modules: ------------ 1.151 +25 -0 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.150 retrieving revision 1.151 diff -u -r1.150 -r1.151 --- mod_perl.c 3 Feb 2003 22:56:19 -0000 1.150 +++ mod_perl.c 4 Feb 2003 06:52:15 -0000 1.151 @@ -101,6 +101,29 @@ return server_pool; } +static void set_taint_var(PerlInterpreter *perl) +{ + dTHXa(perl); + GV *gv; + +/* 5.7.3+ has a built-in special ${^TAINT}, backport it to 5.6.0+ */ +#if PERL_REVISION == 5 && \ + (PERL_VERSION == 6 || (PERL_VERSION == 7 && PERL_SUBVERSION < 3)) + + gv = gv_fetchpv("\024AINT", GV_ADDMULTI, SVt_IV); + sv_setiv(GvSV(gv), PL_tainting); + SvREADONLY_on(GvSV(gv)); +#endif /* perl v < 5.7.3 */ + +#ifdef MP_COMPAT_1X + gv = gv_fetchpv("Apache::__T", GV_ADDMULTI, SVt_PV); + sv_setiv(GvSV(gv), PL_tainting); + SvREADONLY_on(GvSV(gv)); +#endif /* MP_COMPAT_1X */ + +} + + PerlInterpreter *modperl_startup(server_rec *s, apr_pool_t *p) { AV *endav; @@ -175,6 +198,8 @@ apr_pool_cleanup_register(server_pool, cdata, modperl_shutdown, apr_pool_cleanup_null); #endif + + set_taint_var(perl); return perl; } 1.12 +1 -0 modperl-2.0/t/modperl/.cvsignore Index: .cvsignore =================================================================== RCS file: /home/cvs/modperl-2.0/t/modperl/.cvsignore,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- .cvsignore 22 Jan 2003 03:19:43 -0000 1.11 +++ .cvsignore 4 Feb 2003 06:52:15 -0000 1.12 @@ -11,3 +11,4 @@ method.t setauth.t request_rec_tie_api.t +taint.t \ No newline at end of file 1.1 modperl-2.0/t/response/TestModperl/taint.pm Index: taint.pm =================================================================== package TestModperl::taint; use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::RequestIO (); use Apache::RequestUtil (); use Apache::Const -compile => 'OK'; sub handler { my $r = shift; plan $r, tests => 4; ok t_cmp(1, ${^TAINT}, "\${^TAINT}"); eval { ${^TAINT} = 0 }; ok t_cmp(qr/read-only/, $@, "\${^TAINT} is read-only"); ok t_cmp(1, $Apache::__T, "\$Apache::__T"); eval { $Apache::__T = 0 }; ok t_cmp(qr/read-only/, $@, "\$Apache::__T is read-only"); Apache::OK; } 1; __END__