From 4d55f265b801efb52ea49abe3fcdc9c34c4763c2 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Mon, 11 Oct 2010 18:56:19 +0200 Subject: Bug 550097: checksetup.pl should detect when run via a web server (cgi) and fail with a sane error r/a=mkanat --- Bugzilla/Install/Util.pm | 8 +++++++- checksetup.pl | 3 +++ template/en/default/setup/strings.txt.pl | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 50cbfd2a8..14744ef8c 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -298,7 +298,7 @@ sub _wanted_languages { # Checking SERVER_SOFTWARE is the same as i_am_cgi() in Bugzilla::Util. if (exists $ENV{'SERVER_SOFTWARE'}) { - my $cgi = Bugzilla->cgi; + my $cgi = eval { Bugzilla->cgi } || eval { require CGI; return CGI->new() }; $requested = $cgi->http('Accept-Language') || ''; my $lang = $cgi->cookie('LANG'); push(@wanted, $lang) if $lang; @@ -504,6 +504,12 @@ sub vers_cmp { @A <=> @B; } +sub no_checksetup_from_cgi { + print "Content-Type: text/html; charset=UTF-8\r\n\r\n"; + print install_string('no_checksetup_from_cgi'); + exit; +} + ###################### # Helper Subroutines # ###################### diff --git a/checksetup.pl b/checksetup.pl index b6b4fc19c..6d9230dd9 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -60,6 +60,9 @@ use Bugzilla::Install::Util qw(install_string get_version_and_os # Live Code ###################################################################### +# Do not run checksetup.pl from the web browser. +Bugzilla::Install::Util::no_checksetup_from_cgi() if $ENV{'SERVER_SOFTWARE'}; + # When we're running at the command line, we need to pick the right # language before ever displaying any string. init_console(); diff --git a/template/en/default/setup/strings.txt.pl b/template/en/default/setup/strings.txt.pl index f03869205..ca1bf6145 100644 --- a/template/en/default/setup/strings.txt.pl +++ b/template/en/default/setup/strings.txt.pl @@ -336,6 +336,31 @@ WARNING: We are about to convert your table storage format to UTF-8. This If you ever used a version of Bugzilla before 2.22, we STRONGLY recommend that you stop checksetup.pl NOW and run contrib/recode.pl. +END + no_checksetup_from_cgi => < + + + checksetup.pl cannot run from a web browser + + + +

checksetup.pl cannot run from a web browser

+

+ You must not execute this script from your web browser. + To install or upgrade Bugzilla, run this script from + the command-line (e.g. bash or ssh on Linux + or cmd.exe on Windows), and follow instructions given there. +

+ +

+ For more information on how to install Bugzilla, please + read the documentation + available on the official Bugzilla website. +

+ + END patchutils_missing => <<'END', OPTIONAL NOTE: If you want to be able to use the 'difference between two -- cgit v1.2.3-24-g4f1b