From ded0451e9582df33cae6099a2fb72b4ea25076cf Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Jul 2003 13:30:43 +0000 Subject: reverting to vendor branch rt 3.0.4, hopefully --- rt/bin/initacls.Oracle | 26 - rt/bin/initacls.Pg | 28 - rt/bin/initacls.mysql | 20 - rt/bin/mason_handler.fcgi | 255 ++------- rt/bin/mason_handler.scgi | 218 ++----- rt/bin/rt | 1391 --------------------------------------------- rt/bin/rt-mailgate | 842 +++++++++++++++++---------- rt/bin/rtadmin | 1040 --------------------------------- rt/bin/webmux.pl | 248 ++++---- 9 files changed, 706 insertions(+), 3362 deletions(-) delete mode 100644 rt/bin/initacls.Oracle delete mode 100755 rt/bin/initacls.Pg delete mode 100755 rt/bin/initacls.mysql delete mode 100755 rt/bin/rt delete mode 100644 rt/bin/rtadmin (limited to 'rt/bin') diff --git a/rt/bin/initacls.Oracle b/rt/bin/initacls.Oracle deleted file mode 100644 index 8d05f45e1..000000000 --- a/rt/bin/initacls.Oracle +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -DATABASEHOME=$1 -HOSTNAME=$2 -PORT=$3 -DATABASEADMIN=$4 -DBAPASSWD=$5 -DATABASENAME=$6 -DATABASEACLS=$7 - -BINDIR=${DATABASEHOME}/bin - -echo "DBHOME = $DATABASEHOME" -echo "HOSTNAME = $HOSTNAME" -echo "PORT = $PORT" -echo "DATABASEADMIN = $DATABASEADMIN" -echo "DBAPASSWD = $DBAPASSWD" -echo "DATABASENAME = $DATABASENAME" - -PATH=$PATH:$BINDIR -export PATH - -echo "Please enter ${DATABASEADMIN}'s password for the SID ${DATABASENAME} to create an rt user"; - -$BINDIR/sqlplus ${DATABASEADMIN}@${DATABASENAME} @$DATABASEACLS - diff --git a/rt/bin/initacls.Pg b/rt/bin/initacls.Pg deleted file mode 100755 index 82e32de74..000000000 --- a/rt/bin/initacls.Pg +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -DATABASEHOME=$1 -HOSTNAME=$2 -PORT=$3 -DATABASEADMIN=$4 -DBAPASSWD=$5 -DATABASENAME=$6 -DATABASEACLS=$7 - -BINDIR=${DATABASEHOME}/bin - - -PATH=$PATH:$BINDIR -export PATH - -echo "Enter the postgres administrator's database password to create a new user for rt" - -if [ "fnord$PORT" != "fnord" ]; then - PORT="-p $PORT" -fi; - -if [ "fnord$HOSTNAME" != "fnord" ]; then - HOSTNAME="-h $HOSTNAME" -fi; - -psql $HOSTNAME $PORT -d $DATABASENAME -f $DATABASEACLS -U $DATABASEADMIN - diff --git a/rt/bin/initacls.mysql b/rt/bin/initacls.mysql deleted file mode 100755 index 17e63f837..000000000 --- a/rt/bin/initacls.mysql +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -DATABASEHOME=$1 -HOSTNAME=$2 -PORT=$3 -DATABASEADMIN=$4 -DBAPASSWD=$5 -DATABASENAME=$6 -DATABASEACLS=$7 - -BINDIR=${DATABASEHOME}/bin - -PATH=$PATH:$BINDIR -export PATH - -echo "Enter the mysql administrator's database password to create a new user for RT" -$BINDIR/mysql --host=${HOSTNAME} --port=${PORT} --user=${DATABASEADMIN} -p${DBAPASSWD} mysql < $DATABASEACLS - -echo "Enter the mysql administrator's database password to nondestructively reload the database" -$BINDIR/mysqladmin --host=${HOSTNAME} --port=${PORT} --user=${DATABASEADMIN} -p${DBAPASSWD} reload diff --git a/rt/bin/mason_handler.fcgi b/rt/bin/mason_handler.fcgi index e8a4e128f..431eccbd3 100755 --- a/rt/bin/mason_handler.fcgi +++ b/rt/bin/mason_handler.fcgi @@ -1,221 +1,54 @@ -#!!!PERL!! -# $Header: /home/cvs/cvsroot/freeside/rt/bin/mason_handler.fcgi,v 1.1 2002-08-12 06:17:07 ivan Exp $ -# RT is (c) 1996-2001 Jesse Vincent (jesse@fsck.com); +#!/usr/bin/perl +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK use strict; -$ENV{'PATH'} = '/bin:/usr/bin'; # or whatever you need -$ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'}; -$ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'}; -$ENV{'ENV'} = '' if defined $ENV{'ENV'}; -$ENV{'IFS'} = '' if defined $ENV{'IFS'}; +use File::Basename; +require ('/opt/rt3/bin/webmux.pl'); +my $h = &RT::Interface::Web::NewCGIHandler(); -# We really don't want apache to try to eat all vm -# see http://perl.apache.org/guide/control.html#Preventing_mod_perl_Processes_Fr - - -package RT::Mason; -#use CGI qw(-private_tempfiles); # pull in CGI with the private tempfiles - #option predefined -use HTML::Mason; # brings in subpackages: Parser, Interp, etc. - -use vars qw($VERSION %session $Nobody $SystemUser $cgi); - -# List of modules that you want to use from components (see Admin -# manual for details) - -#Clean up our umask...so that the session files aren't world readable, writable or executable -umask(0077); - - - -$VERSION="!!RT_VERSION!!"; - -use lib "!!RT_LIB_PATH!!"; -use lib "!!RT_ETC_PATH!!"; - -#This drags in RT's config.pm -use config; -use Carp; - -{ - package HTML::Mason::Commands; - use vars qw(%session $ContentType); - - use RT; - use RT::Ticket; - use RT::Tickets; - use RT::Transaction; - use RT::Transactions; - use RT::User; - use RT::Users; - use RT::CurrentUser; - use RT::Template; - use RT::Templates; - use RT::Queue; - use RT::Queues; - use RT::ScripAction; - use RT::ScripActions; - use RT::ScripCondition; - use RT::ScripConditions; - use RT::Scrip; - use RT::Scrips; - use RT::Group; - use RT::Groups; - use RT::Keyword; - use RT::Keywords; - use RT::ObjectKeyword; - use RT::ObjectKeywords; - use RT::KeywordSelect; - use RT::KeywordSelects; - use RT::GroupMember; - use RT::GroupMembers; - use RT::Watcher; - use RT::Watchers; - use RT::Handle; - use RT::Interface::Web; - use MIME::Entity; - use CGI::Cookie; - use Date::Parse; - use HTML::Entities; - use Text::Wrapper; - - #TODO: make this use DBI - use Apache::Session::File; - use CGI::Fast; - - # set the page's content type. - # In this case, just save it to a variable that we can pull later; - sub SetContentType { - $ContentType = shift; - } - sub CGIObject { - return $RT::Mason::cgi; - } -} - - -my ($output, $parser, $interp); -if ($HTML::Mason::VERSION < 1.0902) { - require HTML::Mason::ApacheHandler; - - $parser = &RT::Interface::Web::NewParser(allow_globals => [%session]); - - $interp = &RT::Interface::Web::NewInterp(parser=>$parser, - allow_recursive_autohandlers => 1, - out_method => \$output); -} -else { - $interp = &RT::Interface::Web::NewInterp( - allow_globals => [%session], - default_escape_flags => 'h', - - out_method => \$output); -} -# Die if WebSessionDir doesn't exist or we can't write to it - -stat ($RT::MasonSessionDir); -die "Can't read and write $RT::MasonSessionDir" - unless (( -d _ ) and ( -r _ ) and ( -w _ )); - +# Enter CGI::Fast mode, which should also work as a vanilla CGI script. +require CGI::Fast; RT::Init(); # Response loop -while ($RT::Mason::cgi = new CGI::Fast) { - - $HTML::Mason::Commands::ContentType = 'text/html'; - - # This routine comes from ApacheHandler.pm: - my (%args, $cookie); - foreach my $key ( $cgi->param ) { - foreach my $value ( $cgi->param($key) ) { - if (exists($args{$key})) { - if (ref($args{$key})) { - $args{$key} = [@{$args{$key}}, $value]; - } else { - $args{$key} = [$args{$key}, $value]; - } - } else { - $args{$key} = $value; - } - - } - - } - - - my $comp = $ENV{'PATH_INFO'}; - - if ($comp =~ /^(.*)$/) { # untaint the path info. apache should - # never hand us a bogus path. - # We should be more careful here. - $comp = $1; - } - - if ($comp =~ /\/$/) { - $comp .= "index.html"; - } - - #This is all largely cut and pasted from mason's session_handler.pl - - # {{{ Cookies - my %cookies = fetch CGI::Cookie(); - - eval { - my $session_id = undef; - - #Get the session id and untaint it - if ($cookies{'AF_SID'} && $cookies{'AF_SID'}->value() =~ /^(.*)$/) { - $session_id = $1; - } - - tie %HTML::Mason::Commands::session, 'Apache::Session::File', - $session_id, - { Directory => $RT::MasonSessionDir, - LockDirectory => $RT::MasonSessionDir, - } ; - }; - - if ( $@ ) { - # If the session is invalid, create a new session. - if ( $@ =~ m#^Object does not exist in the data store# ) { - tie %HTML::Mason::Commands::session, 'Apache::Session::File', undef, - { Directory => $RT::MasonSessionDir, - LockDirectory => $RT::MasonSessionDir, - }; - undef $cookies{'AF_SID'}; - } - else { - die "$@ \nProbably means that RT Couldn't write to session directory '$RT::MasonSessionDir'. Check that this directory's permissions are correct."; - } +while ( my $cgi = CGI::Fast->new ) { + # the whole point of fastcgi requires the env to get reset here.. + # So we must squash it again + $ENV{'PATH'} = '/bin:/usr/bin'; + $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'}; + $ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'}; + $ENV{'ENV'} = '' if defined $ENV{'ENV'}; + $ENV{'IFS'} = '' if defined $ENV{'IFS'}; + + unless ($h->interp->comp_exists($cgi->path_info)) { + $cgi->path_info($cgi->path_info . "/index.html"); } - - if ( !$cookies{'AF_SID'} ) { - $cookie = new CGI::Cookie - (-name=>'AF_SID', - -value=>$HTML::Mason::Commands::session{_session_id}, - -path => '/',); - - } else { - $cookie = undef; - } - - # }}} - - $output = ''; - eval { - my $status = $interp->exec($comp, %args); - }; - - if ($@) { - $output = "
$@
"; - } - - print "Content-Type: $HTML::Mason::Commands::ContentType\r\n"; - print "Set-Cookie: $cookie\r\n" if ($cookie); - print "\r\n"; - print $output; - untie %HTML::Mason::Commands::session; - + $h->handle_cgi_object($cgi); + # _should_ always be tied } + +1; diff --git a/rt/bin/mason_handler.scgi b/rt/bin/mason_handler.scgi index b9846c898..8e1135c2f 100755 --- a/rt/bin/mason_handler.scgi +++ b/rt/bin/mason_handler.scgi @@ -1,193 +1,41 @@ -#!!!PERL!! -w - -#!/usr/bin/speedy -- -t600 -M8 -# $Header: /home/cvs/cvsroot/freeside/rt/bin/mason_handler.scgi,v 1.1 2002-08-12 06:17:07 ivan Exp $ -# RT is (c) 1996-2001 Jesse Vincent (jesse@fsck.com); -# -# Contains code derived from mason.cgi -# mason.cgi is Copyright December 2000 Joshua Kronengold (mneme@io.com, -# mneme@cyberspace.org). All Rights Reserved. +#!/usr/local/bin/speedy +# BEGIN LICENSE BLOCK +# +# Copyright (c) 1996-2003 Jesse Vincent +# +# (Except where explictly superceded by other copyright notices) +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# Unless otherwise specified, all modifications, corrections or +# extensions to this work which alter its source code become the +# property of Best Practical Solutions, LLC when submitted for +# inclusion in the work. +# +# +# END LICENSE BLOCK use strict; -# {{{ Clean out the environment a little bit -$ENV{'PATH'} = '/bin:/usr/bin'; # or whatever you need -$ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'}; -$ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'}; -$ENV{'ENV'} = '' if defined $ENV{'ENV'}; -$ENV{'IFS'} = '' if defined $ENV{'IFS'}; -# }}} - -package RT::Mason; -use HTML::Mason; # brings in subpackages: Parser, Interp, etc. -use vars qw($VERSION %session $Nobody $SystemUser); - -# List of modules that you want to use from components (see Admin -# manual for details) - -$VERSION="!!RT_VERSION!!"; - -use lib "!!RT_LIB_PATH!!"; -use lib "!!RT_ETC_PATH!!"; - - -#This drags in RT's config.pm -use config; -use Carp; - -use HTML::Mason::FakeApache; -use CGI; - -# {{{ Set up CGI environment and grab CGI params: +require ('/opt/rt3/bin/webmux.pl'); -my $r=new HTML::Mason::FakeApache; +my $h = &RT::Interface::Web::NewCGIHandler(); -$|=1; # set output to non-buffered. +require CGI; -my %cgi; -CGI::ReadParse(\%cgi); # %cgi is now a tied hash containing our params. +RT::Init(); -my $q=$cgi{CGI}; # $q now contains the object tied to %cgi. -# }}} - -# {{{ require what we need -{ - package HTML::Mason::Commands; - - use vars qw(%session); - - use RT::Ticket; - use RT::Tickets; - use RT::Transaction; - use RT::Transactions; - use RT::User; - use RT::Users; - use RT::CurrentUser; - use RT::Template; - use RT::Templates; - use RT::Queue; - use RT::Queues; - use RT::ScripAction; - use RT::ScripActions; - use RT::ScripCondition; - use RT::ScripConditions; - use RT::Scrip; - use RT::Scrips; - use RT::Group; - use RT::Groups; - use RT::Keyword; - use RT::Keywords; - use RT::ObjectKeyword; - use RT::ObjectKeywords; - use RT::KeywordSelect; - use RT::KeywordSelects; - use RT::GroupMember; - use RT::GroupMembers; - use RT::Watcher; - use RT::Watchers; - use RT::Handle; - use RT::Interface::Web; - use MIME::Entity; - use CGI::Cookie; - use Date::Parse; - use HTML::Entities; - - - use Apache::Session::File; - - +my $cgi = CGI->new; +unless ($h->interp->comp_exists($cgi->path_info)) { + $cgi->path_info($cgi->path_info . "/index.html"); } -# }}} - -# {{{ RT Database setup - $RT::Handle = new RT::Handle; - - $RT::Handle->Connect; - - use RT::CurrentUser; - - #RT's system user is a genuine database user. its id lives here - $RT::SystemUser = new RT::CurrentUser(); - $RT::SystemUser->LoadByName('RT_System'); - - #RT's "nobody user" is a genuine database user. its ID lives here. - $RT::Nobody = new RT::CurrentUser(); - $RT::Nobody->LoadByName('Nobody'); - - -# }}} - - - - -# {{{ Deal with cookies - -my %cookies = fetch CGI::Cookie(); -eval { - tie %HTML::Mason::Commands::session, 'Apache::Session::File', - ( $cookies{'AF_SID'} ? $cookies{'AF_SID'}->value() : undef ); -}; - -if ( $@ ) { - # If the session is invalid, create a new session. - if ( $@ =~ m#^Object does not exist in the data store# ) { - tie %HTML::Mason::Commands::session, 'Apache::Session::File', undef; - undef $cookies{'AF_SID'}; - } -} - -if ( !$cookies{'AF_SID'} ) { - my $cookie = new CGI::Cookie( - -name=>'AF_SID', - -value=>$HTML::Mason::Commands::session{_session_id}, - -path => '/'); - print 'Set-Cookie: '. $cookie."\r\n"; -} - -# }}} - -my $path=$ENV{PATH_INFO} || "/"; $path=~s/\'/\\\'/g; - -my $type=`/usr/bin/file '$RT::MasonComponentRoot/$path'`; - -# {{{ if it's a text file, handle it with mason. -if($type=~/text|directory/) { - my ($out, %mason_params); - my $parser = RT::Interface::Web::NewParser(allow_globals=>[qw($r)]); - $mason_params{parser}=$parser; - $r->content_type('text/html'); - # (get cookies line) ... - $r->access_hash('headers_in','Cookie',$ENV{HTTP_COOKIE}); - $r->{'args@'}=[]; - $mason_params{out_method}=\$out; - - my $interp = RT::Interface::Web::NewInterp(%mason_params); - - $interp->set_global(r=>$r); - $interp->exec($path,%cgi); - $r->send_http_header(); - print $out; -} -# }}} - -# {{{ if it's not a text file, just stream it out. - -else { # file is binary, damn it - my $mime_type; - if ( $mime_type= - eval{ use MIME::Types; - my($type,$encoding)=MIME::Types::by_suffix($path); - $type; }) { - print $q->header($mime_type); - $path=~s/[\|\>\<\&]//g; - open F,"$RT::MasonComponentRoot/$path" or - die "couldn't open $path -- $!"; - print while ; - close F; - } else { - die "couldn't resolve type of non-text file (!@; $type) -- install Mime::Types\n"; - } - } - -# }}} +$h->handle_cgi_object($cgi); -untie %HTML::Mason::Commands::session; +1; diff --git a/rt/bin/rt b/rt/bin/rt deleted file mode 100755 index 41220bb56..000000000 --- a/rt/bin/rt +++ /dev/null @@ -1,1391 +0,0 @@ -#!!!PERL!! -w -# -# $Header: /home/cvs/cvsroot/freeside/rt/bin/Attic/rt,v 1.1 2002-08-12 06:17:07 ivan Exp $ -# RT is (c) 1996-2001 Jesse Vincent - -use strict; -use Carp; -use Getopt::Long; - -use lib "!!RT_LIB_PATH!!"; -use lib "!!RT_ETC_PATH!!"; - -use RT::Interface::CLI qw(CleanEnv LoadConfig DBConnect - GetCurrentUser GetMessageContent); - -#Clean out all the nasties from the environment -CleanEnv(); - -#Load etc/config.pm and drop privs -LoadConfig(); - -#Connect to the database and get RT::SystemUser and RT::Nobody loaded -DBConnect(); - -#Drop setgid permissions -RT::DropSetGIDPermissions(); - -#Get the current user all loaded -my $CurrentUser = GetCurrentUser(); - -unless ($CurrentUser->Id) { - print "No RT user found. Please consult your RT administrator.\n"; - exit(1); -} - - -# {{{ commandline flags - -my ( @id, - @limit_queue, - @limit_status, - @limit_owner, - @limit_priority, - @limit_final_priority, - @limit_requestor, - @limit_subject, - @limit_body, - @limit_created, - @limit_resolved, - @limit_lastupdated, - @limit_dependson, - @limit_dependedonby, - @limit_memberof, - @limit_hasmember, - @limit_refersto, - @limit_referredtoby, - @limit_keyword, - - @limit_due, - @limit_starts, - @limit_started, - $limit_first, - $limit_rows, - $history, - $summary, - $create, - @requestors, - @cc, - @admincc, - $status, - $subject, - $owner, - $steal, - $queue, - $time_left, - $priority, - $final_priority, - $due, - $starts, - $started, - $contacted, - $comment, - $reply, - $source, - $edit, - @dependson, - @memberof, - @refersto, - $mergeinto, - @keywords, - $time_taken, - $verbose, - $debug, - $help, - $version); - -# }}} - -# Set defaults for cli args - -$edit = 1; # Assume the user wants to edit replies and comments - # unless they specify --noedit - -# {{{ args - -my @args =("id=s" => \@id, - "limit-queue=s" => \@limit_queue, - "limit-status=s" => \@limit_status, - "limit-owner=s" => \@limit_owner, - "limit-priority=s" => \@limit_priority, - "limit-final-priority=s" => \@limit_final_priority, - "limit-requestor=s" => \@limit_requestor, - "limit-subject=s" => \@limit_subject, - "limit-body=s", \@limit_body, - "limit-created=s" => \@limit_created, - "limit-due=s" => \@limit_due, - "limit-last-updated=s" => \@limit_lastupdated, - "limit-keyword=s" => \@limit_keyword, - - "limit-member-of=s" => \@limit_memberof, - "limit-has-member=s" => \@limit_hasmember, - "limit-depended-on-by=s" => \@limit_dependedonby, - "limit-depends-on=s" => \@limit_dependson, - "limit-referred-to-by=s" => \@limit_referredtoby, - "limit-refers-to=s" => \@limit_refersto, - - "limit-starts=s" => \@limit_starts, - "limit-started=s" => \@limit_started, - "limit-first=i" => \$limit_first, - "limit-rows=i" => \$limit_rows, - "history|show" => \$history, - "summary:s" => \$summary, - "create" => \$create, - "keywords=s" => \@keywords, - "requestor|requestors=s" => \@requestors, - "cc=s" => \@cc, - "admincc=s" => \@admincc, - "status=s" => \$status, - "subject=s" => \$subject, - "owner=s" => \$owner, - "steal" => \$steal, - "queue=s" => \$queue, - - - "priority=i" => \$priority, - "final-priority=i" => \$final_priority, - "due=s" => \$due, - "starts=s" => \$starts, - "started=s" => \$started, - "contacted=s" => \$contacted, - "comment", \$comment, - "reply|respond", \$reply, - "source=s" => \$source, - "edit!" => \$edit, - "depends-on=s" => \@dependson, - "member-of=s" => \@memberof, - "merge-into=s" => \$mergeinto, - "refers-to=s" => \@refersto, - "time-left=i" => \$time_left, - "time-taken=i" => \$time_taken, - "verbose+" => \$verbose, - "debug" => \$debug, - "version" => \$version, - "help|h|usage" => \$help - ); - -# }}} - - - -GetOptions(@args); - -print join(':',@keywords); -# {{{ If they want it, print a usage message and get out - -if ($help) { - - -print < - --limit-status=[!](new|open|stalled|resolved) - - --limit-owner=[!] - --limit-priority=[starts][-][ends] - --limit-final-priority=[starts][-][ends] - starts is less than ends - --limit-requestor=[!]| - --limit-subject=[!] - --limit-body=[!] - --limit-keyword=[!]