[Rt-commit] rt branch, 4.0/die-on-perl-script-handler, created. rt-4.0.10-79-g033dd96

Jim Brandt jbrandt at bestpractical.com
Fri Mar 15 15:02:23 EDT 2013


The branch, 4.0/die-on-perl-script-handler has been created
        at  033dd9655ca319d44cc19e4b9cdaedc93fdb5119 (commit)

- Log -----------------------------------------------------------------
commit 033dd9655ca319d44cc19e4b9cdaedc93fdb5119
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu May 24 14:42:01 2012 -0400

    Die when detecting SetHandler perl-script

diff --git a/docs/UPGRADING-4.0 b/docs/UPGRADING-4.0
index f884c52..b95610b 100644
--- a/docs/UPGRADING-4.0
+++ b/docs/UPGRADING-4.0
@@ -24,9 +24,13 @@ following to remove the _Overlay files:
     find /opt/rt3/lib/ -type f -name '*_Overlay*' -delete
 
 RT has also changed how web deployment works; you will need to review
-docs/web_deployment.pod for current instructions.  The old `fastcgi_server`,
-`webmux.pl`, and `mason_handler.*` files will not work with RT 4.0, and should
-be removed to reduce confusion.
+F<docs/web_deployment.pod> for current instructions.  The old
+`fastcgi_server`, `webmux.pl`, and `mason_handler.*` files will not
+work with RT 4.0, and should be removed to reduce confusion.
+
+If you deploy RT with mod_perl, Apache will no longer start with C<SetHandler>
+set to `perl-script`. F<docs/web_deployment.pod> contains the
+new configuration.
 
 
 =head2 RT_SiteConfig.pm
diff --git a/docs/web_deployment.pod b/docs/web_deployment.pod
index 355f6ce..5a9bd93 100644
--- a/docs/web_deployment.pod
+++ b/docs/web_deployment.pod
@@ -114,8 +114,9 @@ deployment if your privileged users are in a different timezone than the
 one the server is configured for.
 
 B<NOTE>: RT 3.8 and below suggested use of C<SetHandler perl-script>;
-this is incorrect for RT 4, and will lead to difficulties sending
-outgoing mail from RT.  Ensure that you use C<SetHandler modperl>.
+this is incorrect for RT 4, and (starting in RT 4.0.11) RT will refuse
+to start, to prevent difficulties sending mail from RT.  Change to
+C<SetHandler modperl>, as the example below uses.
 
     <VirtualHost rt.example.com>
         ### Optional apache logs for RT
diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index 32c877e..3fa28f1 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -209,6 +209,35 @@ sub HTML::Mason::Exception::as_rt_error {
     return "An internal RT error has occurred.  Your administrator can find more details in RT's log files.";
 }
 
+=head1 CheckModPerlHandler
+
+Make sure we're not running with SetHandler perl-script.
+
+=cut
+
+sub CheckModPerlHandler{
+    my $self = shift;
+    my $env = shift;
+
+    # Plack::Handler::Apache2 masks MOD_PERL, so use MOD_PERL_API_VERSION
+    return unless( $env->{'MOD_PERL_API_VERSION'}
+                   and $env->{'MOD_PERL_API_VERSION'} == 2);
+
+    my $handler = $env->{'psgi.input'}->handler;
+
+    die <<MODPERL if defined $handler && $handler eq 'perl-script';
+RT has problems when SetHandler is set to perl-script.
+Change SetHandler in your in httpd.conf to:
+
+    SetHandler modperl
+
+For a complete example mod_perl configuration, see:
+
+https://bestpractical.com/rt/docs/@{[$RT::VERSION =~ /^(\d\.\d)/]}/web_deployment.html#mod_perl-2.xx
+MODPERL
+
+    return;
+}
 
 # PSGI App
 
@@ -231,6 +260,9 @@ sub PSGIApp {
 
     return sub {
         my $env = shift;
+
+        $self->CheckModPerlHandler($env);
+
         RT::ConnectToDatabase() unless RT->InstallMode;
 
         my $req = Plack::Request->new($env);

-----------------------------------------------------------------------


More information about the Rt-commit mailing list