summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla.pm32
-rw-r--r--Bugzilla/Attachment/PatchReader.pm15
-rw-r--r--Bugzilla/CGI.pm31
-rw-r--r--Bugzilla/CPAN.pm2
-rw-r--r--Bugzilla/Constants.pm3
-rw-r--r--Bugzilla/DaemonControl.pm39
-rw-r--r--Bugzilla/Error.pm4
-rw-r--r--Bugzilla/Install/Filesystem.pm130
-rw-r--r--Bugzilla/ModPerl.pm118
-rw-r--r--Bugzilla/ModPerl/BasicAuth.pm65
-rw-r--r--Bugzilla/ModPerl/BlockIP.pm65
-rw-r--r--Bugzilla/ModPerl/StartupFix.pm51
-rw-r--r--Bugzilla/Quantum.pm199
-rw-r--r--Bugzilla/Quantum/CGI.pm161
-rw-r--r--Bugzilla/Quantum/Plugin/BlockIP.pm43
-rw-r--r--Bugzilla/Quantum/Plugin/Glue.pm112
-rw-r--r--Bugzilla/Quantum/Plugin/Hostage.pm (renamed from Bugzilla/ModPerl/Hostage.pm)51
-rw-r--r--[-rwxr-xr-x]Bugzilla/Quantum/SES.pm (renamed from ses/index.cgi)0
-rw-r--r--Bugzilla/Quantum/Static.pm30
-rw-r--r--Bugzilla/Quantum/Stdout.pm42
-rw-r--r--Bugzilla/Quantum/Template.pm39
-rw-r--r--Bugzilla/Template.pm6
-rw-r--r--Bugzilla/WebService/Server/XMLRPC.pm6
-rw-r--r--Bugzilla/WebService/Util.pm8
-rw-r--r--Dockerfile9
-rw-r--r--Log/Log4perl/Layout/Mozilla.pm3
-rwxr-xr-xMakefile.PL14
-rw-r--r--README.rst35
-rwxr-xr-xbuglist.cgi6
-rwxr-xr-xbugzilla.pl20
-rwxr-xr-xchecksetup.pl3
-rwxr-xr-xcolchange.cgi16
-rw-r--r--conf/log4perl-test.conf4
-rw-r--r--docker-compose.yml1
-rwxr-xr-xheartbeat.cgi8
-rw-r--r--mod_perl.pl200
-rwxr-xr-xscripts/block-ip.pl10
-rwxr-xr-xscripts/entrypoint.pl1
-rwxr-xr-xscripts/rewrite2mojo.pl70
-rwxr-xr-x[-rw-r--r--]scripts/undo.pl0
-rw-r--r--t/001compile.t14
-rw-r--r--t/002goodperl.t7
-rw-r--r--template/en/default/global/header.html.tmpl2
-rw-r--r--vagrant_support/apache.yml8
-rwxr-xr-xvagrant_support/hypnotoad121
-rw-r--r--vagrant_support/hypnotoad.yml27
-rw-r--r--vagrant_support/playbook.yml3
-rw-r--r--vagrant_support/update.yml5
48 files changed, 1017 insertions, 822 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 3d7cb50d5..f6c9abad2 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -13,16 +13,7 @@ use warnings;
use Bugzilla::Logging;
-# We want any compile errors to get to the browser, if possible.
-BEGIN {
- # This makes sure we're in a CGI.
- if ($ENV{SERVER_SOFTWARE} && !$ENV{MOD_PERL}) {
- require CGI::Carp;
- CGI::Carp->import('fatalsToBrowser');
- }
-}
-
-our $VERSION = '20180703.1';
+our $VERSION = '5.13';
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
@@ -189,8 +180,17 @@ sub init_page {
# Subroutines and Methods
#####################################################################
+my $preload_templates = 0;
+sub preload_templates {
+ $preload_templates = 1;
+
+ delete request_cache->{template};
+ template();
+ return 1;
+}
+
sub template {
- request_cache->{template} ||= Bugzilla::Template->create();
+ request_cache->{template} //= Bugzilla::Template->create(preload => $preload_templates);
request_cache->{template}->{_is_main} = 1;
return request_cache->{template};
@@ -201,7 +201,8 @@ sub template_inner {
my $cache = request_cache;
my $current_lang = $cache->{template_current_lang}->[0];
$lang ||= $current_lang || '';
- return $cache->{"template_inner_$lang"} ||= Bugzilla::Template->create(language => $lang);
+ my %options = (language => $lang, preload => $preload_templates);
+ return $cache->{"template_inner_$lang"} ||= Bugzilla::Template->create(%options);
}
sub extensions {
@@ -240,7 +241,7 @@ sub has_extension {
}
sub cgi {
- return request_cache->{cgi} ||= new Bugzilla::CGI();
+ return request_cache->{cgi} ||= Bugzilla::CGI->new;
}
sub input_params {
@@ -353,9 +354,6 @@ sub login {
return $class->user if $class->user->id;
- # Load all extensions here if not running under mod_perl
- $class->extensions unless BZ_PERSISTENT;
-
my $authorizer = new Bugzilla::Auth();
$type = LOGIN_REQUIRED if $class->cgi->param('GoAheadAndLogIn');
@@ -816,7 +814,7 @@ sub check_rate_limit {
my $limit = join("/", @$limit);
Bugzilla->audit("[rate_limit] action=$action, ip=$ip, limit=$limit, name=$name");
if ($action eq 'block') {
- Bugzilla::ModPerl::BlockIP->block_ip($ip);
+ $Bugzilla::Quantum::CGI::C->block_ip($ip);
ThrowUserError("rate_limit");
}
}
diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm
index 2cfbf2c6b..8025f5b82 100644
--- a/Bugzilla/Attachment/PatchReader.pm
+++ b/Bugzilla/Attachment/PatchReader.pm
@@ -116,18 +116,9 @@ sub process_interdiff {
$ENV{'PATH'} = $lc->{diffpath};
my ($pid, $interdiff_stdout, $interdiff_stderr);
- if ($ENV{MOD_PERL}) {
- require Apache2::RequestUtil;
- require Apache2::SubProcess;
- my $request = Apache2::RequestUtil->request;
- (undef, $interdiff_stdout, $interdiff_stderr) = $request->spawn_proc_prog(
- $lc->{interdiffbin}, [$old_filename, $new_filename]
- );
- } else {
- $interdiff_stderr = gensym;
- my $pid = open3(gensym, $interdiff_stdout, $interdiff_stderr,
- $lc->{interdiffbin}, $old_filename, $new_filename);
- }
+ $interdiff_stderr = gensym;
+ $pid = open3(gensym, $interdiff_stdout, $interdiff_stderr,
+ $lc->{interdiffbin}, $old_filename, $new_filename);
binmode $interdiff_stdout;
# Check for errors
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm
index a69bdd278..e50b394fb 100644
--- a/Bugzilla/CGI.pm
+++ b/Bugzilla/CGI.pm
@@ -119,7 +119,7 @@ sub new {
# Under mod_perl, CGI's global variables get reset on each request,
# so we need to set them up again every time.
- $class->_init_bz_cgi_globals() if BZ_PERSISTENT;
+ $class->_init_bz_cgi_globals();
my $self = $class->SUPER::new(@args);
@@ -477,11 +477,6 @@ sub _prevent_unsafe_response {
print $self->SUPER::header(-type => 'text/html', -status => '403 Forbidden');
if ($content_type ne 'text/html') {
print "Untrusted Referer Header\n";
- if ($ENV{MOD_PERL}) {
- my $r = $self->r;
- $r->rflush;
- $r->status(200);
- }
}
exit;
}
@@ -599,8 +594,25 @@ sub header {
$headers{'-link'} .= ', <https://www.google-analytics.com>; rel="preconnect"; crossorigin';
}
}
-
- return $self->SUPER::header(%headers) || "";
+ my $headers = $self->SUPER::header(%headers) || '';
+ if ($self->server_software eq 'Bugzilla::Quantum::CGI') {
+ my $c = $Bugzilla::Quantum::CGI::C;
+ $c->res->headers->parse($headers);
+ my $status = $c->res->headers->status;
+ if ($status && $status =~ /^([0-9]+)/) {
+ $c->res->code($1);
+ }
+ elsif ($c->res->headers->location) {
+ $c->res->code(302);
+ }
+ else {
+ $c->res->code(200);
+ }
+ return '';
+ }
+ else {
+ return $headers;
+ }
}
sub param {
@@ -787,9 +799,6 @@ sub redirect_to_https {
# and do not work with 302. Our redirect really is permanent anyhow, so
# it doesn't hurt to make it a 301.
print $self->redirect(-location => $url, -status => 301);
-
- # When using XML-RPC with mod_perl, we need the headers sent immediately.
- $self->r->rflush if $ENV{MOD_PERL};
exit;
}
diff --git a/Bugzilla/CPAN.pm b/Bugzilla/CPAN.pm
index d765d2901..1b6fb93b9 100644
--- a/Bugzilla/CPAN.pm
+++ b/Bugzilla/CPAN.pm
@@ -103,7 +103,7 @@ sub feature {
my $meta = $class->cpan_meta;
my $feature = $meta->feature($feature_name);
my @modules = $feature->prereqs->merged_requirements(['runtime'], ['requires'])->required_modules;
- Module::Runtime::require_module($_) foreach @modules;
+ Module::Runtime::require_module($_) foreach grep { !/^Test::Taint$/ } @modules;
return $FEATURE_LOADED{$feature_name} = 1;
}
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 0b0c857a0..d71ec25ee 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -15,6 +15,7 @@ use base qw(Exporter);
# For bz_locations
use File::Basename;
+use Cwd qw(realpath);
use Memoize;
@Bugzilla::Constants::EXPORT = qw(
@@ -651,7 +652,7 @@ sub _bz_locations {
#
# On mod_cgi this will be a relative path. On mod_perl it will be an
# absolute path.
- my $libpath = dirname(dirname($INC{'Bugzilla/Constants.pm'}));
+ my $libpath = realpath(dirname(dirname(__FILE__)));
# We have to detaint $libpath, but we can't use Bugzilla::Util here.
$libpath =~ /(.*)/;
$libpath = $1;
diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm
index 2c6df1b87..d0d6af8f7 100644
--- a/Bugzilla/DaemonControl.pm
+++ b/Bugzilla/DaemonControl.pm
@@ -14,7 +14,7 @@ use Bugzilla::Logging;
use Bugzilla::Constants qw(bz_locations);
use Cwd qw(realpath);
use English qw(-no_match_vars $PROGRAM_NAME);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
use Future::Utils qw(repeat try_repeat);
use Future;
use IO::Async::Loop;
@@ -23,7 +23,8 @@ use IO::Async::Protocol::LineStream;
use IO::Async::Signal;
use IO::Socket;
use LWP::Simple qw(get);
-use POSIX qw(setsid WEXITSTATUS);
+use JSON::MaybeXS qw(encode_json);
+use POSIX qw(WEXITSTATUS);
use base qw(Exporter);
@@ -40,12 +41,17 @@ our %EXPORT_TAGS = (
utils => [qw(catch_signal on_exception on_finish)],
);
-use constant {
- JOBQUEUE_BIN => realpath( catfile( bz_locations->{cgi_path}, 'jobqueue.pl' ) ),
- CEREAL_BIN => realpath( catfile( bz_locations->{cgi_path}, 'scripts', 'cereal.pl' ) ),
- HTTPD_BIN => '/usr/sbin/httpd',
- HTTPD_CONFIG => realpath( catfile( bz_locations->{confdir}, 'httpd.conf' ) ),
-};
+my $BUGZILLA_DIR = realpath(bz_locations->{cgi_path});
+my $JOBQUEUE_BIN = catfile( $BUGZILLA_DIR, 'jobqueue.pl' );
+my $CEREAL_BIN = catfile( $BUGZILLA_DIR, 'scripts', 'cereal.pl' );
+my $BUGZILLA_BIN = catfile( $BUGZILLA_DIR, 'bugzilla.pl' );
+my $HYPNOTOAD_BIN = catfile( $BUGZILLA_DIR, 'local', 'bin', 'hypnotoad' );
+my @PERL5LIB = ( $BUGZILLA_DIR, catdir($BUGZILLA_DIR, 'lib'), catdir($BUGZILLA_DIR, 'local', 'lib', 'perl5') );
+
+my %HTTP_COMMAND = (
+ hypnotoad => [ $HYPNOTOAD_BIN, $BUGZILLA_BIN, '-f' ],
+ simple => [ $BUGZILLA_BIN, 'daemon' ],
+);
sub catch_signal {
my ($name, @done) = @_;
@@ -76,7 +82,7 @@ sub run_cereal {
my $loop = IO::Async::Loop->new;
my $exit_f = $loop->new_future;
my $cereal = IO::Async::Process->new(
- command => [CEREAL_BIN],
+ command => [$CEREAL_BIN],
on_finish => on_finish($exit_f),
on_exception => on_exception( 'cereal', $exit_f ),
);
@@ -99,13 +105,12 @@ sub run_httpd {
my $exit_f = $loop->new_future;
my $httpd = IO::Async::Process->new(
code => sub {
-
- # we have to setsid() to make a new process group
- # or else apache will kill its parent.
- setsid();
- my @command = ( HTTPD_BIN, '-DFOREGROUND', '-f' => HTTPD_CONFIG, @args );
- exec @command
- or die "failed to exec $command[0] $!";
+ $ENV{BUGZILLA_HTTPD_ARGS} = encode_json(\@args);
+ $ENV{PERL5LIB} = join(':', @PERL5LIB);
+ my $backend = $ENV{HTTP_BACKEND} // 'hypnotoad';
+ my $command = $HTTP_COMMAND{ $backend };
+ exec @$command
+ or die "failed to exec $command->[0] $!";
},
on_finish => on_finish($exit_f),
on_exception => on_exception( 'httpd', $exit_f ),
@@ -122,7 +127,7 @@ sub run_jobqueue {
my $loop = IO::Async::Loop->new;
my $exit_f = $loop->new_future;
my $jobqueue = IO::Async::Process->new(
- command => [ JOBQUEUE_BIN, 'start', '-f', '-d', @args ],
+ command => [ $JOBQUEUE_BIN, 'start', '-f', '-d', @args ],
on_finish => on_finish($exit_f),
on_exception => on_exception( 'httpd', $exit_f ),
);
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index 9fcd16386..f932294b0 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -31,7 +31,7 @@ use Scalar::Util qw(blessed);
sub _in_eval {
my $in_eval = 0;
for (my $stack = 1; my $sub = (caller($stack))[3]; $stack++) {
- last if $sub =~ /^ModPerl/;
+ last if $sub =~ /^Bugzilla::Quantum::CGI::try/;
$in_eval = 1 if $sub =~ /^\(eval\)/;
}
return $in_eval;
@@ -196,7 +196,7 @@ sub ThrowTemplateError {
# mod_perl overrides exit to call die with this string
# we never want to display this to the user
- exit if $template_err =~ /\bModPerl::Util::exit\b/;
+ die $template_err if ref($template_err) eq 'ARRAY' && $template_err->[0] eq "EXIT\n";
state $logger = Log::Log4perl->get_logger('Bugzilla.Error.Template');
$logger->error($template_err);
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index d56c7f4c4..46e121779 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -41,56 +41,11 @@ use English qw(-no_match_vars $OSNAME);
use base qw(Exporter);
our @EXPORT = qw(
update_filesystem
- create_htaccess
fix_all_file_permissions
fix_dir_permissions
fix_file_permissions
);
-use constant HT_DEFAULT_DENY => <<'EOT';
-# nothing in this directory is retrievable unless overridden by an .htaccess
-# in a subdirectory
-deny from all
-EOT
-
-use constant HT_GRAPHS_DIR => <<'EOT';
-# Allow access to .png and .gif files.
-<FilesMatch (\.gif|\.png)$>
- Allow from all
-</FilesMatch>
-
-# And no directory listings, either.
-Deny from all
-EOT
-
-use constant HT_WEBDOT_DIR => <<'EOT';
-# Restrict access to .dot files to the public webdot server at research.att.com
-# if research.att.com ever changes their IP, or if you use a different
-# webdot server, you'll need to edit this
-<FilesMatch \.dot$>
- Allow from 192.20.225.0/24
- Deny from all
-</FilesMatch>
-
-# Allow access to .png files created by a local copy of 'dot'
-<FilesMatch \.png\$>
- Allow from all
-</FilesMatch>
-
-# And no directory listings, either.
-Deny from all
-EOT
-
-use constant HT_ASSETS_DIR => <<'EOT';
-# Allow access to .css and js files
-<FilesMatch \.(css|js)$>
- Allow from all
-</FilesMatch>
-
-# And no directory listings, either.
-Deny from all
-EOT
-
use constant INDEX_HTML => <<'EOT';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
@@ -258,6 +213,7 @@ sub FILESYSTEM {
# users to be able to cron them or otherwise run
# them as a secure user, like the webserver owner.
'*.cgi' => { perms => WS_EXECUTE },
+ '*.psgi' => { perms => CGI_READ },
'whineatnews.pl' => { perms => WS_EXECUTE },
'collectstats.pl' => { perms => WS_EXECUTE },
'importxml.pl' => { perms => WS_EXECUTE },
@@ -274,13 +230,13 @@ sub FILESYSTEM {
'jobqueue-worker.pl' => { perms => OWNER_EXECUTE },
'clean-bug-user-last-visit.pl' => { perms => WS_EXECUTE },
+ 'bugzilla.pl' => { perms => OWNER_EXECUTE },
'Bugzilla.pm' => { perms => CGI_READ },
"$localconfig*" => { perms => CGI_READ },
'META.*' => { perms => CGI_READ },
'MYMETA.*' => { perms => CGI_READ },
'bugzilla.dtd' => { perms => WS_SERVE },
'mod_perl.pl' => { perms => WS_SERVE },
- '.htaccess' => { perms => WS_SERVE },
'cvs-update.log' => { perms => WS_SERVE },
'scripts/sendunsentbugmail.pl' => { perms => WS_EXECUTE },
'docs/bugzilla.ent' => { perms => OWNER_WRITE },
@@ -389,7 +345,7 @@ sub FILESYSTEM {
'contrib' => { files => OWNER_EXECUTE,
dirs => DIR_OWNER_WRITE, },
'scripts' => { files => OWNER_EXECUTE,
- dirs => DIR_OWNER_WRITE, },
+ dirs => DIR_WS_SERVE, },
);
# --- FILES TO CREATE --- #
@@ -516,54 +472,15 @@ sub FILESYSTEM {
'index.html' => { perms => WS_SERVE, contents => INDEX_HTML }
);
- # Because checksetup controls the .htaccess creation separately
- # by a localconfig variable, these go in a separate variable from
- # %create_files.
- #
- # Note that these get WS_SERVE as their permission
- # because they're *read* by the webserver, even though they're not
- # actually, themselves, served.
- my %htaccess = (
- "$attachdir/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$libdir/Bugzilla/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$extlib/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$templatedir/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- 'contrib/.htaccess' => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- 'scripts/.htaccess' => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- 't/.htaccess' => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- 'xt/.htaccess' => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- '.circleci/.htaccess' => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$confdir/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$datadir/.htaccess" => { perms => WS_SERVE,
- contents => HT_DEFAULT_DENY },
- "$graphsdir/.htaccess" => { perms => WS_SERVE,
- contents => HT_GRAPHS_DIR },
- "$webdotdir/.htaccess" => { perms => WS_SERVE,
- contents => HT_WEBDOT_DIR },
- "$assetsdir/.htaccess" => { perms => WS_SERVE,
- contents => HT_ASSETS_DIR },
- );
-
Bugzilla::Hook::process('install_filesystem', {
files => \%files,
create_dirs => \%create_dirs,
non_recurse_dirs => \%non_recurse_dirs,
recurse_dirs => \%recurse_dirs,
create_files => \%create_files,
- htaccess => \%htaccess,
});
- my %all_files = (%create_files, %htaccess, %index_html, %files);
+ my %all_files = (%create_files, %index_html, %files);
my %all_dirs = (%create_dirs, %non_recurse_dirs);
return {
@@ -572,7 +489,6 @@ sub FILESYSTEM {
all_dirs => \%all_dirs,
create_files => \%create_files,
- htaccess => \%htaccess,
index_html => \%index_html,
all_files => \%all_files,
};
@@ -620,13 +536,6 @@ sub update_filesystem {
_rename_file($oldparamsfile, "$datadir/$oldparamsfile");
}
- # Remove old assets htaccess file to force recreation with correct values.
- if (-e "$assetsdir/.htaccess") {
- if (read_file("$assetsdir/.htaccess") =~ /<FilesMatch \\\.css\$>/) {
- unlink("$assetsdir/.htaccess");
- }
- }
-
_create_files(%files);
if ($params->{index_html}) {
_create_files(%{$fs->{index_html}});
@@ -731,27 +640,6 @@ sub _convert_single_file_skins {
}
}
-sub create_htaccess {
- _create_files(%{FILESYSTEM()->{htaccess}});
-
- # Repair old .htaccess files
-
- my $webdot_dir = bz_locations()->{'webdotdir'};
- # The public webdot IP address changed.
- my $webdot = new IO::File("$webdot_dir/.htaccess", 'r')
- || die "$webdot_dir/.htaccess: $!";
- my $webdot_data;
- { local $/; $webdot_data = <$webdot>; }
- $webdot->close;
- if ($webdot_data =~ /192\.20\.225\.10/) {
- print "Repairing $webdot_dir/.htaccess...\n";
- $webdot_data =~ s/192\.20\.225\.10/192.20.225.0\/24/g;
- $webdot = new IO::File("$webdot_dir/.htaccess", 'w') || die $!;
- print $webdot $webdot_data;
- $webdot->close;
- }
-}
-
sub _rename_file {
my ($from, $to) = @_;
print install_string('file_rename', { from => $from, to => $to }), "\n";
@@ -1062,16 +950,6 @@ Params: C<index_html> - Whether or not we should create
Returns: nothing
-=item C<create_htaccess()>
-
-Description: Creates all of the .htaccess files for Apache,
- in the various Bugzilla directories. Also updates
- the .htaccess files if they need updating.
-
-Params: none
-
-Returns: nothing
-
=item C<fix_all_file_permissions($output)>
Description: Sets all the file permissions on all of Bugzilla's files
diff --git a/Bugzilla/ModPerl.pm b/Bugzilla/ModPerl.pm
deleted file mode 100644
index 19cd1128f..000000000
--- a/Bugzilla/ModPerl.pm
+++ /dev/null
@@ -1,118 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-package Bugzilla::ModPerl;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use File::Find ();
-use Cwd ();
-use Carp ();
-
-# We don't need (or want) to use Bugzilla's template subclass.
-# it is easier to reason with the code without all the extra things Bugzilla::Template adds
-# (and there might be side-effects, since this code is loaded very early in the httpd startup)
-use Template ();
-
-use Bugzilla::ModPerl::BlockIP;
-use Bugzilla::ModPerl::Hostage;
-
-sub apache_config {
- my ($class, $cgi_path) = @_;
-
- Carp::croak "\$cgi_path is required" unless $cgi_path;
-
- my %htaccess;
- $cgi_path = Cwd::realpath($cgi_path);
- my $wanted = sub {
- package File::Find;
- our ($name, $dir);
-
- if ($name =~ m#/\.htaccess$#) {
- open my $fh, '<', $name or die "cannot open $name $!";
- my $contents = do {
- local $/ = undef;
- <$fh>;
- };
- close $fh;
- $htaccess{$dir} = { file => $name, contents => $contents, dir => $dir };
- }
- };
-
- File::Find::find( { wanted => $wanted, no_chdir => 1 }, $cgi_path );
- my $template = Template->new;
- my $conf;
- my %vars = (
- root_htaccess => delete $htaccess{$cgi_path},
- htaccess_files => [ map { $htaccess{$_} } sort { length $a <=> length $b } keys %htaccess ],
- cgi_path => $cgi_path,
- );
- $template->process(\*DATA, \%vars, \$conf);
- my $apache_version = Apache2::ServerUtil::get_server_version();
- if ($apache_version =~ m!Apache/(\d+)\.(\d+)\.(\d+)!) {
- my ($major, $minor, $patch) = ($1, $2, $3);
- if ($major > 2 || $major == 2 && $minor >= 4) {
- $conf =~ s{^\s+deny\s+from\s+all.*$}{Require all denied}gmi;
- $conf =~ s{^\s+allow\s+from\s+all.*$}{Require all granted}gmi;
- $conf =~ s{^\s+allow\s+from\s+(\S+).*$}{Require host $1}gmi;
- }
- }
-
- return $conf;
-}
-
-1;
-
-__DATA__
-# Make sure each httpd child receives a different random seed (bug 476622).
-# Bugzilla::RNG has one srand that needs to be called for
-# every process, and Perl has another. (Various Perl modules still use
-# the built-in rand(), even though we never use it in Bugzilla itself,
-# so we need to srand() both of them.)
-PerlChildInitHandler "sub { Bugzilla::RNG::srand(); srand(); eval { Bugzilla->dbh->ping } }"
-PerlInitHandler Bugzilla::ModPerl::Hostage
-PerlAccessHandler Bugzilla::ModPerl::BlockIP
-
-# It is important to specify ErrorDocuments outside of all directories.
-# These used to be in .htaccess, but then things like "AllowEncodedSlashes no"
-# mean that urls containing %2f are unstyled.
-ErrorDocument 401 /errors/401.html
-ErrorDocument 403 /errors/403.html
-ErrorDocument 404 /errors/404.html
-ErrorDocument 500 /errors/500.html
-
-<Directory "[% cgi_path %]">
- AddHandler perl-script .cgi
- # No need to PerlModule these because they're already defined in mod_perl.pl
- PerlResponseHandler Bugzilla::ModPerl::ResponseHandler
- PerlCleanupHandler Bugzilla::ModPerl::CleanupHandler Apache2::SizeLimit
- PerlOptions +ParseHeaders
- Options +ExecCGI +FollowSymLinks
- DirectoryIndex index.cgi index.html
- AllowOverride none
- # from [% root_htaccess.file %]
- [% root_htaccess.contents FILTER indent %]
-</Directory>
-
-# AWS SES endpoint for handling mail bounces/complaints
-<Location "/ses">
- PerlSetEnv AUTH_VAR_NAME ses_username
- PerlSetEnv AUTH_VAR_PASS ses_password
- PerlAuthenHandler Bugzilla::ModPerl::BasicAuth
- AuthName SES
- AuthType Basic
- require valid-user
-</Location>
-
-# directory rules for all the other places we have .htaccess files
-[% FOREACH htaccess IN htaccess_files %]
-# from [% htaccess.file %]
-<Directory "[% htaccess.dir %]">
- [% htaccess.contents FILTER indent %]
-</Directory>
-[% END %]
diff --git a/Bugzilla/ModPerl/BasicAuth.pm b/Bugzilla/ModPerl/BasicAuth.pm
deleted file mode 100644
index 7248a19f3..000000000
--- a/Bugzilla/ModPerl/BasicAuth.pm
+++ /dev/null
@@ -1,65 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-package Bugzilla::ModPerl::BasicAuth;
-use 5.10.1;
-use strict;
-use warnings;
-
-# Protects a mod_perl <Location> with Basic HTTP authentication.
-#
-# Example use:
-#
-# <Location "/ses">
-# PerlAuthenHandler Bugzilla::ModPerl::BasicAuth
-# PerlSetEnv AUTH_VAR_NAME ses_username
-# PerlSetEnv AUTH_VAR_PASS ses_password
-# AuthName SES
-# AuthType Basic
-# require valid-user
-# </Location>
-#
-# AUTH_VAR_NAME and AUTH_VAR_PASS are the names of variables defined in
-# `localconfig` which hold the authentication credentials.
-
-use Apache2::Const -compile => qw(OK HTTP_UNAUTHORIZED); ## no critic (Freenode::ModPerl)
-use Bugzilla::Logging;
-use Bugzilla ();
-
-sub handler {
- my $r = shift;
- my ($status, $password) = $r->get_basic_auth_pw;
- if ($status != Apache2::Const::OK) {
- WARN("Got non-OK status: $status when trying to get password");
- return $status
- }
-
- my $auth_var_name = $ENV{AUTH_VAR_NAME};
- my $auth_var_pass = $ENV{AUTH_VAR_PASS};
- unless ($auth_var_name && $auth_var_pass) {
- ERROR('AUTH_VAR_NAME and AUTH_VAR_PASS environmental vars not set');
- $r->note_basic_auth_failure;
- return Apache2::Const::HTTP_UNAUTHORIZED;
- }
-
- my $auth_user = Bugzilla->localconfig->{$auth_var_name};
- my $auth_pass = Bugzilla->localconfig->{$auth_var_pass};
- unless ($auth_user && $auth_pass) {
- ERROR("$auth_var_name and $auth_var_pass not configured");
- $r->note_basic_auth_failure;
- return Apache2::Const::HTTP_UNAUTHORIZED;
- }
-
- unless ($r->user eq $auth_user && $password eq $auth_pass) {
- $r->note_basic_auth_failure;
- WARN('username and password do not match');
- return Apache2::Const::HTTP_UNAUTHORIZED;
- }
-
- return Apache2::Const::OK;
-}
-
-1;
diff --git a/Bugzilla/ModPerl/BlockIP.pm b/Bugzilla/ModPerl/BlockIP.pm
deleted file mode 100644
index 4e9a4be5c..000000000
--- a/Bugzilla/ModPerl/BlockIP.pm
+++ /dev/null
@@ -1,65 +0,0 @@
-package Bugzilla::ModPerl::BlockIP;
-use 5.10.1;
-use strict;
-use warnings;
-
-use Apache2::RequestRec ();
-use Apache2::Connection ();
-
-use Apache2::Const -compile => qw(OK);
-use Cache::Memcached::Fast;
-
-use constant BLOCK_TIMEOUT => 60*60;
-
-my $MEMCACHED = Bugzilla::Memcached->_new()->{memcached};
-my $STATIC_URI = qr{
- ^/
- (?: extensions/[^/]+/web
- | robots\.txt
- | __heartbeat__
- | __lbheartbeat__
- | __version__
- | images
- | skins
- | js
- | errors
- )
-}xms;
-
-sub block_ip {
- my ($class, $ip) = @_;
- $MEMCACHED->set("block_ip:$ip" => 1, BLOCK_TIMEOUT) if $MEMCACHED;
-}
-
-sub unblock_ip {
- my ($class, $ip) = @_;
- $MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
-}
-
-sub handler {
- my $r = shift;
- return Apache2::Const::OK if $r->uri =~ $STATIC_URI;
-
- my $ip = $r->headers_in->{'X-Forwarded-For'};
- if ($ip) {
- $ip = (split(/\s*,\s*/ms, $ip))[-1];
- }
- else {
- $ip = $r->connection->remote_ip;
- }
-
- if ($MEMCACHED && $MEMCACHED->get("block_ip:$ip")) {
- __PACKAGE__->block_ip($ip);
- $r->status_line("429 Too Many Requests");
- # 500 is used here because apache 2.2 doesn't understand 429.
- # the above line and the return value together mean we produce 429.
- # Any other variation doesn't work.
- $r->custom_response(500, "Too Many Requests");
- return 429;
- }
- else {
- return Apache2::Const::OK;
- }
-}
-
-1;
diff --git a/Bugzilla/ModPerl/StartupFix.pm b/Bugzilla/ModPerl/StartupFix.pm
deleted file mode 100644
index bcc467e9f..000000000
--- a/Bugzilla/ModPerl/StartupFix.pm
+++ /dev/null
@@ -1,51 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-package Bugzilla::ModPerl::StartupFix;
-use 5.10.1;
-use strict;
-use warnings;
-
-use Filter::Util::Call;
-use Apache2::ServerUtil ();
-
-# This module is a source filter that removes every subsequent line
-# if this is the first time apache has started,
-# as reported by Apache2::ServerUtil::restart_count(), which is 1
-# on the first start.
-
-my $FIRST_STARTUP = <<'CODE';
-warn "Bugzilla::ModPerl::StartupFix: Skipping first startup using source filter\n";
-1;
-CODE
-
-sub import {
- my ($class) = @_;
- my ($ref) = {};
- filter_add( bless $ref, $class );
-}
-
-# this will be called for each line.
-# For the first line replaced, we insert $FIRST_STARTUP.
-# Every subsequent line is replaced with an empty string.
-sub filter {
- my ($self) = @_;
- my ($status);
- if ($status = filter_read() > 0) {
- if (Apache2::ServerUtil::restart_count() < 2) {
- if (!$self->{did_it}) {
- $self->{did_it} = 1;
- $_ = $FIRST_STARTUP;
- }
- else {
- $_ = "";
- }
- }
- }
- return $status;
-}
-
-1; \ No newline at end of file
diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm
new file mode 100644
index 000000000..2519e23ad
--- /dev/null
+++ b/Bugzilla/Quantum.pm
@@ -0,0 +1,199 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum;
+use Mojo::Base 'Mojolicious';
+
+use CGI::Compile; # Needed for its exit() overload
+use Bugzilla::Logging;
+use Bugzilla::Quantum::Template;
+use Bugzilla::Quantum::CGI;
+use Bugzilla::Quantum::Static;
+
+use Bugzilla ();
+use Bugzilla::Constants qw(bz_locations);
+use Bugzilla::BugMail ();
+use Bugzilla::CGI ();
+use Bugzilla::Extension ();
+use Bugzilla::Install::Requirements ();
+use Bugzilla::Util ();
+use Cwd qw(realpath);
+
+use MojoX::Log::Log4perl::Tiny;
+
+has 'static' => sub { Bugzilla::Quantum::Static->new };
+
+sub startup {
+ my ($self) = @_;
+
+ $self->plugin('Bugzilla::Quantum::Plugin::Glue');
+ $self->plugin('Bugzilla::Quantum::Plugin::Hostage');
+ $self->plugin('Bugzilla::Quantum::Plugin::BlockIP');
+
+ if ( $self->mode ne 'development' ) {
+ $self->hook(
+ after_static => sub {
+ my ($c) = @_;
+ $c->res->headers->cache_control('public, max-age=31536000');
+ }
+ );
+ }
+
+ my $r = $self->routes;
+ Bugzilla::Quantum::CGI->load_all($r);
+ Bugzilla::Quantum::CGI->load_one('bzapi_cgi', 'extensions/BzAPI/bin/rest.cgi');
+
+ $r->any('/')->to('CGI#index_cgi');
+ $r->any('/rest')->to('CGI#rest_cgi');
+ $r->any('/rest.cgi/*PATH_INFP')->to('CGI#rest_cgi' => { PATH_INFO => '' });
+ $r->any('/rest/*PATH_INFO')->to( 'CGI#rest_cgi' => { PATH_INFO => '' });
+ $r->any('/bug/:id')->to('CGI#show_bug_cgi');
+ $r->any('/extensions/BzAPI/bin/rest.cgi/*PATH_INFO')->to('CGI#bzapi_cgi');
+ $r->get(
+ '/__lbheartbeat__' => sub {
+ my $c = shift;
+ $c->reply->file( $c->app->home->child('__lbheartbeat__') );
+ },
+ );
+
+ $r->get('/__heartbeat__')->to( 'CGI#heartbeat_cgi');
+ $r->get('/robots.txt')->to( 'CGI#robots_cgi' );
+
+ $r->any('/review')->to( 'CGI#page_cgi' => {'id' => 'splinter.html'});
+ $r->any('/user_profile')->to( 'CGI#page_cgi' => {'id' => 'user_profile.html'});
+ $r->any('/userprofile')->to( 'CGI#page_cgi' => {'id' => 'user_profile.html'});
+ $r->any('/request_defer')->to( 'CGI#page_cgi' => {'id' => 'request_defer.html'});
+ $r->any('/login')->to( 'CGI#index_cgi' => { 'GoAheadAndLogIn' => '1' });
+
+ $r->any('/:new_bug' => [new_bug => qr{new[-_]bug}])->to( 'CGI#new_bug_cgi');
+ $r->any('/:REWRITE_itrequest' => [REWRITE_itrequest => qr{form[\.:]itrequest}])->to(
+ 'CGI#enter_bug_cgi' => { 'product' => 'Infrastructure & Operations', 'format' => 'itrequest' }
+ );
+ $r->any('/:REWRITE_mozlist' => [REWRITE_mozlist => qr{form[\.:]mozlist}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'mozlist'}
+ );
+ $r->any('/:REWRITE_poweredby' => [REWRITE_poweredby => qr{form[\.:]poweredby}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'poweredby'}
+ );
+ $r->any('/:REWRITE_presentation' => [REWRITE_presentation => qr{form[\.:]presentation}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'presentation'}
+ );
+ $r->any('/:REWRITE_trademark' => [REWRITE_trademark => qr{form[\.:]trademark}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'trademark'}
+ );
+ $r->any('/:REWRITE_recoverykey' => [REWRITE_recoverykey => qr{form[\.:]recoverykey}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'recoverykey'}
+ );
+ $r->any('/:REWRITE_legal' => [REWRITE_legal => qr{form[\.:]legal}])->to(
+ 'CGI#enter_bug_cgi' => { 'product' => 'Legal', 'format' => 'legal' },
+ );
+ $r->any('/:REWRITE_recruiting' => [REWRITE_recruiting => qr{form[\.:]recruiting}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Recruiting', 'format' => 'recruiting'}
+ );
+ $r->any('/:REWRITE_intern' => [REWRITE_intern => qr{form[\.:]intern}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Recruiting', 'format' => 'intern'}
+ );
+ $r->any('/:REWRITE_mozpr' => [REWRITE_mozpr => qr{form[\.:]mozpr}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla PR', 'format' => 'mozpr' },
+ );
+ $r->any('/:REWRITE_reps_mentorship' => [REWRITE_reps_mentorship => qr{form[\.:]reps[\.:]mentorship}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'mozreps' },
+ );
+ $r->any('/:REWRITE_reps_budget' => [REWRITE_reps_budget => qr{form[\.:]reps[\.:]budget}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-budget'}
+ );
+ $r->any('/:REWRITE_reps_swag' => [REWRITE_reps_swag => qr{form[\.:]reps[\.:]swag}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-swag'}
+ );
+ $r->any('/:REWRITE_reps_it' => [REWRITE_reps_it => qr{form[\.:]reps[\.:]it}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-it'}
+ );
+ $r->any('/:REWRITE_reps_payment' => [REWRITE_reps_payment => qr{form[\.:]reps[\.:]payment}])->to(
+ 'CGI#page_cgi' => {'id' => 'remo-form-payment.html'}
+ );
+ $r->any('/:REWRITE_csa_discourse' => [REWRITE_csa_discourse => qr{form[\.:]csa[\.:]discourse}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Infrastructure & Operations', 'format' => 'csa-discourse'}
+ );
+ $r->any('/:REWRITE_employee_incident' => [REWRITE_employee_incident => qr{form[\.:]employee[\.\-:]incident}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'employee-incident'}
+ );
+ $r->any('/:REWRITE_brownbag' => [REWRITE_brownbag => qr{form[\.:]brownbag}])->to(
+ 'CGI#https_air_mozilla_org_requests' => {}
+ );
+ $r->any('/:REWRITE_finance' => [REWRITE_finance => qr{form[\.:]finance}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Finance','format' => 'finance'}
+ );
+ $r->any('/:REWRITE_moz_project_review' => [REWRITE_moz_project_review => qr{form[\.:]moz[\.\-:]project[\.\-:]review}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org','format' => 'moz-project-review'}
+ );
+ $r->any('/:REWRITE_docs' => [REWRITE_docs => qr{form[\.:]docs?}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Developer Documentation','format' => 'doc'}
+ );
+ $r->any('/:REWRITE_mdn' => [REWRITE_mdn => qr{form[\.:]mdn?}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'mdn','product' => 'developer.mozilla.org'}
+ );
+ $r->any('/:REWRITE_swag_gear' => [REWRITE_swag_gear => qr{form[\.:](swag|gear)}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'swag','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_costume' => [REWRITE_costume => qr{form[\.:]costume}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Marketing','format' => 'costume'}
+ );
+ $r->any('/:REWRITE_ipp' => [REWRITE_ipp => qr{form[\.:]ipp}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Internet Public Policy','format' => 'ipp'}
+ );
+ $r->any('/:REWRITE_creative' => [REWRITE_creative => qr{form[\.:]creative}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'creative','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_user_engagement' => [REWRITE_user_engagement => qr{form[\.:]user[\.\-:]engagement}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'user-engagement','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_dev_engagement_event' => [REWRITE_dev_engagement_event => qr{form[\.:]dev[\.\-:]engagement[\.\-\:]event}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Developer Engagement','format' => 'dev-engagement-event'}
+ );
+ $r->any('/:REWRITE_mobile_compat' => [REWRITE_mobile_compat => qr{form[\.:]mobile[\.\-:]compat}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Tech Evangelism','format' => 'mobile-compat'}
+ );
+ $r->any('/:REWRITE_web_bounty' => [REWRITE_web_bounty => qr{form[\.:]web[\.:]bounty}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'web-bounty','product' => 'mozilla.org'}
+ );
+ $r->any('/:REWRITE_automative' => [REWRITE_automative => qr{form[\.:]automative}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Testing','format' => 'automative'}
+ );
+ $r->any('/:REWRITE_comm_newsletter' => [REWRITE_comm_newsletter => qr{form[\.:]comm[\.:]newsletter}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'comm-newsletter','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_screen_share_whitelist' => [REWRITE_screen_share_whitelist => qr{form[\.:]screen[\.:]share[\.:]whitelist}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'screen-share-whitelist','product' => 'Firefox'}
+ );
+ $r->any('/:REWRITE_data_compliance' => [REWRITE_data_compliance => qr{form[\.:]data[\.\-:]compliance}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Data Compliance','format' => 'data-compliance'}
+ );
+ $r->any('/:REWRITE_fsa_budget' => [REWRITE_fsa_budget => qr{form[\.:]fsa[\.:]budget}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'FSA','format' => 'fsa-budget'}
+ );
+ $r->any('/:REWRITE_triage_request' => [REWRITE_triage_request => qr{form[\.:]triage[\.\-]request}])->to(
+ 'CGI#page_cgi' => {'id' => 'triage_request.html'}
+ );
+ $r->any('/:REWRITE_crm_CRM' => [REWRITE_crm_CRM => qr{form[\.:](crm|CRM)}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'crm','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_nda' => [REWRITE_nda => qr{form[\.:]nda}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Legal','format' => 'nda'}
+ );
+ $r->any('/:REWRITE_name_clearance' => [REWRITE_name_clearance => qr{form[\.:]name[\.:]clearance}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'name-clearance','product' => 'Legal'}
+ );
+ $r->any('/:REWRITE_shield_studies' => [REWRITE_shield_studies => qr{form[\.:]shield[\.:]studies}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Shield','format' => 'shield-studies'}
+ );
+ $r->any('/:REWRITE_client_bounty' => [REWRITE_client_bounty => qr{form[\.:]client[\.:]bounty}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Firefox','format' => 'client-bounty'}
+ );
+
+}
+
+1;
diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm
new file mode 100644
index 000000000..16c733686
--- /dev/null
+++ b/Bugzilla/Quantum/CGI.pm
@@ -0,0 +1,161 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum::CGI;
+use Mojo::Base 'Mojolicious::Controller';
+
+use CGI::Compile;
+use Bugzilla::Constants qw(bz_locations);
+use Bugzilla::Quantum::Stdout;
+use File::Slurper qw(read_text);
+use File::Spec::Functions qw(catfile);
+use Sub::Name;
+use Sub::Quote 2.005000;
+use Try::Tiny;
+use Taint::Util qw(untaint);
+use Socket qw(AF_INET inet_aton);
+use Sys::Hostname;
+use English qw(-no_match_vars);
+
+our $C;
+my %SEEN;
+
+sub load_all {
+ my ($class, $r) = @_;
+
+ foreach my $file (glob '*.cgi') {
+ my $name = _file_to_method($file);
+ $class->load_one($name, $file);
+ $r->any("/$file")->to("CGI#$name");
+ }
+}
+
+sub load_one {
+ my ($class, $name, $file) = @_;
+ my $package = __PACKAGE__ . "::$name",
+ my $inner_name = "_$name";
+ my $content = read_text( catfile( bz_locations->{cgi_path}, $file ) );
+ $content = "package $package; $content";
+ untaint($content);
+ my %options = (
+ package => $package,
+ file => $file,
+ line => 1,
+ no_defer => 1,
+ );
+ die "Tried to load $file more than once" if $SEEN{$file}++;
+ my $inner = quote_sub $inner_name, $content, {}, \%options;
+ my $wrapper = sub {
+ my ($c) = @_;
+ my $stdin = $c->_STDIN;
+ my $stdout = '';
+ local $C = $c;
+ local %ENV = $c->_ENV($file);
+ local *STDIN; ## no critic (local)
+ local $CGI::Compile::USE_REAL_EXIT = 0;
+ local $PROGRAM_NAME = $file;
+ open STDIN, '<', $stdin->path or die "STDIN @{[$stdin->path]}: $!" if -s $stdin->path;
+ tie *STDOUT, 'Bugzilla::Quantum::Stdout', controller => $c; ## no critic (tie)
+ try {
+ Bugzilla->init_page();
+ $inner->();
+ }
+ catch {
+ die $_ unless ref $_ eq 'ARRAY' && $_->[0] eq "EXIT\n";
+ }
+ finally {
+ untie *STDOUT;
+ $c->finish;
+ Bugzilla->_cleanup; ## no critic (private)
+ CGI::initialize_globals();
+ };
+ };
+
+ no strict 'refs'; ## no critic (strict)
+ *{$name} = subname($name, $wrapper);
+ return 1;
+}
+
+sub _ENV {
+ my ($c, $script_name) = @_;
+ my $tx = $c->tx;
+ my $req = $tx->req;
+ my $headers = $req->headers;
+ my $content_length = $req->content->is_multipart ? $req->body_size : $headers->content_length;
+ my %env_headers = ( HTTP_COOKIE => '', HTTP_REFERER => '' );
+
+ for my $name ( @{ $headers->names } ) {
+ my $key = uc "http_$name";
+ $key =~ s!\W!_!g;
+ $env_headers{$key} = $headers->header($name);
+ }
+
+ my $remote_user;
+ if ( my $userinfo = $c->req->url->to_abs->userinfo ) {
+ $remote_user = $userinfo =~ /([^:]+)/ ? $1 : '';
+ }
+ elsif ( my $authenticate = $headers->authorization ) {
+ $remote_user = $authenticate =~ /Basic\s+(.*)/ ? b64_decode $1 : '';
+ $remote_user = $remote_user =~ /([^:]+)/ ? $1 : '';
+ }
+ my $path_info = $c->param('PATH_INFO');
+ my %captures = %{ $c->stash->{'mojo.captures'} // {} };
+ foreach my $key (keys %captures) {
+ if ($key eq 'action' || $key eq 'PATH_INFO' || $key =~ /^REWRITE_/) {
+ delete $captures{$key};
+ }
+ }
+ my $cgi_query = Mojo::Parameters->new(%captures);
+ $cgi_query->append($req->url->query);
+
+ return (
+ %ENV,
+ CONTENT_LENGTH => $content_length || 0,
+ CONTENT_TYPE => $headers->content_type || '',
+ GATEWAY_INTERFACE => 'CGI/1.1',
+ HTTPS => $req->is_secure ? 'YES' : 'NO',
+ %env_headers,
+ QUERY_STRING => $cgi_query->to_string,
+ PATH_INFO => $path_info ? "/$path_info" : '',
+ REMOTE_ADDR => $tx->remote_address,
+ REMOTE_HOST => gethostbyaddr( inet_aton( $tx->remote_address || '127.0.0.1' ), AF_INET ) || '',
+ REMOTE_PORT => $tx->remote_port,
+ REMOTE_USER => $remote_user || '',
+ REQUEST_METHOD => $req->method,
+ SCRIPT_NAME => "/$script_name",
+ SERVER_NAME => hostname,
+ SERVER_PORT => $tx->local_port,
+ SERVER_PROTOCOL => $req->is_secure ? 'HTTPS' : 'HTTP', # TODO: Version is missing
+ SERVER_SOFTWARE => __PACKAGE__,
+ );
+}
+
+sub _STDIN {
+ my $c = shift;
+ my $stdin;
+
+ if ( $c->req->content->is_multipart ) {
+ $stdin = Mojo::Asset::File->new;
+ $stdin->add_chunk( $c->req->build_body );
+ }
+ else {
+ $stdin = $c->req->content->asset;
+ }
+
+ return $stdin if $stdin->isa('Mojo::Asset::File');
+ return Mojo::Asset::File->new->add_chunk( $stdin->slurp );
+}
+
+sub _file_to_method {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ return $name;
+}
+
+
+1;
diff --git a/Bugzilla/Quantum/Plugin/BlockIP.pm b/Bugzilla/Quantum/Plugin/BlockIP.pm
new file mode 100644
index 000000000..fbfffad66
--- /dev/null
+++ b/Bugzilla/Quantum/Plugin/BlockIP.pm
@@ -0,0 +1,43 @@
+package Bugzilla::Quantum::Plugin::BlockIP;
+use 5.10.1;
+use Mojo::Base 'Mojolicious::Plugin';
+
+use Bugzilla::Memcached;
+
+use constant BLOCK_TIMEOUT => 60*60;
+
+my $MEMCACHED = Bugzilla::Memcached->_new()->{memcached};
+
+sub register {
+ my ( $self, $app, $conf ) = @_;
+
+ $app->hook(before_routes => \&_before_routes);
+ $app->helper(block_ip => \&_block_ip);
+ $app->helper(unblock_ip => \&_unblock_ip);
+}
+
+sub _block_ip {
+ my ($class, $ip) = @_;
+ $MEMCACHED->set("block_ip:$ip" => 1, BLOCK_TIMEOUT) if $MEMCACHED;
+}
+
+sub _unblock_ip {
+ my ($class, $ip) = @_;
+ $MEMCACHED->delete("block_ip:$ip") if $MEMCACHED;
+}
+
+sub _before_routes {
+ my ( $c ) = @_;
+ return if $c->stash->{'mojo.static'};
+
+ my $ip = $c->tx->remote_address;
+ if ($MEMCACHED && $MEMCACHED->get("block_ip:$ip")) {
+ $c->block_ip($ip);
+ $c->res->code(429);
+ $c->res->message("Too Many Requests");
+ $c->res->body("Too Many Requests");
+ $c->finish;
+ }
+}
+
+1;
diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm
new file mode 100644
index 000000000..54a360003
--- /dev/null
+++ b/Bugzilla/Quantum/Plugin/Glue.pm
@@ -0,0 +1,112 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum::Plugin::Glue;
+use 5.10.1;
+use Mojo::Base 'Mojolicious::Plugin';
+
+use Try::Tiny;
+use Bugzilla::Constants;
+use Bugzilla::Quantum::Template;
+use Bugzilla::Logging;
+use Bugzilla::RNG ();
+use JSON::MaybeXS qw(decode_json);
+
+sub register {
+ my ( $self, $app, $conf ) = @_;
+
+ my %D;
+ if ($ENV{BUGZILLA_HTTPD_ARGS}) {
+ my $args = decode_json($ENV{BUGZILLA_HTTPD_ARGS});
+ foreach my $arg (@$args) {
+ if ($arg =~ /^-D(\w+)$/) {
+ $D{$1} = 1;
+ }
+ else {
+ die "Unknown httpd arg: $arg";
+ }
+ }
+ }
+
+ # hypnotoad is weird and doesn't look for MOJO_LISTEN itself.
+ $app->config(
+ hypnotoad => {
+ listen => [ $ENV{MOJO_LISTEN} ],
+ },
+ );
+
+ # Make sure each httpd child receives a different random seed (bug 476622).
+ # Bugzilla::RNG has one srand that needs to be called for
+ # every process, and Perl has another. (Various Perl modules still use
+ # the built-in rand(), even though we never use it in Bugzilla itself,
+ # so we need to srand() both of them.)
+ # Also, ping the dbh to force a reconnection.
+ Mojo::IOLoop->next_tick(
+ sub {
+ Bugzilla::RNG::srand();
+ srand();
+ eval { Bugzilla->dbh->ping };
+ }
+ );
+
+ $app->hook(
+ before_dispatch => sub {
+ my ($c) = @_;
+ if ($D{HTTPD_IN_SUBDIR}) {
+ my $path = $c->req->url->path;
+ $path =~ s{^/bmo}{}s;
+ $c->req->url->path($path);
+ }
+ Log::Log4perl::MDC->put(request_id => $c->req->request_id);
+ }
+ );
+
+ Bugzilla::Extension->load_all();
+ if ($app->mode ne 'development') {
+ Bugzilla->preload_features();
+ DEBUG("preloading templates");
+ Bugzilla->preload_templates();
+ DEBUG("done preloading templates");
+ }
+ $app->secrets([Bugzilla->localconfig->{side_wide_secret}]);
+
+ $app->renderer->add_handler(
+ 'bugzilla' => sub {
+ my ( $renderer, $c, $output, $options ) = @_;
+ my $vars = delete $c->stash->{vars};
+
+ # Helpers
+ my %helper;
+ foreach my $method ( grep {m/^\w+\z/} keys %{ $renderer->helpers } ) {
+ my $sub = $renderer->helpers->{$method};
+ $helper{$method} = sub { $c->$sub(@_) };
+ }
+ $vars->{helper} = \%helper;
+
+ # The controller
+ $vars->{c} = $c;
+ my $name = $options->{template};
+ unless ($name =~ /\./) {
+ $name = sprintf '%s.%s.tmpl', $options->{template}, $options->{format};
+ }
+ my $template = Bugzilla->template;
+ $template->process( $name, $vars, $output )
+ or die $template->error;
+ }
+ );
+
+ $app->log(
+ MojoX::Log::Log4perl::Tiny->new(
+ logger => Log::Log4perl->get_logger(ref $app)
+ )
+ );
+}
+
+
+
+
+1;
diff --git a/Bugzilla/ModPerl/Hostage.pm b/Bugzilla/Quantum/Plugin/Hostage.pm
index a3bdfac58..42a05a910 100644
--- a/Bugzilla/ModPerl/Hostage.pm
+++ b/Bugzilla/Quantum/Plugin/Hostage.pm
@@ -1,9 +1,6 @@
-package Bugzilla::ModPerl::Hostage;
+package Bugzilla::Quantum::Plugin::Hostage;
use 5.10.1;
-use strict;
-use warnings;
-
-use Apache2::Const qw(:common); ## no critic (Freenode::ModPerl)
+use Mojo::Base 'Mojolicious::Plugin';
sub _attachment_root {
my ($base) = @_;
@@ -24,8 +21,14 @@ sub _attachment_host_regex {
return qr/^$regex$/s;
}
-sub handler {
- my $r = shift;
+sub register {
+ my ( $self, $app, $conf ) = @_;
+
+ $app->hook(before_routes => \&_before_routes);
+}
+
+sub _before_routes {
+ my ( $c ) = @_;
state $urlbase = Bugzilla->localconfig->{urlbase};
state $urlbase_uri = URI->new($urlbase);
state $urlbase_host = $urlbase_uri->host;
@@ -34,37 +37,43 @@ sub handler {
state $attachment_root = _attachment_root($attachment_base);
state $attachment_host_regex = _attachment_host_regex($attachment_base);
- my $hostname = $r->hostname;
- return OK if $hostname eq $urlbase_host;
+ my $stash = $c->stash;
+ my $req = $c->req;
+ my $url = $req->url->to_abs;
+
+ return if $stash->{'mojo.static'};
+
+ my $hostname = $url->host;
+ return if $hostname eq $urlbase_host;
- my $path = $r->uri;
- return OK if $path eq '/__lbheartbeat__';
+ my $path = $url->path;
+ return if $path eq '/__lbheartbeat__';
if ($attachment_base && $hostname eq $attachment_root) {
- $r->headers_out->set(Location => $urlbase);
- return REDIRECT;
+ $c->redirect_to($urlbase);
+ return;
}
elsif ($attachment_base && $hostname =~ $attachment_host_regex) {
if ($path =~ m{^/attachment\.cgi}s) {
- return OK;
+ return;
} else {
- my $new_uri = URI->new($r->unparsed_uri);
+ my $new_uri = $url->clone;
$new_uri->scheme($urlbase_uri->scheme);
$new_uri->host($urlbase_host);
- $r->headers_out->set(Location => $new_uri);
- return REDIRECT;
+ $c->redirect_to($new_uri);
+ return;
}
}
elsif (my ($id) = $hostname =~ $urlbase_host_regex) {
my $new_uri = $urlbase_uri->clone;
$new_uri->path('/show_bug.cgi');
$new_uri->query_form(id => $id);
- $r->headers_out->set(Location => $new_uri);
- return REDIRECT;
+ $c->redirect_to($new_uri);
+ return;
}
else {
- $r->headers_out->set(Location => $urlbase);
- return REDIRECT;
+ $c->redirect_to($urlbase);
+ return;
}
}
diff --git a/ses/index.cgi b/Bugzilla/Quantum/SES.pm
index e36956b1d..e36956b1d 100755..100644
--- a/ses/index.cgi
+++ b/Bugzilla/Quantum/SES.pm
diff --git a/Bugzilla/Quantum/Static.pm b/Bugzilla/Quantum/Static.pm
new file mode 100644
index 000000000..2bb54990e
--- /dev/null
+++ b/Bugzilla/Quantum/Static.pm
@@ -0,0 +1,30 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum::Static;
+use Mojo::Base 'Mojolicious::Static';
+use Bugzilla::Constants qw(bz_locations);
+
+my $LEGACY_RE = qr{
+ ^ (?:static/v[0-9]+\.[0-9]+/) ?
+ ( (?:extensions/[^/]+/web|(?:image|skin|j)s)/.+)
+ $
+}xs;
+
+sub file {
+ my ($self, $rel) = @_;
+
+ if (my ($legacy_rel) = $rel =~ $LEGACY_RE) {
+ local $self->{paths} = [ bz_locations->{cgi_path} ];
+ return $self->SUPER::file($legacy_rel);
+ }
+ else {
+ return $self->SUPER::file($rel);
+ }
+}
+
+1;
diff --git a/Bugzilla/Quantum/Stdout.pm b/Bugzilla/Quantum/Stdout.pm
new file mode 100644
index 000000000..ee470a56a
--- /dev/null
+++ b/Bugzilla/Quantum/Stdout.pm
@@ -0,0 +1,42 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum::Stdout;
+use 5.10.1;
+use Moo;
+
+has 'controller' => (
+ is => 'ro',
+ required => 1,
+);
+
+sub TIEHANDLE { ## no critic (unpack)
+ my $class = shift;
+
+ return $class->new(@_);
+}
+
+sub PRINTF { ## no critic (unpack)
+ my $self = shift;
+ $self->PRINT(sprintf @_);
+}
+
+sub PRINT { ## no critic (unpack)
+ my $self = shift;
+
+ foreach my $chunk (@_) {
+ my $str = "$chunk";
+ utf8::encode($str);
+ $self->controller->write($str);
+ }
+}
+
+sub BINMODE {
+ # no-op
+}
+
+1; \ No newline at end of file
diff --git a/Bugzilla/Quantum/Template.pm b/Bugzilla/Quantum/Template.pm
new file mode 100644
index 000000000..2442f1134
--- /dev/null
+++ b/Bugzilla/Quantum/Template.pm
@@ -0,0 +1,39 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Quantum::Template;
+use 5.10.1;
+use Moo;
+
+has 'controller' => (
+ is => 'ro',
+ required => 1,
+);
+
+has 'template' => (
+ is => 'ro',
+ required => 1,
+ handles => ['error', 'get_format'],
+);
+
+sub process {
+ my ($self, $file, $vars, $output) = @_;
+
+ if (@_ < 4) {
+ $self->controller->stash->{vars} = $vars;
+ $self->controller->render(template => $file, handler => 'bugzilla');
+ return 1;
+ }
+ elsif (@_ == 4) {
+ return $self->template->process($file, $vars, $output);
+ }
+ else {
+ die __PACKAGE__ . '->process() called with too many arguments';
+ }
+}
+
+1; \ No newline at end of file
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 107c457c6..e54877e9b 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -571,7 +571,7 @@ sub create {
# if a packager has modified bz_locations() to contain absolute
# paths.
ABSOLUTE => 1,
- RELATIVE => 1,
+ RELATIVE => $ENV{SERVER_SOFTWARE} ? 0 : 1,
# Only use an on-disk template cache if we're running as the web
# server. This ensures the permissions of the cache remain correct.
@@ -1042,7 +1042,11 @@ sub create {
# under mod_perl, use a provider (template loader) that preloads all templates into memory
my $provider_class
+<<<<<<< HEAD
= BZ_PERSISTENT
+=======
+ = $opts{preload}
+>>>>>>> dylanwh/mojo-poc
? 'Bugzilla::Template::PreloadProvider'
: 'Template::Provider';
diff --git a/Bugzilla/WebService/Server/XMLRPC.pm b/Bugzilla/WebService/Server/XMLRPC.pm
index 6bb73af01..5ad50e91c 100644
--- a/Bugzilla/WebService/Server/XMLRPC.pm
+++ b/Bugzilla/WebService/Server/XMLRPC.pm
@@ -14,11 +14,7 @@ use warnings;
use Bugzilla::Logging;
use XMLRPC::Transport::HTTP;
use Bugzilla::WebService::Server;
-if ($ENV{MOD_PERL}) {
- our @ISA = qw(XMLRPC::Transport::HTTP::Apache Bugzilla::WebService::Server);
-} else {
- our @ISA = qw(XMLRPC::Transport::HTTP::CGI Bugzilla::WebService::Server);
-}
+our @ISA = qw(XMLRPC::Transport::HTTP::CGI Bugzilla::WebService::Server);
use Bugzilla::WebService::Constants;
use Bugzilla::Error;
diff --git a/Bugzilla/WebService/Util.pm b/Bugzilla/WebService/Util.pm
index 29ff05448..d462c884a 100644
--- a/Bugzilla/WebService/Util.pm
+++ b/Bugzilla/WebService/Util.pm
@@ -23,7 +23,7 @@ use base qw(Exporter);
# We have to "require", not "use" this, because otherwise it tries to
# use features of Test::More during import().
-require Test::Taint;
+require Test::Taint if ${^TAINT};
our @EXPORT_OK = qw(
extract_flags
@@ -193,8 +193,10 @@ sub taint_data {
# Though this is a private function, it hasn't changed since 2004 and
# should be safe to use, and prevents us from having to write it ourselves
# or require another module to do it.
- Test::Taint::_deeply_traverse(\&_delete_bad_keys, \@params);
- Test::Taint::taint_deeply(\@params);
+ if (${^TAINT}) {
+ Test::Taint::_deeply_traverse(\&_delete_bad_keys, \@params);
+ Test::Taint::taint_deeply(\@params);
+ }
}
sub _delete_bad_keys {
diff --git a/Dockerfile b/Dockerfile
index 009c41ee8..1e5c521ee 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,12 +9,6 @@ ENV CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL}
ENV CIRCLE_SHA1=${CIRCLE_SHA1}
ENV LOG4PERL_CONFIG_FILE=log4perl-json.conf
-ENV HTTPD_StartServers=8
-ENV HTTPD_MinSpareServers=5
-ENV HTTPD_MaxSpareServers=20
-ENV HTTPD_ServerLimit=256
-ENV HTTPD_MaxClients=256
-ENV HTTPD_MaxRequestsPerChild=4000
ENV PORT=8000
@@ -28,7 +22,8 @@ RUN mv /opt/bmo/local /app && \
chown -R app:app /app && \
perl -I/app -I/app/local/lib/perl5 -c -E 'use Bugzilla; BEGIN { Bugzilla->extensions }' && \
perl -c /app/scripts/entrypoint.pl && \
- setcap 'cap_net_bind_service=+ep' /usr/sbin/httpd
+ setcap 'cap_net_bind_service=+ep' /usr/sbin/httpd && \
+ setcap 'cap_net_bind_service=+ep' /usr/bin/perl
USER app
diff --git a/Log/Log4perl/Layout/Mozilla.pm b/Log/Log4perl/Layout/Mozilla.pm
index b625c54f4..4aedd9843 100644
--- a/Log/Log4perl/Layout/Mozilla.pm
+++ b/Log/Log4perl/Layout/Mozilla.pm
@@ -53,6 +53,9 @@ sub render {
my $mdc = Log::Log4perl::MDC->get_context;
my $fields = $mdc->{fields} // {};
+ if ($mdc->{request_id}) {
+ $fields->{request_id} = $mdc->{request_id}
+ }
my %out = (
EnvVersion => LOGGING_FORMAT_VERSION,
Hostname => $HOSTNAME,
diff --git a/Makefile.PL b/Makefile.PL
index 7012c641d..cebbb057b 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -69,6 +69,7 @@ my %requires = (
'Module::Metadata' => '1.000033',
'Module::Runtime' => '0.014',
'Mojolicious' => '7.71',
+ 'MojoX::Log::Log4perl::Tiny' => '0.01',
'Moo' => '2.002004',
'MooX::StrictConstructor' => '0.008',
'Mozilla::CA' => '20160104',
@@ -79,6 +80,7 @@ my %requires = (
'Template' => '2.24',
'Text::CSV_XS' => '1.26',
'Throwable' => '0.200013',
+ 'Sub::Quote' => '2.005000',
'Type::Tiny' => '1.000005',
'URI' => '1.55',
'URI::Escape::XS' => '0.14',
@@ -282,18 +284,6 @@ my %optional_features = (
}
},
},
- mod_perl => {
- description => 'mod_perl support under Apache',
- prereqs => {
- runtime => {
- requires => {
- 'mod_perl2' => '1.999022',
- 'Apache2::SizeLimit' => '0.96',
- 'Plack::Handler::Apache2' => 0,
- }
- }
- }
- },
inbound_email => {
description => 'Inbound Email',
prereqs => {
diff --git a/README.rst b/README.rst
index 985be314e..0d8d03f38 100644
--- a/README.rst
+++ b/README.rst
@@ -330,41 +330,6 @@ BMO_use_mailer_queue
Usually configured on the MTA section of the admin interface, you may change this here for testing purposes.
Should be 1 or 0. If 1, the job queue will be used. For testing, only set to 0 if the BMO_mail_delivery_method is None or Test.
-HTTPD_StartServers
- Sets the number of child server processes created on startup.
- As the number of processes is dynamically controlled depending on the load,
- there is usually little reason to adjust this parameter.
- Default: 8
-
-HTTPD_MinSpareServers
- Sets the desired minimum number of idle child server processes. An idle
- process is one which is not handling a request. If there are fewer than
- MinSpareServers idle, then the parent process creates new children at a
- maximum rate of 1 per second.
- Default: 5
-
-HTTPD_MaxSpareServers
- Sets the desired maximum number of idle child server processes. An idle
- process is one which is not handling a request. If there are more than
- MaxSpareServers idle, then the parent process will kill off the excess
- processes.
- Default: 20
-
-HTTPD_MaxClients
- Sets the maximum number of child processes that will be launched to serve requests.
- Default: 256
-
-HTTPD_ServerLimit
- Sets the maximum configured value for MaxClients for the lifetime of the
- Apache process.
- Default: 256
-
-HTTPD_MaxRequestsPerChild
- Sets the limit on the number of requests that an individual child server
- process will handle. After MaxRequestsPerChild requests, the child process
- will die. If MaxRequestsPerChild is 0, then the process will never expire.
- Default: 4000
-
USE_NYTPROF
Write `Devel::NYTProf`_ profiles out for each requests.
These will be named /app/data/nytprof.$host.$script.$n.$pid, where $host is
diff --git a/buglist.cgi b/buglist.cgi
index 4d3ad1a86..58dedf480 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -752,12 +752,6 @@ if ($serverpush) {
$template->process("list/server-push.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
- # Under mod_perl, flush stdout so that the page actually shows up.
- if ($ENV{MOD_PERL}) {
- require Apache2::RequestUtil;
- Apache2::RequestUtil->request->rflush();
- }
-
# Don't do multipart_end() until we're ready to display the replacement
# page, otherwise any errors that happen before then (like SQL errors)
# will result in a blank page being shown to the user instead of the error.
diff --git a/bugzilla.pl b/bugzilla.pl
new file mode 100755
index 000000000..efcea293b
--- /dev/null
+++ b/bugzilla.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+use 5.10.1;
+use strict;
+use warnings;
+
+use File::Basename qw(basename dirname);
+use File::Spec::Functions qw(catdir);
+use Cwd qw(realpath);
+
+BEGIN {
+ require lib;
+ my $dir = realpath( dirname(__FILE__) );
+ lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) );
+}
+use Mojolicious::Commands;
+
+$ENV{MOJO_LISTEN} ||= $ENV{PORT} ? "http://*:$ENV{PORT}" : "http://*:3001";
+
+# Start command line interface for application
+Mojolicious::Commands->start_app('Bugzilla::Quantum');
diff --git a/checksetup.pl b/checksetup.pl
index d3f08e024..7c9826ee3 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -135,7 +135,7 @@ require Bugzilla::Install::Localconfig;
import Bugzilla::Install::Localconfig qw(update_localconfig);
require Bugzilla::Install::Filesystem;
-import Bugzilla::Install::Filesystem qw(update_filesystem create_htaccess
+import Bugzilla::Install::Filesystem qw(update_filesystem
fix_all_file_permissions);
require Bugzilla::Install::DB;
require Bugzilla::DB;
@@ -201,7 +201,6 @@ unless ($switch{'no-database'}) {
###########################################################################
update_filesystem({ index_html => $lc_hash->{'index_html'} });
-create_htaccess() if $lc_hash->{'create_htaccess'};
# Remove parameters from the params file that no longer exist in Bugzilla,
# and set the defaults for new ones
diff --git a/colchange.cgi b/colchange.cgi
index d77782bec..46d25ecdf 100755
--- a/colchange.cgi
+++ b/colchange.cgi
@@ -136,26 +136,12 @@ if (defined $cgi->param('rememberedquery')) {
$params->param('columnlist', join(",", @collist));
$vars->{'redirect_url'} = "buglist.cgi?".$params->query_string();
-
# If we're running on Microsoft IIS, $cgi->redirect discards
# the Set-Cookie lines. In mod_perl, $cgi->redirect with cookies
# causes the page to be rendered as text/plain.
# Workaround is to use the old-fashioned redirection mechanism.
# See bug 214466 and bug 376044 for details.
- if ($ENV{'MOD_PERL'}
- || $ENV{'SERVER_SOFTWARE'} =~ /Microsoft-IIS/
- || $ENV{'SERVER_SOFTWARE'} =~ /Sun ONE Web/)
- {
- print $cgi->header(-type => "text/html",
- -refresh => "0; URL=$vars->{'redirect_url'}");
- }
- else {
- print $cgi->redirect($vars->{'redirect_url'});
- exit;
- }
-
- $template->process("global/message.html.tmpl", $vars)
- || ThrowTemplateError($template->error());
+ print $cgi->redirect($vars->{'redirect_url'});
exit;
}
diff --git a/conf/log4perl-test.conf b/conf/log4perl-test.conf
index 77fc00af8..1760279db 100644
--- a/conf/log4perl-test.conf
+++ b/conf/log4perl-test.conf
@@ -4,14 +4,14 @@ log4perl.appender.Cereal.PeerAddr=127.0.0.1
log4perl.appender.Cereal.PeerPort=5880
log4perl.appender.Cereal.defer_connection=1
log4perl.appender.Cereal.layout = Log::Log4perl::Layout::PatternLayout
-log4perl.appender.Cereal.layout.ConversionPattern = %d %6p | %c | %m{chomp}%n
+log4perl.appender.Cereal.layout.ConversionPattern = %X{request_id} %d %6p | %c | %m{chomp}%n
log4perl.filter.LOG_TO_STDERR = sub { not $ENV{LOG4PERL_STDERR_DISABLE} }
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.Filter = LOG_TO_STDERR
log4perl.appender.Screen.stderr = 1
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
-log4perl.appender.Screen.layout.ConversionPattern = %d %6p | %c | %m{chomp}%n
+log4perl.appender.Screen.layout.ConversionPattern = STDERR: %X{request_id} %d %6p | %c | %m{chomp}%n
log4perl.appender.File = Log::Log4perl::Appender::File
log4perl.appender.File.layout = Log::Log4perl::Layout::Mozilla
diff --git a/docker-compose.yml b/docker-compose.yml
index 1ca6f5c90..b00c6bc03 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -19,6 +19,7 @@ services:
- LOCALCONFIG_ENV=1
- LOG4PERL_CONFIG_FILE=log4perl-docker.conf
- BUGZILLA_UNSAFE_AUTH_DELEGATION=1
+ - HTTP_BACKEND=simple
- PORT=80
- BMO_db_host=bmo-db.vm
- BMO_db_name=bugs
diff --git a/heartbeat.cgi b/heartbeat.cgi
index 08cf13fa7..773673697 100755
--- a/heartbeat.cgi
+++ b/heartbeat.cgi
@@ -29,7 +29,6 @@ my $ok = eval {
die "database not available" unless $database_ok;
die "memcached server(s) not available" unless $memcached_ok;
- die "mod_perl/psgi not configured?" unless BZ_PERSISTENT;
1;
};
FATAL("heartbeat error: $@") if !$ok && $@;
@@ -37,10 +36,3 @@ FATAL("heartbeat error: $@") if !$ok && $@;
my $cgi = Bugzilla->cgi;
print $cgi->header(-type => 'text/plain', -status => $ok ? '200 OK' : '500 Internal Server Error');
print $ok ? "Bugzilla OK\n" : "Bugzilla NOT OK\n";
-
-if ($ENV{MOD_PERL}) {
- my $r = $cgi->r;
- # doing this supresses the error document, but does not change the http response code.
- $r->rflush;
- $r->status(200);
-}
diff --git a/mod_perl.pl b/mod_perl.pl
deleted file mode 100644
index b5a038f0a..000000000
--- a/mod_perl.pl
+++ /dev/null
@@ -1,200 +0,0 @@
-#!/usr/bin/perl -T
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-
-package Bugzilla::ModPerl;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-BEGIN { $main::BUGZILLA_PERSISTENT = 1 }
-
-# This sets up our libpath without having to specify it in the mod_perl
-# configuration.
-use File::Basename;
-use File::Spec;
-BEGIN {
- require lib;
- my $dir = dirname(__FILE__);
- lib->import($dir, File::Spec->catdir($dir, "lib"), File::Spec->catdir($dir, qw(local lib perl5)));
-}
-
-use Bugzilla::ModPerl::StartupFix;
-use Taint::Util qw(untaint);
-
-use constant USE_NYTPROF => !! $ENV{USE_NYTPROF};
-use constant NYTPROF_DIR => do {
- my $dir = $ENV{NYTPROF_DIR};
- untaint($dir);
- $dir;
-};
-BEGIN {
- if (USE_NYTPROF) {
- $ENV{NYTPROF} = "savesrc=0:start=no:addpid=1";
- }
-}
-use if USE_NYTPROF, 'Devel::NYTProf::Apache';
-
-use Bugzilla::Constants ();
-
-# If you have an Apache2::Status handler in your Apache configuration,
-# you need to load Apache2::Status *here*, so that any later-loaded modules
-# can report information to Apache2::Status.
-#use Apache2::Status ();
-
-# We don't want to import anything into the global scope during
-# startup, so we always specify () after using any module in this
-# file.
-
-use Apache2::Log ();
-use Apache2::ServerUtil;
-use Apache2::SizeLimit;
-use ModPerl::RegistryLoader ();
-use File::Basename ();
-use File::Find ();
-use English qw(-no_match_vars $OSNAME);
-
-# This loads most of our modules.
-use Bugzilla ();
-# Loading Bugzilla.pm doesn't load this, though, and we want it preloaded.
-use Bugzilla::BugMail ();
-use Bugzilla::CGI ();
-use Bugzilla::Extension ();
-use Bugzilla::Install::Requirements ();
-use Bugzilla::Util ();
-use Bugzilla::RNG ();
-use Bugzilla::ModPerl ();
-
-# Make warnings go to the virtual host's log and not the main
-# server log.
-BEGIN { *CORE::GLOBAL::warn = \&Apache2::ServerRec::warn; }
-
-# Pre-compile the CGI.pm methods that we're going to use.
-Bugzilla::CGI->compile(qw(:cgi :push));
-
-# This means that every httpd child will die after processing a request if it
-# is taking up more than $apache_size_limit of RAM all by itself, not counting RAM it is
-# sharing with the other httpd processes.
-my $limit = Bugzilla->localconfig->{apache_size_limit};
-if ($OSNAME eq 'linux' && ! eval { require Linux::Smaps }) {
- WARN('SizeLimit requires Linux::Smaps on linux. size limit set to 800MB');
- $limit = 800_000;
-}
-Apache2::SizeLimit->set_max_unshared_size($limit);
-
-my $cgi_path = Bugzilla::Constants::bz_locations()->{'cgi_path'};
-
-# Set up the configuration for the web server
-my $server = Apache2::ServerUtil->server;
-my $conf = Bugzilla::ModPerl->apache_config($cgi_path);
-$server->add_config([ grep { length $_ } split("\n", $conf)]);
-
-# Pre-load localconfig. It might already be loaded, but we need to make sure.
-Bugzilla->localconfig;
-if ($ENV{LOCALCONFIG_ENV}) {
- delete @ENV{ (Bugzilla::Install::Localconfig::ENV_KEYS) };
-}
-
-# Pre-load all extensions
-Bugzilla::Extension->load_all();
-
-Bugzilla->preload_features();
-
-# Force instantiation of template so Bugzilla::Template::PreloadProvider can do its magic.
-Bugzilla->template;
-
-# Have ModPerl::RegistryLoader pre-compile all CGI scripts.
-my $rl = new ModPerl::RegistryLoader();
-# If we try to do this in "new" it fails because it looks for a
-# Bugzilla/ModPerl/ResponseHandler.pm
-$rl->{package} = 'Bugzilla::ModPerl::ResponseHandler';
-my $feature_files = Bugzilla::Install::Requirements::map_files_to_features();
-
-# Prevent "use lib" from doing anything when the .cgi files are compiled.
-# This is important to prevent the current directory from getting into
-# @INC and messing things up. (See bug 630750.)
-no warnings 'redefine';
-local *lib::import = sub {};
-use warnings;
-
-foreach my $file (glob "$cgi_path/*.cgi") {
- my $base_filename = File::Basename::basename($file);
- if (my $feature = $feature_files->{$base_filename}) {
- next if !Bugzilla->feature($feature);
- }
- Bugzilla::Util::trick_taint($file);
- $rl->handler($file, $file);
-}
-
-# Some items might already be loaded into the request cache
-# best to make sure it starts out empty.
-# Because of bug 1347335 we also do this in init_page().
-Bugzilla::clear_request_cache();
-
-package Bugzilla::ModPerl::ResponseHandler;
-use strict;
-use base qw(ModPerl::Registry);
-use Bugzilla;
-use Bugzilla::Constants qw(USAGE_MODE_REST bz_locations);
-use Time::HiRes;
-use Sys::Hostname;
-
-sub handler : method {
- my $class = shift;
-
- # $0 is broken under mod_perl before 2.0.2, so we have to set it
- # here explicitly or init_page's shutdownhtml code won't work right.
- $0 = $ENV{'SCRIPT_FILENAME'};
-
- # Prevent "use lib" from modifying @INC in the case where a .cgi file
- # is being automatically recompiled by mod_perl when Apache is
- # running. (This happens if a file changes while Apache is already
- # running.)
- no warnings 'redefine';
- local *lib::import = sub {};
- use warnings;
-
- if (Bugzilla::ModPerl::USE_NYTPROF) {
- state $count = {};
- state $dir = Bugzilla::ModPerl::NYTPROF_DIR // bz_locations()->{datadir};
- state $host = (split(/\./, hostname()))[0];
- my $script = File::Basename::basename($ENV{SCRIPT_FILENAME});
- $script =~ s/\.cgi$//;
- my $file = $dir . "/nytprof.$host.$script." . ++$count->{$$};
- DB::enable_profile($file);
- }
- Bugzilla::init_page();
- my $result = $class->SUPER::handler(@_);
- if (Bugzilla::ModPerl::USE_NYTPROF) {
- DB::disable_profile();
- DB::finish_profile();
- }
-
- # When returning data from the REST api we must only return 200 or 304,
- # which tells Apache not to append its error html documents to the
- # response.
- return Bugzilla->usage_mode == USAGE_MODE_REST && $result != 304
- ? Apache2::Const::OK
- : $result;
-}
-
-
-package Bugzilla::ModPerl::CleanupHandler;
-use strict;
-use Apache2::Const -compile => qw(OK);
-
-sub handler {
- my $r = shift;
-
- Bugzilla::_cleanup();
-
- return Apache2::Const::OK;
-}
-
-1;
diff --git a/scripts/block-ip.pl b/scripts/block-ip.pl
index b767a1fd5..3fa66d336 100755
--- a/scripts/block-ip.pl
+++ b/scripts/block-ip.pl
@@ -12,8 +12,8 @@ use warnings;
use lib qw(. lib local/lib/perl5);
use Bugzilla;
+use Bugzilla::Quantum;
use Bugzilla::Constants;
-use Bugzilla::ModPerl::BlockIP;
use Getopt::Long;
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
@@ -23,10 +23,12 @@ GetOptions('unblock' => \$unblock);
pod2usage("No IPs given") unless @ARGV;
+my $app = Bugzilla::Quantum->new;
+
if ($unblock) {
- Bugzilla::ModPerl::BlockIP->unblock_ip($_) for @ARGV;
+ $app->unblock_ip($_) for @ARGV;
} else {
- Bugzilla::ModPerl::BlockIP->block_ip($_) for @ARGV;
+ $app->block_ip($_) for @ARGV;
}
=head1 NAME
@@ -52,4 +54,4 @@ If passed, the IPs will be unblocked instead of blocked. Use this to remove IPs
=head1 DESCRIPTION
-This is just a simple CLI inteface to L<Bugzilla::ModPerl::BlockIP>.
+This is just a simple CLI inteface to L<Bugzilla::Quantum::Plugin::BlockIP>.
diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl
index 1b0dcb7f1..c48582606 100755
--- a/scripts/entrypoint.pl
+++ b/scripts/entrypoint.pl
@@ -156,6 +156,7 @@ sub cmd_test_webservices {
sub cmd_test_selenium {
my $conf = require $ENV{BZ_QA_CONF_FILE};
+ $ENV{HTTP_BACKEND} = 'simple';
check_data_dir();
copy_qa_extension();
diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl
new file mode 100755
index 000000000..bae6d514b
--- /dev/null
+++ b/scripts/rewrite2mojo.pl
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use 5.10.1;
+use strict;
+use warnings;
+use Mojo::Parameters;
+use Data::Dumper;
+
+while (<>) {
+ my ($cmd, @args) = split /\s+/, $_;
+ next unless $cmd;
+ if (lc($cmd) eq "\LRewriteRule") {
+ my ($regex, $target, $flags) = @args;
+ $flags //= '';
+ next if $flags =~ /E=HTTP/;
+ next if $target eq '-';
+ my $action = 'rewrite_query';
+ if ($flags =~ /R/) {
+ next;
+ }
+ my ($script, $query) = $target =~ /^([^?]+)(?:\?(.+))?$/;
+ my $name = _file_to_method($script);
+ $regex =~ s/^\^//;
+ $regex =~ s/\$$//;
+ my $regex_name = _regex_to_name($regex);
+ my $param_hash = Mojo::Parameters->new($query)->to_hash;
+ my $param_str = Data::Dumper->new([$param_hash])->Terse(1)->Indent(0)->Dump;
+ say "\$r->any('/:$regex_name' => [$regex_name => qr{$regex}])->to(";
+ say " 'CGI#$name' => $param_str";
+ say ");";
+
+ }
+ # elsif (lc($cmd) eq "\LRedirect") {
+ # my ($type, $path, $url) = @args;
+ # if ($type eq 'permanent') {
+ # say "if (\$path =~ m{^\Q$path\E}s) {";
+ # say " redirect(\$c, q{$url});";
+ # say " return;";
+ # say "}";
+ # }
+ # else {
+ # warn "I don't understand Redirect $type\n";
+ # }
+ # }
+}
+
+sub _file_to_method {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ return $name;
+}
+
+sub _regex_to_name {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ $name =~ s/_+/_/g;
+ $name =~ s/^_//s;
+ $name =~ s/_$//s;
+ return $name;
+}
+
+
diff --git a/scripts/undo.pl b/scripts/undo.pl
index 24d6f594b..24d6f594b 100644..100755
--- a/scripts/undo.pl
+++ b/scripts/undo.pl
diff --git a/t/001compile.t b/t/001compile.t
index e81162056..3d8d82bf4 100644
--- a/t/001compile.t
+++ b/t/001compile.t
@@ -35,7 +35,7 @@ sub compile_file {
my ($file) = @_;
# Don't allow CPAN.pm to modify the global @INC, which the version
- # shipped with Perl 5.8.8 does. (It gets loaded by
+ # shipped with Perl 5.8.8 does. (It gets loaded by
# Bugzilla::Install::CPAN.)
local @INC = @INC;
@@ -43,10 +43,6 @@ sub compile_file {
skip "$file: extensions not tested", 1;
return;
}
- if ($file =~ /ModPerl/) {
- skip "$file: ModPerl stuff not tested", 1;
- return;
- }
if ($file =~ s/\.pm$//) {
$file =~ s{/}{::}g;
@@ -82,7 +78,7 @@ my $file_features = map_files_to_features();
# Test the scripts by compiling them
foreach my $file (@testitems) {
# These were already compiled, above.
- next if ($file eq 'Bugzilla.pm'
+ next if ($file eq 'Bugzilla.pm'
or $file eq 'Bugzilla/Constants.pm'
or $file eq 'Bugzilla/Install/Requirements.pm');
SKIP: {
@@ -94,10 +90,10 @@ foreach my $file (@testitems) {
skip "$file: $feature not enabled", 1;
}
- # Check that we have a DBI module to support the DB, if this
+ # Check that we have a DBI module to support the DB, if this
# is a database module (but not Schema)
if ($file =~ m{Bugzilla/DB/([^/]+)\.pm$}
- and $file ne "Bugzilla/DB/Schema.pm")
+ and $file ne "Bugzilla/DB/Schema.pm")
{
my $module = lc($1);
Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1;
@@ -105,4 +101,4 @@ foreach my $file (@testitems) {
compile_file($file);
}
-}
+}
diff --git a/t/002goodperl.t b/t/002goodperl.t
index 5f201160b..80d7cf2b9 100644
--- a/t/002goodperl.t
+++ b/t/002goodperl.t
@@ -83,6 +83,7 @@ foreach my $file (@testitems) {
my $found_use_strict = 0;
my $found_use_warnings = 0;
my $found_modern_perl = 0;
+ my $found_mojo = 0;
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
next if (!$file); # skip null entries
@@ -92,13 +93,17 @@ foreach my $file (@testitems) {
}
while (my $file_line = <FILE>) {
$found_modern_perl = 1 if $file_line =~ m/^use\s*(?:Moo|Role::Tiny)/;
+ $found_mojo = 1 if $file_line =~ m/^use\s(?:Mojo(?:licious::Lite|::Base)\b)/;
$found_use_perl = 1 if $file_line =~ m/^\s*use 5.10.1/;
$found_use_strict = 1 if $file_line =~ m/^\s*use strict/;
$found_use_warnings = 1 if $file_line =~ m/^\s*use warnings/;
- if ($found_modern_perl) {
+ if ($found_modern_perl || $found_mojo) {
$found_use_strict = 1;
$found_use_warnings = 1;
}
+ if ($found_mojo) {
+ $found_use_perl = 1;
+ }
last if ($found_use_perl && $found_use_strict && $found_use_warnings);
}
close (FILE);
diff --git a/template/en/default/global/header.html.tmpl b/template/en/default/global/header.html.tmpl
index 153137394..17cac3cb8 100644
--- a/template/en/default/global/header.html.tmpl
+++ b/template/en/default/global/header.html.tmpl
@@ -97,6 +97,8 @@
[% IF Param('utf8') %]
<meta charset="UTF-8">
[% END %]
+ [% USE Bugzilla %]
+ <base href="[% urlbase FILTER html %]">
[% IF Bugzilla.cgi.should_block_referrer %]
<meta name="referrer" content="origin">
diff --git a/vagrant_support/apache.yml b/vagrant_support/apache.yml
index 5031187e3..2d65965ab 100644
--- a/vagrant_support/apache.yml
+++ b/vagrant_support/apache.yml
@@ -6,8 +6,8 @@
mode: 0644
when: LAZY == 0
-- name: enable httpd
- service: name=httpd enabled=yes
+- name: disable httpd
+ service: name=httpd enabled=no
when: LAZY == 0
- name: ensure bugzilla.log has right permissions
@@ -16,5 +16,5 @@
- name: ensure bugzilla-json.log has right permissions
file: path=/vagrant/logs/bugzilla-json.log state=touch owner=vagrant group=apache mode=0660
-- name: restart httpd
- service: name=httpd state=restarted \ No newline at end of file
+- name: stop httpd
+ service: name=httpd state=stopped
diff --git a/vagrant_support/hypnotoad b/vagrant_support/hypnotoad
new file mode 100755
index 000000000..af6a600f3
--- /dev/null
+++ b/vagrant_support/hypnotoad
@@ -0,0 +1,121 @@
+#!/bin/bash
+#
+# bugzilla-push This starts, stops, and restarts the Bugzilla push
+# daemon, which manages syncronising bugzilla.mozilla.org and
+# third party bugzilla installs.
+#
+# chkconfig: 345 85 15
+# description: Bugzilla push daemon
+#
+### BEGIN INIT INFO
+# Provides: bugzilla-push
+# Required-Start: $local_fs $syslog MTA mysqld
+# Required-Stop: $local_fs $syslog MTA mysqld
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Start and stop the Bugzilla push daemon.
+# Description: The Bugzilla push daemon (bugzilla-pushd.pl)
+#
+#
+#
+### END INIT INFO
+
+NAME=`basename $0`
+
+#################
+# Configuration #
+#################
+
+# This should be the path to your Bugzilla
+BUGZILLA=/vagrant
+# Who owns the Bugzilla directory and files?
+USER=vagrant
+
+PERL5LIB="$BUGZILLA:$BUGZILLA/lib:$BUGZILLA/local/lib/perl5"
+export PERL5LIB
+export MOJO_MODE
+
+if [[ x$PORT == x ]]; then
+ PORT=80
+ export PORT
+fi
+
+# If you want to pass any options to the daemon (like -d for debugging)
+# specify it here.
+OPTIONS=""
+
+# You can also override the configuration by creating a
+# /etc/sysconfig/bugzilla-queue file so that you don't
+# have to edit this script.
+if [ -r /etc/sysconfig/$NAME ]; then
+ . /etc/sysconfig/$NAME
+fi
+
+##########
+# Script #
+##########
+
+RETVAL=0
+BIN="$BUGZILLA/local/bin/hypnotoad"
+PIDFILE="$BUGZILLA/hypnotoad.pid"
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+usage ()
+{
+ echo "Usage: service $NAME {start|stop|status|restart|condrestart}"
+ RETVAL=1
+}
+
+
+start ()
+{
+ if [[ -f $PIDFILE ]]; then
+ checkpid "$(cat $PIDFILE)" && return 0
+ fi
+ echo -n "Starting $NAME: "
+ daemon --pidfile=$PIDFILE --user=$USER "cd $BUGZILLA && $BIN bugzilla.pl >/dev/null"
+ ret=$?
+ [ $ret -eq "0" ] && touch /var/lock/subsys/$NAME
+ echo
+ return $ret
+}
+
+stop ()
+{
+ cd $BUGZILLA && $BIN bugzilla.pl --stop
+ rm -f /var/lock/subsys/$NAME
+}
+
+restart ()
+{
+ start
+}
+
+condrestart ()
+{
+ [ -e /var/lock/subsys/$NAME ] && restart || return 0
+}
+
+status ()
+{
+ if [[ -f $PIDFILE ]] && checkpid "$(cat $PIDFILE)"; then
+ echo hypnotoad is amazing
+ return 0
+ else
+ echo hypnotoad is not running
+ return 1
+ fi
+}
+
+case "$1" in
+ start) start; RETVAL=$? ;;
+ stop) stop; RETVAL=$? ;;
+ status) status; RETVAL=$?;;
+ restart) restart; RETVAL=$? ;;
+ condrestart) condrestart; RETVAL=$? ;;
+ *) usage ; RETVAL=2 ;;
+esac
+
+exit $RETVAL
diff --git a/vagrant_support/hypnotoad.yml b/vagrant_support/hypnotoad.yml
new file mode 100644
index 000000000..a66f9ba04
--- /dev/null
+++ b/vagrant_support/hypnotoad.yml
@@ -0,0 +1,27 @@
+- name: grant perl ability to listen to privledged ports
+ command: setcap 'cap_net_bind_service=+ep' /usr/bin/perl
+
+- name: hypnotoad daemon sysconfig
+ copy:
+ dest: /etc/sysconfig/hypnotoad
+ mode: 0644
+ content: |
+ BUGZILLA=/vagrant
+ USER=vagrant
+ MOJO_MODE=development
+
+- name: hypnotoad daemon init file
+ template:
+ dest: /etc/init.d/hypnotoad
+ src: hypnotoad
+ owner: root
+ group: root
+ mode: 0755
+
+- name: enable hypnotoad
+ service: name=hypnotoad enabled=yes
+ when: LAZY == 0
+
+- name: restart hypnotoad
+ service: name=hypnotoad state=restarted
+
diff --git a/vagrant_support/playbook.yml b/vagrant_support/playbook.yml
index c067eab05..82fbba4a2 100644
--- a/vagrant_support/playbook.yml
+++ b/vagrant_support/playbook.yml
@@ -222,5 +222,8 @@
- include_tasks: apache.yml
vars:
LAZY: 0
+ - include_tasks: hypnotoad.yml
+ vars:
+ LAZY: 0
- import_tasks: devtools.yml
diff --git a/vagrant_support/update.yml b/vagrant_support/update.yml
index c53a0554e..533da5b5e 100644
--- a/vagrant_support/update.yml
+++ b/vagrant_support/update.yml
@@ -20,4 +20,7 @@
LAZY: 1
- include_tasks: apache.yml
vars:
- LAZY: 1 \ No newline at end of file
+ LAZY: 1
+ - include_tasks: hypnotoad.yml
+ vars:
+ LAZY: 1