import of rt 3.0.9
[freeside.git] / rt / bin / mason_handler.fcgi.in
1 #!@PERL@
2 # BEGIN LICENSE BLOCK
3
4 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5
6 # (Except where explictly superceded by other copyright notices)
7
8 # This work is made available to you under the terms of Version 2 of
9 # the GNU General Public License. A copy of that license should have
10 # been provided with this software, but in any event can be snarfed
11 # from www.gnu.org.
12
13 # This work is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # General Public License for more details.
17
18 # Unless otherwise specified, all modifications, corrections or
19 # extensions to this work which alter its source code become the
20 # property of Best Practical Solutions, LLC when submitted for
21 # inclusion in the work.
22
23
24 # END LICENSE BLOCK
25
26 use strict;
27 use File::Basename;
28 require ('@RT_BIN_PATH@/webmux.pl');
29
30 my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
31
32 # Enter CGI::Fast mode, which should also work as a vanilla CGI script.
33 require CGI::Fast;
34
35 RT::Init();
36
37 # Response loop
38 while ( my $cgi = CGI::Fast->new ) {
39     # the whole point of fastcgi requires the env to get reset here..
40     # So we must squash it again
41     $ENV{'PATH'}   = '/bin:/usr/bin';
42     $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
43     $ENV{'SHELL'}  = '/bin/sh' if defined $ENV{'SHELL'};
44     $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
45     $ENV{'IFS'}    = '' if defined $ENV{'IFS'};
46
47     RT::ConnectToDatabase();
48
49     if ( ( !$h->interp->comp_exists( $cgi->path_info ) )
50         && ( $h->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
51         $cgi->path_info( $cgi->path_info . "/index.html" );
52     }
53
54     eval { $h->handle_cgi_object($cgi); };
55     if ($@) {
56         $RT::Logger->crit($@);
57     }
58
59
60     if ($RT::Handle->TransactionDepth) {
61         $RT::Handle->ForceRollback;
62         $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;
63     }
64
65
66 }
67
68 1;