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 use lib ("@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");
41 use CGI qw(-private_tempfiles); #bring this in before mason, to make sure we
42 #set private_tempfiles
46 require HTML::Mason::ApacheHandler;
49 require HTML::Mason::CGIHandler;
53 use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
55 use vars qw($Nobody $SystemUser $r);
57 #This drags in RT's config.pm
63 package HTML::Mason::Commands;
64 use vars qw(%session);
73 use RT::ScripConditions;
78 use RT::CustomFieldValues;
79 use RT::TicketCustomFieldValues;
81 use RT::Interface::Web;
90 # Activate the following if running httpd as root (the normal case).
91 # Resets ownership of all files created by Mason at startup.
92 # Note that mysql uses DB for sessions, so there's no need to do this.
93 unless ($RT::DatabaseType =~ /(mysql|Pg)/) {
94 # Clean up our umask to protect session files
97 if ( $CGI::MOD_PERL) {
98 chown( Apache->server->uid, Apache->server->gid, [$RT::MasonSessionDir] )
99 if Apache->server->can('uid');
101 # Die if WebSessionDir doesn't exist or we can't write to it
102 stat($RT::MasonSessionDir);
103 die "Can't read and write $RT::MasonSessionDir"
104 unless ( ( -d _ ) and ( -r _ ) and ( -w _ ) );
107 my $ah = &RT::Interface::Web::NewApacheHandler() if $CGI::MOD_PERL;
114 # We don't need to handle non-text items
115 return -1 if defined( $r->content_type ) && $r->content_type !~ m|^text/|io;
118 my $status = $ah->handle_request($r);
121 $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") if $RT::Handle->TransactionDepth;