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'};
37 use lib ("@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");
42 use CGI qw(-private_tempfiles); #bring this in before mason, to make sure we
43 #set private_tempfiles
46 if ($mod_perl::VERSION >= 1.9908) {
47 require Apache::RequestUtil;
48 no warnings 'redefine';
49 my $sub = *Apache::request{CODE};
50 *Apache::request = sub {
52 eval { $r = $sub->('Apache'); };
58 require HTML::Mason::ApacheHandler;
61 require HTML::Mason::CGIHandler;
65 use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
67 use vars qw($Nobody $SystemUser $r);
69 #This drags in RT's config.pm
75 package HTML::Mason::Commands;
76 use vars qw(%session);
85 use RT::ScripConditions;
90 use RT::CustomFieldValues;
91 use RT::TicketCustomFieldValues;
93 use RT::Interface::Web;
102 # Activate the following if running httpd as root (the normal case).
103 # Resets ownership of all files created by Mason at startup.
104 # Note that mysql uses DB for sessions, so there's no need to do this.
105 unless ($RT::DatabaseType =~ /(mysql|Pg)/) {
106 # Clean up our umask to protect session files
109 if ( $CGI::MOD_PERL) {
110 chown( Apache->server->uid, Apache->server->gid, [$RT::MasonSessionDir] )
111 if Apache->server->can('uid');
113 # Die if WebSessionDir doesn't exist or we can't write to it
114 stat($RT::MasonSessionDir);
115 die "Can't read and write $RT::MasonSessionDir"
116 unless ( ( -d _ ) and ( -r _ ) and ( -w _ ) );
119 my $ah = &RT::Interface::Web::NewApacheHandler(@RT::MasonParameters) if $CGI::MOD_PERL;
124 local $SIG{__WARN__};
129 # We don't need to handle non-text items
130 return -1 if defined( $r->content_type ) && $r->content_type !~ m|^text/|io;
134 eval { $status = $ah->handle_request($r) };
136 $RT::Logger->crit($@);
141 if ($RT::Handle->TransactionDepth) {
142 $RT::Handle->ForceRollback;
143 $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;