1 # $Header: /home/cvs/cvsroot/freeside/rt/bin/Attic/webmux.pl,v 1.1 2002-08-12 06:17:07 ivan Exp $
2 # RT is (c) 1996-2000 Jesse Vincent (jesse@fsck.com);
5 $ENV{'PATH'} = '/bin:/usr/bin'; # or whatever you need
6 $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
7 $ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'};
8 $ENV{'ENV'} = '' if defined $ENV{'ENV'};
9 $ENV{'IFS'} = '' if defined $ENV{'IFS'};
12 # We really don't want apache to try to eat all vm
13 # see http://perl.apache.org/guide/control.html#Preventing_mod_perl_Processes_Fr
18 use CGI qw(-private_tempfiles); #bring this in before mason, to make sure we
19 #set private_tempfiles
20 use HTML::Mason::ApacheHandler (args_method => 'CGI');
21 use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
23 use vars qw($VERSION %session $Nobody $SystemUser $r $m);
25 # List of modules that you want to use from components (see Admin
28 #Clean up our umask...so that the session files aren't world readable, writable or executable
33 $VERSION="!!RT_VERSION!!";
35 use lib "!!RT_LIB_PATH!!";
36 use lib "!!RT_ETC_PATH!!";
38 #This drags in RT's config.pm
43 package HTML::Mason::Commands;
44 use vars qw(%session $m);
60 use RT::ScripCondition;
61 use RT::ScripConditions;
68 use RT::ObjectKeyword;
69 use RT::ObjectKeywords;
70 use RT::KeywordSelect;
71 use RT::KeywordSelects;
77 use RT::Interface::Web;
84 #TODO: make this use DBI
85 use Apache::Session::File;
87 # Set this page's content type to whatever we are called with
90 $RT::Mason::r->content_type($type);
98 my ($parser, $interp, $ah);
99 if ($HTML::Mason::VERSION < 1.0902) {
100 $parser = &RT::Interface::Web::NewParser(allow_globals => [%session]);
102 $interp = &RT::Interface::Web::NewInterp(parser=>$parser,
103 allow_recursive_autohandlers => 1,
106 $ah = &RT::Interface::Web::NewApacheHandler($interp);
108 $ah = &RT::Interface::Web::NewMason11ApacheHandler();
110 # Activate the following if running httpd as root (the normal case).
111 # Resets ownership of all files created by Mason at startup.
113 chown (Apache->server->uid, Apache->server->gid,
114 [$RT::MasonSessionDir]);
117 chown (Apache->server->uid, Apache->server->gid,
118 $ah->interp->files_written);
120 # Die if WebSessionDir doesn't exist or we can't write to it
122 stat ($RT::MasonSessionDir);
123 die "Can't read and write $RT::MasonSessionDir"
124 unless (( -d _ ) and ( -r _ ) and ( -w _ ));
132 # We don't need to handle non-text items
133 return -1 if defined($r->content_type) && $r->content_type !~ m|^text/|io;
135 #This is all largely cut and pasted from mason's session_handler.pl
137 my %cookies = Apache::Cookie::parse($r->header_in('Cookie'));
140 tie %HTML::Mason::Commands::session, 'Apache::Session::File',
141 ( $cookies{'AF_SID'} ? $cookies{'AF_SID'}->value() : undef ),
142 { Directory => $RT::MasonSessionDir,
143 LockDirectory => $RT::MasonSessionDir,
148 # If the session is invalid, create a new session.
149 if ( $@ =~ m#^Object does not exist in the data store# ) {
150 tie %HTML::Mason::Commands::session, 'Apache::Session::File', undef,
151 { Directory => $RT::MasonSessionDir,
152 LockDirectory => $RT::MasonSessionDir,
154 undef $cookies{'AF_SID'};
157 die "RT Couldn't write to session directory '$RT::MasonSessionDir'. Check that this directory's permissions are correct.";
161 if ( !$cookies{'AF_SID'} ) {
162 my $cookie = new Apache::Cookie
165 -value=>$HTML::Mason::Commands::session{_session_id},
170 my $status = $ah->handle_request($r);
171 untie %HTML::Mason::Commands::session;