Skip to content

Commit 019efba

Browse files
committed
Merge branch '4.4.7-releng' into 4.4-trunk
2 parents 2c63541 + 33e9203 commit 019efba

File tree

9 files changed

+48
-8
lines changed

9 files changed

+48
-8
lines changed

docs/web_deployment.pod

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@ B<WARNING: mod_perl 1.99_xx is not supported.>
171171
To run RT using mod_perl 1.xx please see L<Plack::Handler::Apache1> for
172172
configuration examples.
173173

174+
=head3 Restricting the REST 1.0 mail-gateway
175+
176+
RT processes email via a REST 1.0 endpoint. If you accept email on the same
177+
server as your running RT, you can restrict this endpoint to localhost only
178+
with a configuration like the following:
179+
180+
# Accept requests only from localhost
181+
<Location /REST/1.0/NoAuth/mail-gateway>
182+
Require local
183+
</Location>
184+
185+
If you run C<bin/rt-mailgate> on a separate server, you can update
186+
the above to allow additional IP addresses.
187+
188+
<Location /REST/1.0/NoAuth/mail-gateway>
189+
Require ip 127.0.0.1 ::1 192.0.2.0 # Add your actual IPs
190+
</Location>
191+
192+
See the L<Apache documentation|https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html>
193+
for additional configuration options.
194+
195+
After adding this configuration, test receiving email and confirm
196+
your C<bin/rt-mailgate> utility and C</etc/aliases> configurations
197+
can successfully submit email to RT.
174198

175199
=head2 nginx
176200

lib/RT/Interface/Email.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ sub Gateway {
159159
);
160160
}
161161

162+
# Clean up sensitive headers. Crypt related headers are cleaned up in RT::Interface::Email::Crypt::VerifyDecrypt
163+
my @headers = qw( RT-Attach RT-Send-Cc RT-Send-Bcc RT-Message-ID RT-DetectedAutoGenerated RT-Squelch-Replies-To );
164+
$Message->head->delete($_) for @headers;
165+
162166
#Set up a queue object
163167
my $SystemQueueObj = RT::Queue->new( RT->SystemUser );
164168
$SystemQueueObj->Load( $args{'queue'} );

lib/RT/Interface/Email/Crypt.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,14 @@ sub VerifyDecrypt {
7373
);
7474

7575
# we clean all possible headers
76-
my @headers =
76+
my @headers = (
7777
qw(
7878
X-RT-Incoming-Encryption
7979
X-RT-Incoming-Signature X-RT-Privacy
8080
X-RT-Sign X-RT-Encrypt
8181
),
82-
map "X-RT-$_-Status", RT::Crypt->Protocols;
82+
map "X-RT-$_-Status", RT::Crypt->Protocols
83+
);
8384
foreach my $p ( $args{'Message'}->parts_DFS ) {
8485
$p->head->delete($_) for @headers;
8586
}

share/html/REST/1.0/NoAuth/mail-gateway

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,18 @@ use RT::Interface::Email;
5959
$r->content_type('text/plain; charset=utf-8');
6060
$m->error_format('text');
6161
my ( $status, $error, $Ticket ) = RT::Interface::Email::Gateway( \%ARGS );
62+
63+
# Obscure the message to avoid any information disclosure unless
64+
# in DevelMode.
65+
my $log_error;
66+
unless ( RT->Config->Get('DevelMode') ) {
67+
$log_error = $error;
68+
$error = 'operation unsuccessful';
69+
}
70+
6271
if ( $status == 1 ) {
6372
$m->out("ok\n");
64-
if ( $Ticket && $Ticket->Id ) {
73+
if ( $Ticket && $Ticket->Id && RT->Config->Get('DevelMode') ) {
6574
$m->out( 'Ticket: ' . ($Ticket->Id || '') . "\n" );
6675
$m->out( 'Queue: ' . ($Ticket->QueueObj->Name || '') . "\n" );
6776
$m->out( 'Owner: ' . ($Ticket->OwnerObj->Name || '') . "\n" );
@@ -73,9 +82,11 @@ if ( $status == 1 ) {
7382
}
7483
else {
7584
if ( $status == -75 ) {
85+
RT->Logger->error("mail-gateway returned status -75: $log_error") if $log_error;
7686
$m->out( "temporary failure - $error\n" );
7787
}
7888
else {
89+
RT->Logger->error("mail-gateway error: $log_error") if $log_error;
7990
$m->out( "not ok - $error\n" );
8091
}
8192
}

t/mail/gateway.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use strict;
22
use warnings;
33

44

5-
use RT::Test config => 'Set( @MailPlugins, "Action::Take", "Action::Resolve");', tests => undef, actual_server => 1;
5+
use RT::Test config => 'Set( @MailPlugins, "Action::Take", "Action::Resolve"); Set($DevelMode, 1);', tests => undef, actual_server => 1;
66
my ($baseurl, $m) = RT::Test->started_ok;
77

88
use RT::Tickets;

t/mail/han-encodings.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33

4-
use RT::Test tests => undef, actual_server => 1;
4+
use RT::Test tests => undef, config => 'Set($DevelMode, 1);', actual_server => 1;
55

66
# we can't simply call Encode::HanExtra->require here because we are testing
77
# if Encode::HanExtra could be automatically loaded.

t/mail/sendmail-plaintext.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ for my $encoding ('ISO-8859-1', 'UTF-8') {
132132
{
133133
my ($ticket) = mail_in_ticket('rt-send-cc');
134134
my $cc = first_attach($ticket)->GetHeader('RT-Send-Cc');
135-
like ($cc, qr/test$_/, "Found test $_") for 1..5;
135+
ok (!$cc, "No RT-Send-Cc"); # RT-Send-Cc is supposed to be cleared
136136
}
137137

138138
{

t/mail/sendmail.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ for my $encoding ('ISO-8859-1', 'UTF-8') {
157157
{
158158
my ($ticket) = mail_in_ticket('rt-send-cc');
159159
my $cc = first_attach($ticket)->GetHeader('RT-Send-Cc');
160-
like ($cc, qr/test$_/, "Found test $_") for 1..5;
160+
ok (!$cc, "No RT-Send-Cc"); # RT-Send-Cc is supposed to be cleared
161161
}
162162

163163
{

t/ticket/interface.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33

4-
use RT::Test tests => undef, actual_server => 1;
4+
use RT::Test tests => undef, config => 'Set($DevelMode, 1);', actual_server => 1;
55

66
my ( $baseurl, $m ) = RT::Test->started_ok;
77

0 commit comments

Comments
 (0)