Commit ccaf82a2 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 224588: Unify ($^O =~ /MSWin/) checks (always use ON_WINDOWS)

Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
parent 120fc1b9
...@@ -21,26 +21,25 @@ ...@@ -21,26 +21,25 @@
# Byron Jones <bugzilla@glob.com.au> # Byron Jones <bugzilla@glob.com.au>
# Marc Schumann <wurblzap@gmail.com> # Marc Schumann <wurblzap@gmail.com>
package Bugzilla::CGI;
use strict; use strict;
package Bugzilla::CGI; use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Util;
BEGIN { BEGIN {
if ($^O =~ /MSWin32/i) { if (ON_WINDOWS) {
# Help CGI find the correct temp directory as the default list # Help CGI find the correct temp directory as the default list
# isn't Windows friendly (Bug 248988) # isn't Windows friendly (Bug 248988)
$ENV{'TMPDIR'} = $ENV{'TEMP'} || $ENV{'TMP'} || "$ENV{'WINDIR'}\\TEMP"; $ENV{'TMPDIR'} = $ENV{'TEMP'} || $ENV{'TMP'} || "$ENV{'WINDIR'}\\TEMP";
} }
} }
use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers SERVER_PUSH); use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles
:unique_headers SERVER_PUSH);
use base qw(CGI); use base qw(CGI);
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Util;
# We need to disable output buffering - see bug 179174 # We need to disable output buffering - see bug 179174
$| = 1; $| = 1;
......
...@@ -297,7 +297,7 @@ sub check_mail_delivery_method { ...@@ -297,7 +297,7 @@ sub check_mail_delivery_method {
my $check = check_multi(@_); my $check = check_multi(@_);
return $check if $check; return $check if $check;
my $mailer = shift; my $mailer = shift;
if ($mailer eq 'sendmail' && $^O =~ /MSWin32/i) { if ($mailer eq 'sendmail' and ON_WINDOWS) {
# look for sendmail.exe # look for sendmail.exe
return "Failed to locate " . SENDMAIL_EXE return "Failed to locate " . SENDMAIL_EXE
unless -e SENDMAIL_EXE; unless -e SENDMAIL_EXE;
......
...@@ -430,13 +430,13 @@ use constant DB_MODULE => { ...@@ -430,13 +430,13 @@ use constant DB_MODULE => {
name => 'Oracle'}, name => 'Oracle'},
}; };
# The user who should be considered "root" when we're giving
# instructions to Bugzilla administrators.
use constant ROOT_USER => $^O =~ /MSWin32/i ? 'Administrator' : 'root';
# True if we're on Win32. # True if we're on Win32.
use constant ON_WINDOWS => ($^O =~ /MSWin32/i); use constant ON_WINDOWS => ($^O =~ /MSWin32/i);
# The user who should be considered "root" when we're giving
# instructions to Bugzilla administrators.
use constant ROOT_USER => ON_WINDOWS ? 'Administrator' : 'root';
use constant MIN_SMALLINT => -32768; use constant MIN_SMALLINT => -32768;
use constant MAX_SMALLINT => 32767; use constant MAX_SMALLINT => 32767;
......
...@@ -267,7 +267,7 @@ if ($webdotbase =~ /^https?:/) { ...@@ -267,7 +267,7 @@ if ($webdotbase =~ /^https?:/) {
close $pngfh; close $pngfh;
# On Windows $pngfilename will contain \ instead of / # On Windows $pngfilename will contain \ instead of /
$pngfilename =~ s|\\|/|g if $^O eq 'MSWin32'; $pngfilename =~ s|\\|/|g if ON_WINDOWS;
# Under mod_perl, pngfilename will have an absolute path, and we # Under mod_perl, pngfilename will have an absolute path, and we
# need to make that into a relative path. # need to make that into a relative path.
......
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
###Compilation### ###Compilation###
use strict; use strict;
use lib qw(. lib t);
use lib 't'; use Bugzilla::Constants;
use Support::Files; use Support::Files;
use Test::More tests => scalar(@Support::Files::testitems); use Test::More tests => scalar(@Support::Files::testitems);
...@@ -94,7 +93,7 @@ foreach my $file (@testitems) { ...@@ -94,7 +93,7 @@ foreach my $file (@testitems) {
# Special hack due to CPAN.pm on Windows with Cygwin installed throwing # Special hack due to CPAN.pm on Windows with Cygwin installed throwing
# strings of the form "Set up gcc environment - 3.4.4 (cygming special, # strings of the form "Set up gcc environment - 3.4.4 (cygming special,
# gdc 0.12, using dmd 0.125)". See bug 416047 for details. # gdc 0.12, using dmd 0.125)". See bug 416047 for details.
if ($^O =~ /MSWin32/i if (ON_WINDOWS
&& grep($_ eq $file, 'install-module.pl', 'Bugzilla/Install/CPAN.pm')) && grep($_ eq $file, 'install-module.pl', 'Bugzilla/Install/CPAN.pm'))
{ {
$loginfo =~ s/^Set up gcc environment.*?\n//; $loginfo =~ s/^Set up gcc environment.*?\n//;
......
...@@ -30,10 +30,11 @@ ...@@ -30,10 +30,11 @@
# Sample exploit code: '>"><script>alert('Oh dear...')</script> # Sample exploit code: '>"><script>alert('Oh dear...')</script>
use strict; use strict;
use lib 't'; use lib qw(. lib t);
use vars qw(%safe); use vars qw(%safe);
use Bugzilla::Constants;
use Support::Templates; use Support::Templates;
use File::Spec; use File::Spec;
use Test::More tests => $Support::Templates::num_actual_files; use Test::More tests => $Support::Templates::num_actual_files;
...@@ -45,7 +46,7 @@ my $topdir = cwd; ...@@ -45,7 +46,7 @@ my $topdir = cwd;
$/ = undef; $/ = undef;
foreach my $path (@Support::Templates::include_paths) { foreach my $path (@Support::Templates::include_paths) {
$path =~ s|\\|/|g if $^O eq 'MSWin32'; # convert \ to / in path if on windows $path =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows
$path =~ m|template/([^/]+)/([^/]+)|; $path =~ m|template/([^/]+)/([^/]+)|;
my $lang = $1; my $lang = $1;
my $flavor = $2; my $flavor = $2;
...@@ -66,7 +67,7 @@ foreach my $path (@Support::Templates::include_paths) { ...@@ -66,7 +67,7 @@ foreach my $path (@Support::Templates::include_paths) {
} }
else { else {
do "filterexceptions.pl"; do "filterexceptions.pl";
if ($^O eq 'MSWin32') { if (ON_WINDOWS) {
# filterexceptions.pl uses / separated paths, while # filterexceptions.pl uses / separated paths, while
# find_actual_files returns \ separated ones on Windows. # find_actual_files returns \ separated ones on Windows.
# Here, we convert the filter exception hash to use \. # Here, we convert the filter exception hash to use \.
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
######Errors###### ######Errors######
use strict; use strict;
use lib qw(. lib t);
use lib 't'; use Bugzilla::Constants;
use Bugzilla::WebService::Constants; use Bugzilla::WebService::Constants;
use File::Spec; use File::Spec;
...@@ -60,7 +60,7 @@ foreach my $include_path (@include_paths) { ...@@ -60,7 +60,7 @@ foreach my $include_path (@include_paths) {
foreach my $path (@{$actual_files{$include_path}}) { foreach my $path (@{$actual_files{$include_path}}) {
my $file = File::Spec->catfile($include_path, $path); my $file = File::Spec->catfile($include_path, $path);
$file =~ s/\s.*$//; # nuke everything after the first space $file =~ s/\s.*$//; # nuke everything after the first space
$file =~ s|\\|/|g if $^O eq 'MSWin32'; # convert \ to / in path if on windows $file =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows
$test_templates{$file} = () $test_templates{$file} = ()
if $file =~ m#global/(code|user)-error\.html\.tmpl#; if $file =~ m#global/(code|user)-error\.html\.tmpl#;
} }
......
...@@ -42,7 +42,7 @@ if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/)) ...@@ -42,7 +42,7 @@ if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/))
# Try to determine the GID used by the web server. # Try to determine the GID used by the web server.
my @pscmds = ('ps -eo comm,gid', 'ps -acxo command,gid', 'ps -acxo command,rgid'); my @pscmds = ('ps -eo comm,gid', 'ps -acxo command,gid', 'ps -acxo command,rgid');
my $sgid = 0; my $sgid = 0;
if ($^O !~ /MSWin32/i) { if (!ON_WINDOWS) {
foreach my $pscmd (@pscmds) { foreach my $pscmd (@pscmds) {
open PH, "$pscmd 2>/dev/null |"; open PH, "$pscmd 2>/dev/null |";
while (my $line = <PH>) { while (my $line = <PH>) {
...@@ -83,7 +83,7 @@ Please refer to the web server configuration section of the Bugzilla guide. ...@@ -83,7 +83,7 @@ Please refer to the web server configuration section of the Bugzilla guide.
If you are using virtual hosts or suexec, this warning may not apply.\n"; If you are using virtual hosts or suexec, this warning may not apply.\n";
} }
} }
elsif ($^O !~ /MSWin32/i) { elsif (!ON_WINDOWS) {
print print
"TEST-WARNING Failed to find the GID for the 'httpd' process, unable "TEST-WARNING Failed to find the GID for the 'httpd' process, unable
to validate webservergroup.\n"; to validate webservergroup.\n";
...@@ -138,7 +138,7 @@ if ($@ eq '') { ...@@ -138,7 +138,7 @@ if ($@ eq '') {
# Ensure major versions of GD and libgd match # Ensure major versions of GD and libgd match
# Windows's GD module include libgd.dll, guaranteed to match # Windows's GD module include libgd.dll, guaranteed to match
if ($^O !~ /MSWin32/i) { if (!ON_WINDOWS) {
my $gdlib = `gdlib-config --version 2>&1` || ""; my $gdlib = `gdlib-config --version 2>&1` || "";
$gdlib =~ s/\n$//; $gdlib =~ s/\n$//;
if (!$gdlib) { if (!$gdlib) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment