4 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
6 # (Except where explictly superceded by other copyright notices)
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
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.
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.
29 $ENV{'PATH'} = '/bin:/usr/bin'; # or whatever you need
30 $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
31 $ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'};
32 $ENV{'ENV'} = '' if defined $ENV{'ENV'};
33 $ENV{'IFS'} = '' if defined $ENV{'IFS'};
36 eval { require Apache2; require Apache::compat }
37 if $ENV{'MOD_PERL'} and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
41 use lib ("@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");
46 use CGI qw(-private_tempfiles); #bring this in before mason, to make sure we
47 #set private_tempfiles
50 if ($mod_perl::VERSION >= 1.9908) {
51 require Apache::RequestUtil;
52 no warnings 'redefine';
53 my $sub = *Apache::request{CODE};
54 *Apache::request = sub {
56 eval { $r = $sub->('Apache'); };
62 require HTML::Mason::ApacheHandler;
65 require HTML::Mason::CGIHandler;
69 use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
71 use vars qw($Nobody $SystemUser $r);
73 #This drags in RT's config.pm
79 package HTML::Mason::Commands;
80 use vars qw(%session);
89 use RT::ScripConditions;
94 use RT::CustomFieldValues;
95 use RT::TicketCustomFieldValues;
97 use RT::Interface::Web;
106 # Activate the following if running httpd as root (the normal case).
107 # Resets ownership of all files created by Mason at startup.
108 # Note that mysql uses DB for sessions, so there's no need to do this.
109 unless ($RT::DatabaseType =~ /(mysql|Pg)/) {
110 # Clean up our umask to protect session files
113 if ( $CGI::MOD_PERL) {
114 chown( Apache->server->uid, Apache->server->gid, [$RT::MasonSessionDir] )
115 if Apache->server->can('uid');
117 # Die if WebSessionDir doesn't exist or we can't write to it
118 stat($RT::MasonSessionDir);
119 die "Can't read and write $RT::MasonSessionDir"
120 unless ( ( -d _ ) and ( -r _ ) and ( -w _ ) );
123 my $ah = &RT::Interface::Web::NewApacheHandler(@RT::MasonParameters) if $CGI::MOD_PERL;
128 local $SIG{__WARN__};
133 # We don't need to handle non-text items
134 return -1 if defined( $r->content_type ) && $r->content_type !~ m|^text/|io;
138 eval { $status = $ah->handle_request($r) };
140 $RT::Logger->crit($@);
145 if ($RT::Handle->TransactionDepth) {
146 $RT::Handle->ForceRollback;
147 $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;