summaryrefslogtreecommitdiff
path: root/rt/bin
diff options
context:
space:
mode:
authorivan <ivan>2004-12-03 20:40:48 +0000
committerivan <ivan>2004-12-03 20:40:48 +0000
commitd39d52aac8f38ea9115628039f0df5aa3ac826de (patch)
treec77529c4e4dbb9bf832fcef14538dc16b2f7a110 /rt/bin
parentc582e92888b4a5553e1b4e5214cf35217e4a0cf0 (diff)
import rt 3.2.2
Diffstat (limited to 'rt/bin')
-rw-r--r--rt/bin/mason_handler.fcgi.in50
-rw-r--r--rt/bin/mason_handler.scgi.in49
-rw-r--r--rt/bin/mason_handler.svc.in45
-rw-r--r--rt/bin/rt-crontool.in84
-rw-r--r--rt/bin/rt-mailgate.in47
-rw-r--r--rt/bin/rt.in112
-rwxr-xr-xrt/bin/standalone_httpd.in192
-rw-r--r--rt/bin/webmux.pl.in116
8 files changed, 522 insertions, 173 deletions
diff --git a/rt/bin/mason_handler.fcgi.in b/rt/bin/mason_handler.fcgi.in
index 52dddd3d3..4a1abd36b 100644
--- a/rt/bin/mason_handler.fcgi.in
+++ b/rt/bin/mason_handler.fcgi.in
@@ -1,9 +1,15 @@
#!@PERL@
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,26 +21,40 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
#
-# END LICENSE BLOCK
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
+package RT::Mason;
use strict;
+use vars '$Handler';
use File::Basename;
require ('@RT_BIN_PATH@/webmux.pl');
-my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
-
# Enter CGI::Fast mode, which should also work as a vanilla CGI script.
require CGI::Fast;
RT::Init();
-RT::DropSetGIDPermissions();
-
while ( my $cgi = CGI::Fast->new ) {
# the whole point of fastcgi requires the env to get reset here..
@@ -47,12 +67,12 @@ while ( my $cgi = CGI::Fast->new ) {
RT::ConnectToDatabase();
- if ( ( !$h->interp->comp_exists( $cgi->path_info ) )
- && ( $h->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
+ if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
+ && ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
$cgi->path_info( $cgi->path_info . "/index.html" );
}
- eval { $h->handle_cgi_object($cgi); };
+ eval { $Handler->handle_cgi_object($cgi); };
if ($@) {
$RT::Logger->crit($@);
}
diff --git a/rt/bin/mason_handler.scgi.in b/rt/bin/mason_handler.scgi.in
index fdbf624f6..177ff00fd 100644
--- a/rt/bin/mason_handler.scgi.in
+++ b/rt/bin/mason_handler.scgi.in
@@ -1,9 +1,15 @@
#!@SPEEDY_BIN@
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,30 +21,45 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
#
+# CONTRIBUTION SUBMISSION POLICY:
#
-# END LICENSE BLOCK
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
+package RT::Mason;
use strict;
+use vars '$Handler';
require ('@RT_BIN_PATH@/webmux.pl');
-my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
-
require CGI;
RT::Init();
-RT::DropSetGIDPermissions();
my $cgi = CGI->new;
-if ( ( !$h->interp->comp_exists( $cgi->path_info ) )
- && ( $h->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
+if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
+ && ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
$cgi->path_info( $cgi->path_info . "/index.html" );
}
-$h->handle_cgi_object($cgi);
+$Handler->handle_cgi_object($cgi);
1;
diff --git a/rt/bin/mason_handler.svc.in b/rt/bin/mason_handler.svc.in
index 0ba1f51b5..d82f3c120 100644
--- a/rt/bin/mason_handler.svc.in
+++ b/rt/bin/mason_handler.svc.in
@@ -1,9 +1,15 @@
#!@PERL@
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,14 +21,29 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
-# END LICENSE BLOCK
-
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
=head1 NAME
mason_handler.svc - Win32 IIS Service handler for RT
@@ -55,8 +76,11 @@ registry setting will also be automatically populated.
=cut
+package RT::Mason;
+
use strict;
use File::Basename;
+use vars '$Handler';
require (dirname(__FILE__) . '/webmux.pl');
use Cwd;
@@ -197,7 +221,6 @@ BEGIN {
warn "Begin listening on $ENV{'FCGI_SOCKET_PATH'}\n";
require CGI::Fast;
-my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
RT::Init();
@@ -212,7 +235,7 @@ while( my $cgi = CGI::Fast->new ) {
warn "Serving $comp\n";
- $h->handle_cgi($comp);
+ $Handler->handle_cgi($comp);
# _should_ always be tied
}
diff --git a/rt/bin/rt-crontool.in b/rt/bin/rt-crontool.in
index 45f9aefab..6b95d8dc5 100644
--- a/rt/bin/rt-crontool.in
+++ b/rt/bin/rt-crontool.in
@@ -1,9 +1,15 @@
#!@PERL@
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,14 +21,29 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
-# END LICENSE BLOCK
-
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
use strict;
use Carp;
@@ -45,9 +66,6 @@ RT::LoadConfig();
#Connect to the database and get RT::SystemUser and RT::Nobody loaded
RT::Init();
-#Drop setgid permissions
-RT::DropSetGIDPermissions();
-
#Get the current user all loaded
my $CurrentUser = GetCurrentUser();
@@ -78,15 +96,19 @@ load_module($condition) if ($condition);
# load template if specified
my $template_obj;
if ($template_id) {
- $template_obj = RT::Template->new($RT::Nobody);
- $template_obj->LoadById($template_id);
+ $template_obj = RT::Template->new($CurrentUser);
+ $template_obj->Load($template_id);
}
#At the appointed time:
#find a bunch of tickets
my $tickets = RT::Tickets->new($CurrentUser);
-my $search = $search->new( TicketsObj => $tickets, Argument => $search_arg );
+my $search = $search->new(
+ TicketsObj => $tickets,
+ Argument => $search_arg,
+ CurrentUser => $CurrentUser
+);
$search->Prepare();
@@ -95,12 +117,13 @@ my $tickets = $search->TicketsObj;
#for each ticket we've found
while ( my $ticket = $tickets->Next() ) {
- print "\n" . $ticket->Id() . ": " if ($verbose);
+ print $ticket->Id() . ": " if ($verbose);
# perform some more advanced check
if ($condition) {
my $condition_obj = $condition->new( TicketObj => $ticket,
- Argument => $condition_arg );
+ Argument => $condition_arg,
+ CurrentUser => $CurrentUser );
# if the condition doesn't apply, get out of here
@@ -109,9 +132,12 @@ while ( my $ticket = $tickets->Next() ) {
}
#prepare our action
- my $action_obj = $action->new( TicketObj => $ticket,
- TemplateObj => $template_obj,
- Argument => $action_arg );
+ my $action_obj = $action->new(
+ TicketObj => $ticket,
+ TemplateObj => $template_obj,
+ Argument => $action_arg,
+ CurrentUser => $CurrentUser
+ );
#if our preparation, move onto the next ticket
next unless ( $action_obj->Prepare );
@@ -119,7 +145,7 @@ while ( my $ticket = $tickets->Next() ) {
#commit our action.
next unless ( $action_obj->Commit );
- print loc("Action committed.") if ($verbose);
+ print loc("Action committed.\n") if ($verbose);
}
# {{{ load_module
@@ -197,19 +223,17 @@ sub help {
)
. "\n\n";
- print " bin/rt-cron-tool \\\n";
- print
- " --search RT::Search::ActiveTicketsInQueue --search-arg general \\\n";
- print
- " --condition RT::Condition::UntouchedInHours --condition-arg 4 \\\n";
+ print " bin/rt-crontool \\\n";
+ print " --search RT::Search::ActiveTicketsInQueue --search-arg general \\\n";
+ print " --condition RT::Condition::UntouchedInHours --condition-arg 4 \\\n";
print " --action RT::Action::SetPriority --action-arg 99 \\\n";
print " --verbose\n";
print "\n";
- print loc("Escalate tickets");
- print "rt-crontool \\\n";
- print " --search RT::Search::ActiveTicketsInQueue --search-arg thequeuename \\\n";
- print " --action RT::Action::EscalatePriority \\\n";
+ print loc("Escalate tickets"). "\n";
+ print " bin/rt-crontool \\\n";
+ print " --search RT::Search::ActiveTicketsInQueue --search-arg general \\\n";
+ print " --action RT::Action::EscalatePriority\n";
diff --git a/rt/bin/rt-mailgate.in b/rt/bin/rt-mailgate.in
index 2ddb604ec..a37364ffb 100644
--- a/rt/bin/rt-mailgate.in
+++ b/rt/bin/rt-mailgate.in
@@ -1,9 +1,15 @@
#!@PERL@ -w
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,13 +21,29 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
#
-# END LICENSE BLOCK
+# }}} END BPS TAGGED BLOCK
=head1 NAME
@@ -49,7 +71,7 @@ is ( $? >> 8, 75, "The error message above is expected The mail gateway exited w
# {{{ Test new ticket creation by root who is privileged and superuser
-ok(open(MAIL, "|@RT_BIN_PATH@/rt-mailgate --url http://localhost".$RT::WebPath."/ --queue general --action correspond"), "Opened the mailgate - $@");
+ok(open(MAIL, "|@RT_BIN_PATH@/rt-mailgate --debug --url http://localhost".$RT::WebPath."/ --queue general --action correspond"), "Opened the mailgate - $@");
print MAIL <<EOF;
From: root\@localhost
To: rt\@example.com
@@ -165,6 +187,8 @@ $u = RT::User->new($RT::SystemUser);
$u->Load('doesnotexist-2@example.com');
ok( $u->Id == 0, " user does not exist and was not created by ticket correspondence submission");
# }}}
+
+
# {{{ can another random reply to a ticket after being granted privs? answer should be yes
@@ -294,6 +318,7 @@ my $attachments = RT::Attachments->new($RT::SystemUser);
$attachments->Limit(FIELD => 'ContentType', VALUE => 'image/gif');
ok ($attachments->Count == 1, 'Found only one gif in the database');
my $attachment = $attachments->First;
+ok($attachment->Id);
my $acontent = $attachment->Content;
warn "coming from the database, the content is ".Digest::MD5::md5_base64($acontent);
@@ -433,6 +458,10 @@ my %args = (
# Read the message in from STDIN
$args{'message'} = <>;
+unless ( $args{message} =~ /\S/ ) {
+ print STDERR "$0: no message passed on STDIN!\n";
+ exit 0;
+}
if ($opts{'extension'}) {
$args{$opts{'extension'}} = $ENV{'EXTENSION'};
diff --git a/rt/bin/rt.in b/rt/bin/rt.in
index b44e04158..86c83ca50 100644
--- a/rt/bin/rt.in
+++ b/rt/bin/rt.in
@@ -1,9 +1,15 @@
#!@PERL@ -w
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,14 +21,29 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
-# END LICENSE BLOCK
-
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
use strict;
# This program is intentionally written to have as few non-core module
@@ -30,6 +51,7 @@ use strict;
use Cwd;
use LWP;
+use Text::ParseWords;
use HTTP::Request::Common;
# We derive configuration information from hardwired defaults, dotfiles,
@@ -77,6 +99,7 @@ my $idlist = '(?:(?:\d+-)?\d+,)*(?:\d+-)?\d+';
my %handlers = (
# handler => [ ...aliases... ],
version => ["version", "ver"],
+ shell => ["shell"],
logout => ["logout"],
help => ["help", "man"],
show => ["show", "cat"],
@@ -88,18 +111,25 @@ my %handlers = (
grant => ["grant", "revoke"],
);
-# Once we find and call an appropriate handler, we're done.
-
-my (%actions, $action);
+my %actions;
foreach my $fn (keys %handlers) {
foreach my $alias (@{ $handlers{$fn} }) {
$actions{$alias} = \&{"$fn"};
}
}
-if (@ARGV && exists $actions{$ARGV[0]}) {
- $action = shift @ARGV;
+
+# Once we find and call an appropriate handler, we're done.
+
+sub handler {
+ my $action;
+
+ if (@ARGV && exists $actions{$ARGV[0]}) {
+ $action = shift @ARGV;
+ }
+ $actions{$action || "help"}->($action || ());
}
-$actions{$action || "help"}->($action || ());
+
+handler();
exit;
# Handler functions.
@@ -107,6 +137,20 @@ exit;
#
# The following subs are handlers for each entry in %actions.
+sub shell {
+ $|=1;
+ print "rt> ";
+ while (<>) {
+ chomp;
+ next if /^#/ || /^\s*$/;
+
+ @ARGV = shellwords($_);
+ handler();
+ print "rt> ";
+ }
+ print "\n";
+}
+
sub version {
print "rt $VERSION\n";
}
@@ -115,19 +159,22 @@ sub logout {
submit("$REST/logout") if defined $session->cookie;
}
+my %help;
sub help {
my ($action, $type) = @_;
- my (%help, $key);
+ my $key;
# What help topics do we know about?
- local $/ = undef;
- foreach my $item (@{ Form::parse(<DATA>) }) {
- my $title = $item->[2]{Title};
- my @titles = ref $title eq 'ARRAY' ? @$title : $title;
+ if (!%help) {
+ local $/ = undef;
+ foreach my $item (@{ Form::parse(<DATA>) }) {
+ my $title = $item->[2]{Title};
+ my @titles = ref $title eq 'ARRAY' ? @$title : $title;
foreach $title (grep $_, @titles) {
$help{$title} = $item->[2]{Text};
}
+ }
}
# What does the user want help with?
@@ -168,7 +215,9 @@ sub help {
# Displays a list of objects that match some specified condition.
sub list {
- my ($q, $type, %data, $orderby);
+ my ($q, $type, %data);
+ my $orderby = $config{orderby};
+
if ($config{orderby}) {
$data{orderby} = $config{orderby};
}
@@ -205,7 +254,6 @@ sub list {
$bad = 1; last;
}
}
-
if (!defined $q) {
$q = $config{query};
}
@@ -460,7 +508,7 @@ sub edit {
if ($output) {
print $text;
- exit;
+ return;
}
my $synerr = 0;
@@ -486,7 +534,7 @@ EDIT:
}
else {
print $r->content;
- exit -1;
+ return;
}
}
print $r->content;
@@ -515,7 +563,7 @@ sub comment {
if (/-a/) {
unless (-f $ARGV[0] && -r $ARGV[0]) {
whine "Cannot read attachment: '$ARGV[0]'.";
- exit -1;
+ return;
}
push @files, shift @ARGV;
}
@@ -560,6 +608,7 @@ sub comment {
Attachment => [ @files ],
TimeWorked => $wtime || '',
Text => $msg || '',
+ Status => ''
}
];
@@ -571,7 +620,7 @@ sub comment {
do {
my $ntext = vi($text);
- exit if ($error && $ntext eq $text);
+ return if ($error && $ntext eq $text);
$text = $ntext;
$form = Form::parse($text);
$error = 0;
@@ -583,7 +632,7 @@ sub comment {
goto NEXT;
}
elsif (!@$o) {
- exit;
+ return;
}
@files = @{ vsplit($k->{Attachment}) };
@@ -659,7 +708,7 @@ sub link {
$bad = 1;
}
unless (exists $ltypes{lc $rel}) {
- whine "Invalid relationship '$rel' specified.";
+ whine "Invalid link '$rel' specified.";
$bad = 1;
}
%data = (id => $from, rel => $rel, to => $to, del => $del);
@@ -1122,6 +1171,7 @@ sub config_from_file {
sub parse_config_file {
my %cfg;
my ($file) = @_;
+ local $_; # $_ may be aliased to a constant, from line 1163
open(CFG, $file) && do {
while (<CFG>) {
@@ -1741,16 +1791,16 @@ Text:
Syntax:
- rt link [-d] <id-A> <relationship> <id-B>
+ rt link [-d] <id-A> <link> <id-B>
Creates (or, with -d, deletes) a link between the specified tickets.
- The relationship can (irrespective of case) be any of:
+ The link can (irrespective of case) be any of:
DependsOn/DependedOnBy: A depends upon B (or vice versa).
RefersTo/ReferredToBy: A refers to B (or vice versa).
MemberOf/HasMember: A is a member of B (or vice versa).
- To view a ticket's relationships, use "rt show ticket/3/links". (See
+ To view a ticket's links, use "rt show ticket/3/links". (See
"rt help ticket" and "rt help show".)
Options:
diff --git a/rt/bin/standalone_httpd.in b/rt/bin/standalone_httpd.in
new file mode 100755
index 000000000..bf449455c
--- /dev/null
+++ b/rt/bin/standalone_httpd.in
@@ -0,0 +1,192 @@
+#!@PERL@ -w
+# {{{ BEGIN BPS TAGGED BLOCK
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
+package RT::Mason;
+
+use strict;
+use vars '$Handler';
+
+require ('@RT_BIN_PATH@/webmux.pl');
+
+use lib( "@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");
+
+use Socket;
+
+RT::Init();
+
+my $port = shift || '8080';
+
+main_loop($port);
+
+sub main_loop {
+ my $port = shift;
+ my $tcp = getprotobyname('tcp');
+
+ socket( HTTPDaemon, PF_INET, SOCK_STREAM, $tcp ) or die "socket: $!";
+ setsockopt( HTTPDaemon, SOL_SOCKET, SO_REUSEADDR, pack( "l", 1 ) )
+ or warn "setsockopt: $!";
+ bind( HTTPDaemon, sockaddr_in( $port, INADDR_ANY ) ) or die "bind: $!";
+ listen( HTTPDaemon, SOMAXCONN ) or die "listen: $!";
+
+ print("You can connect to your RT server at http://localhost:$port/\n");
+
+ while (1) {
+
+ for ( ; accept( Remote, HTTPDaemon ); close Remote ) {
+
+ *STDIN = *Remote;
+ *STDOUT = *Remote;
+
+ my $remote_sockaddr = getpeername(STDIN);
+ my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr);
+ my $peername = gethostbyaddr( $iaddr, AF_INET ) || "localhost";
+ my $peeraddr = inet_ntoa($iaddr) || "127.0.0.1";
+
+ my $local_sockaddr = getsockname(STDIN);
+ my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr);
+ my $localname = gethostbyaddr( $localiaddr, AF_INET )
+ || "localhost";
+ my $localaddr = inet_ntoa($localiaddr) || "127.0.0.1";
+
+ chomp( $_ = <STDIN> );
+ my ( $method, $request_uri, $proto, undef ) = split;
+
+ #$request_uri =~ s#\\#/#g;
+ $RT::Logger->info("<- $peername: $_");
+ my ( $file, undef, $query_string ) =
+ ( $request_uri =~ /([^?]*)(\?(.*))?/ ); # split at ?
+ #$file =~ s/%([\dA-Fa-f]{2})/chr(hex($1))/eg; # decode url-escaped entities
+
+ last if ( $method !~ /^(GET|POST|HEAD)$/ );
+
+ build_cgi_env( method => $method,
+ query_string => $query_string,
+ path => $file,
+ method => $method,
+ port => $port,
+ peername => $peername,
+ peeraddr => $peeraddr,
+ localname => $localname,
+ request_uri => $request_uri );
+
+ RT::ConnectToDatabase();
+ my $cgi = CGI->new();
+
+ print "HTTP/1.0 200 OK\n"; # probably OK by now
+
+ if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
+ && ($Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) )
+ ) {
+ $cgi->path_info( $cgi->path_info . "/index.html" );
+ }
+
+ eval { $Handler->handle_cgi_object($cgi); };
+ $RT::Logger->crit($@) if ($@);
+
+ if ( $RT::Handle->TransactionDepth ) {
+ $RT::Handle->ForceRollback;
+ $RT::Logger->crit( "Transaction not committed. Usually indicates a software fault. Data loss may have occurred");
+ }
+
+ }
+
+ }
+
+}
+
+
+
+sub build_cgi_env {
+ my %args = ( query_string => '',
+ path => '',
+ port => undef,
+ protocol => undef,
+ localname => undef,
+ method => undef,
+ remote_name => undef,
+
+
+ @_);
+
+ foreach my $var qw(USER_AGENT CONTENT_LENGTH CONTENT_TYPE
+ COOKIE SERVER_PORT SERVER_PROTOCOL SERVER_NAME
+ PATH_INFO REQUEST_URI REQUEST_METHOD REMOTE_ADDR
+ REMOTE_HOST QUERY_STRING SERVER_SOFTWARE) {
+ delete $ENV{$var};
+ }
+ while (<STDIN>) {
+ s/[\r\l\n\s]+$//;
+ if( /^([\w\-]+): (.+)/i) {
+ my $tag = uc($1);
+ $tag =~ s/^COOKIES$/COOKIE/;
+ my $val = $2;
+ $tag =~ s/-/_/g;
+ $tag = "HTTP_".$tag unless (grep /^$tag$/, qw(CONTENT_LENGTH CONTENT_TYPE COOKIE));
+ if ($ENV{$tag}) {
+ $ENV{$tag} .= "; $val";
+ }
+ else {
+ $ENV{$tag} = $val;
+ }
+ }
+ last if (/^$/);
+ }
+
+
+ $ENV{SERVER_PROTOCOL} = $args{protocol};
+ $ENV{SERVER_PORT} = $args{port};
+ $ENV{SERVER_NAME} = $args{'localname'};
+ $ENV{SERVER_URL} = "http://".$args{'localname'}.":".$args{'port'}."/";
+ $ENV{PATH_INFO} = $args{'path'};
+ $ENV{REQUEST_URI} = $args{'request_uri'};
+ $ENV{REQUEST_METHOD} = $args{method};
+ $ENV{REMOTE_ADDR} = $args{'peeraddr'};
+ $ENV{REMOTE_HOST} = $args{'peername'};
+ $ENV{QUERY_STRING} = $args{'query_string'};
+ $ENV{SERVER_SOFTWARE} = "rt-standalone/$RT::VERSION";
+
+ CGI::initialize_globals();
+}
diff --git a/rt/bin/webmux.pl.in b/rt/bin/webmux.pl.in
index 2c8487c0d..877948960 100644
--- a/rt/bin/webmux.pl.in
+++ b/rt/bin/webmux.pl.in
@@ -1,9 +1,15 @@
#!@PERL@
-# BEGIN LICENSE BLOCK
+# {{{ BEGIN BPS TAGGED BLOCK
#
-# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
#
-# (Except where explictly superceded by other copyright notices)
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
#
# 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
@@ -15,30 +21,46 @@
# 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.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
-# END LICENSE BLOCK
-
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# }}} END BPS TAGGED BLOCK
use strict;
BEGIN {
- $ENV{'PATH'} = '/bin:/usr/bin'; # or whatever you need
+ $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'};
- @ORACLE_ENV_PREF@
- eval { require Apache2; require Apache::compat }
- if $ENV{'MOD_PERL'} and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
+ eval { require Apache2; require APR::Table; require MasonX::Apache2Handler; 1 } or
+ eval { require Apache2; require Apache::compat; 1 } or die $@
+ if $ENV{'MOD_PERL'}
+ and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
}
-use lib ("@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");
+use lib ( "@LOCAL_LIB_PATH@", "@RT_LIB_PATH@" );
use RT;
package RT::Mason;
@@ -46,29 +68,9 @@ package RT::Mason;
use CGI qw(-private_tempfiles); #bring this in before mason, to make sure we
#set private_tempfiles
-BEGIN {
- if ($mod_perl::VERSION >= 1.9908) {
- require Apache::RequestUtil;
- no warnings 'redefine';
- my $sub = *Apache::request{CODE};
- *Apache::request = sub {
- my $r;
- eval { $r = $sub->('Apache'); };
- # warn $@ if $@;
- return $r;
- };
- }
- if ($CGI::MOD_PERL) {
- require HTML::Mason::ApacheHandler;
- }
- else {
- require HTML::Mason::CGIHandler;
- }
-}
-
-use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
+use HTML::Mason; # brings in subpackages: Parser, Interp, etc.
-use vars qw($Nobody $SystemUser $r);
+use vars qw($Nobody $SystemUser $Handler $r);
#This drags in RT's config.pm
RT::LoadConfig();
@@ -76,6 +78,7 @@ RT::LoadConfig();
use Carp;
{
+
package HTML::Mason::Commands;
use vars qw(%session);
@@ -100,27 +103,12 @@ use Carp;
use CGI::Cookie;
use Time::ParseDate;
use HTML::Entities;
+ use HTML::Scrubber;
+ use Text::Quoted;
}
-
-# Activate the following if running httpd as root (the normal case).
-# Resets ownership of all files created by Mason at startup.
-# Note that mysql uses DB for sessions, so there's no need to do this.
-unless ($RT::DatabaseType =~ /(mysql|Pg)/) {
- # Clean up our umask to protect session files
- umask(0077);
-
-if ( $CGI::MOD_PERL) {
- chown( Apache->server->uid, Apache->server->gid, [$RT::MasonSessionDir] )
- if Apache->server->can('uid');
- }
- # 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 _ ) );
-}
-
-my $ah = &RT::Interface::Web::NewApacheHandler(@RT::MasonParameters) if $CGI::MOD_PERL;
+use RT::Interface::Web::Handler;
+$Handler = RT::Interface::Web::Handler->new(@RT::MasonParameters);
sub handler {
($r) = @_;
@@ -130,21 +118,23 @@ sub handler {
RT::Init();
- # We don't need to handle non-text items
- return -1 if defined( $r->content_type ) && $r->content_type !~ m|^text/|io;
+ # We don't need to handle non-text, non-xml items
+ return -1 if defined( $r->content_type ) && $r->content_type !~ m!(^text/|\bxml\b)!io;
my %session;
my $status;
- eval { $status = $ah->handle_request($r) };
+ eval { $status = $Handler->handle_request($r) };
if ($@) {
- $RT::Logger->crit($@);
+ $RT::Logger->crit($@);
}
- undef (%session);
+ undef(%session);
- if ($RT::Handle->TransactionDepth) {
- $RT::Handle->ForceRollback;
- $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;
+ if ( $RT::Handle->TransactionDepth ) {
+ $RT::Handle->ForceRollback;
+ $RT::Logger->crit(
+"Transaction not committed. Usually indicates a software fault. Data loss may have occurred"
+ );
}
return $status;
}