X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMason%2FRequest.pm;h=36c46dc41bda9eb87667081e7ce5d6175c7b10da;hb=7b5a266236857fbb4bbf8d4ac3031c3fec75cac2;hp=d8fd77a664efa0a81841ab37f4a0e049ee9a4512;hpb=be40a9fa3750374b32f2aa31e8807433c05d7817;p=freeside.git diff --git a/FS/FS/Mason/Request.pm b/FS/FS/Mason/Request.pm index d8fd77a66..36c46dc41 100644 --- a/FS/FS/Mason/Request.pm +++ b/FS/FS/Mason/Request.pm @@ -4,6 +4,7 @@ use strict; use warnings; use vars qw( $FSURL $QUERY_STRING ); use base 'HTML::Mason::Request'; +use FS::Trace; $FSURL = 'http://Set/FS_Mason_Request_FSURL/in_standalone_mode/'; $QUERY_STRING = ''; @@ -11,21 +12,27 @@ $QUERY_STRING = ''; sub new { my $class = shift; + FS::Trace->log('creating new FS::Mason::Request object'); + my $superclass = $HTML::Mason::ApacheHandler::VERSION ? 'HTML::Mason::Request::ApacheHandler' : $HTML::Mason::CGIHandler::VERSION ? 'HTML::Mason::Request::CGI' : 'HTML::Mason::Request'; + FS::Trace->log(' altering superclass'); $class->alter_superclass( $superclass ); + FS::Trace->log(' setting valid params'); #huh... shouldn't alter_superclass take care of this for us? __PACKAGE__->valid_params( %{ $superclass->valid_params() } ); + FS::Trace->log(' freeside_setup'); my %opt = @_; my $mode = $superclass =~ /Apache/i ? 'apache' : 'standalone'; $class->freeside_setup($opt{'comp'}, $mode); + FS::Trace->log(' SUPER::new'); $class->SUPER::new(@_); } @@ -33,11 +40,34 @@ sub new { #override alter_superclass ala RT::Interface::Web::Request ?? # for Mason 1.39 vs. Perl 5.10.0 +my $protect_fds; + sub freeside_setup { my( $class, $filename, $mode ) = @_; + FS::Trace->log(' protecting fds'); + + #from rt/bin/webmux.pl(.in) + if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'} + && $ENV{'MOD_PERL_API_VERSION'} >= 2 + ) { + # under mod_perl2, STDIN and STDOUT get closed and re-opened, + # however they are not on FD 0 and 1. In this case, the next + # socket that gets opened will occupy one of these FDs, and make + # all system() and open "|-" calls dangerous; for example, the + # DBI handle can get this FD, which later system() calls will + # close by putting garbage into the socket. + $protect_fds = []; + push @{$protect_fds}, IO::Handle->new_from_fd(0, "r") + if fileno(STDIN) != 0; + push @{$protect_fds}, IO::Handle->new_from_fd(1, "w") + if fileno(STDOUT) != 1; + } + if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) { + FS::Trace->log(' handling RT REST/NoAuth file'); + package HTML::Mason::Commands; #? use FS::UID qw( adminsuidsetup ); @@ -46,10 +76,13 @@ sub freeside_setup { ##old installs w/fs_selfs or selfserv?? #&adminsuidsetup('fs_selfservice'); + FS::Trace->log(' adminsuidsetup fs_queue'); &adminsuidsetup('fs_queue'); } else { + FS::Trace->log(' handling regular file'); + package HTML::Mason::Commands; use vars qw( $cgi $p $fsurl ); # $lh ); #not using /mt use Encode; @@ -58,6 +91,7 @@ sub freeside_setup { if ( $mode eq 'apache' ) { $cgi = new CGI; + FS::Trace->log(' cgisuidsetup'); &cgisuidsetup($cgi); #&cgisuidsetup($r); $fsurl = rooturl(); @@ -72,6 +106,7 @@ sub freeside_setup { die "unknown mode $mode"; } + FS::Trace->log(' UTF-8-decoding form data'); # foreach my $param ( $cgi->param ) { my @values = $cgi->param($param); @@ -83,6 +118,8 @@ sub freeside_setup { } + FS::Trace->log(' done'); + } sub callback {