From 693d63dda2563a40a827d5673ed1811a6b05e342 Mon Sep 17 00:00:00 2001 From: "bbaetz%student.usyd.edu.au" Date: Mon, 17 Jun 2002 09:39:00 +0000 Subject: [PATCH] Bug 151053, ConnectToDatabase/quietly_check_login sometimes not called early enough r=mattyt, jouni --- webtools/bugzilla/buglist.cgi | 34 ++++++++++++------------ webtools/bugzilla/colchange.cgi | 2 +- webtools/bugzilla/createaccount.cgi | 3 +++ webtools/bugzilla/describecomponents.cgi | 4 +-- webtools/bugzilla/doeditparams.cgi | 2 +- webtools/bugzilla/editcomponents.cgi | 1 + webtools/bugzilla/editgroups.cgi | 1 + webtools/bugzilla/editkeywords.cgi | 1 + webtools/bugzilla/editmilestones.cgi | 1 + webtools/bugzilla/editparams.cgi | 1 + webtools/bugzilla/editproducts.cgi | 1 + webtools/bugzilla/editusers.cgi | 1 + webtools/bugzilla/editversions.cgi | 1 + webtools/bugzilla/move.pl | 2 +- webtools/bugzilla/post_bug.cgi | 2 +- webtools/bugzilla/process_bug.cgi | 3 +-- webtools/bugzilla/queryhelp.cgi | 5 ++-- webtools/bugzilla/quips.cgi | 5 ++++ webtools/bugzilla/sidebar.cgi | 4 +-- webtools/bugzilla/token.cgi | 1 + webtools/bugzilla/userprefs.cgi | 2 ++ webtools/bugzilla/xml.cgi | 5 ++-- 22 files changed, 49 insertions(+), 33 deletions(-) diff --git a/webtools/bugzilla/buglist.cgi b/webtools/bugzilla/buglist.cgi index b649b8f1e158..06eff56054d8 100755 --- a/webtools/bugzilla/buglist.cgi +++ b/webtools/bugzilla/buglist.cgi @@ -66,14 +66,28 @@ ConnectToDatabase(); # Data and Security Validation ################################################################################ +# Whether or not the user wants to change multiple bugs. +my $dotweak = $::FORM{'tweak'} ? 1 : 0; + +# Log the user in +if ($dotweak) { + confirm_login(); + if (!UserInGroup("editbugs")) { + DisplayError("Sorry, you do not have sufficient privileges to edit + multiple bugs."); + exit; + } + GetVersionTable(); +} +else { + quietly_check_login(); +} + # Determine the format in which the user would like to receive the output. # Uses the default format if the user did not specify an output format; # otherwise validates the user's choice against the list of available formats. my $format = ValidateOutputFormat($::FORM{'format'}, "list"); -# Whether or not the user wants to change multiple bugs. -my $dotweak = $::FORM{'tweak'} ? 1 : 0; - # Use server push to display a "Please wait..." message for the user while # executing their query if their browser supports it and they are viewing # the bug list as HTML and they have not disabled it by adding &serverpush=0 @@ -137,20 +151,6 @@ if ($::FORM{'cmdtype'} eq 'runnamed') { $filename =~ s/\s//; } -if ($dotweak) { - confirm_login(); - if (!UserInGroup("editbugs")) { - DisplayError("Sorry, you do not have sufficient privileges to edit - multiple bugs."); - exit; - } - GetVersionTable(); -} -else { - quietly_check_login(); -} - - ################################################################################ # Utilities ################################################################################ diff --git a/webtools/bugzilla/colchange.cgi b/webtools/bugzilla/colchange.cgi index 5e6857724b56..64dd9c4a5dcb 100755 --- a/webtools/bugzilla/colchange.cgi +++ b/webtools/bugzilla/colchange.cgi @@ -34,6 +34,7 @@ use vars qw( require "CGI.pl"; +ConnectToDatabase(); quietly_check_login(); print "Content-type: text/html\n"; @@ -41,7 +42,6 @@ print "Content-type: text/html\n"; # The master list not only says what fields are possible, but what order # they get displayed in. -ConnectToDatabase(); GetVersionTable(); my @masterlist = ("opendate", "changeddate", "severity", "priority", diff --git a/webtools/bugzilla/createaccount.cgi b/webtools/bugzilla/createaccount.cgi index ff07da7829e4..577ab8dba69a 100755 --- a/webtools/bugzilla/createaccount.cgi +++ b/webtools/bugzilla/createaccount.cgi @@ -42,6 +42,9 @@ ConnectToDatabase(); # If we're using LDAP for login, then we can't create a new account here. if(Param('useLDAP')) { + # Just in case someone already has an account, let them get the correct + # footer on the error message + quietly_check_login(); DisplayError("This site is using LDAP for authentication. Please contact an LDAP administrator to get a new account created.", "Can't create LDAP accounts"); diff --git a/webtools/bugzilla/describecomponents.cgi b/webtools/bugzilla/describecomponents.cgi index 8ae98260b3b5..2f723757e73a 100755 --- a/webtools/bugzilla/describecomponents.cgi +++ b/webtools/bugzilla/describecomponents.cgi @@ -34,10 +34,10 @@ use lib qw(.); require "CGI.pl"; ConnectToDatabase(); -GetVersionTable(); - quietly_check_login(); +GetVersionTable(); + if (!defined $::FORM{'product'}) { # Reference to a subset of %::proddesc, which the user is allowed to see my %products; diff --git a/webtools/bugzilla/doeditparams.cgi b/webtools/bugzilla/doeditparams.cgi index 7390333c0d51..3e97e140bc06 100755 --- a/webtools/bugzilla/doeditparams.cgi +++ b/webtools/bugzilla/doeditparams.cgi @@ -33,7 +33,7 @@ use vars %::param, %::param_default, @::param_list; - +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editcomponents.cgi b/webtools/bugzilla/editcomponents.cgi index f48566906209..4f76593df667 100755 --- a/webtools/bugzilla/editcomponents.cgi +++ b/webtools/bugzilla/editcomponents.cgi @@ -188,6 +188,7 @@ sub PutTrailer (@) # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editgroups.cgi b/webtools/bugzilla/editgroups.cgi index fe8b32ff7cba..9c93363c00b2 100755 --- a/webtools/bugzilla/editgroups.cgi +++ b/webtools/bugzilla/editgroups.cgi @@ -29,6 +29,7 @@ use lib "."; require "CGI.pl"; +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editkeywords.cgi b/webtools/bugzilla/editkeywords.cgi index 4b6f7635677f..51294206dcb1 100755 --- a/webtools/bugzilla/editkeywords.cgi +++ b/webtools/bugzilla/editkeywords.cgi @@ -108,6 +108,7 @@ sub Validate ($$) { # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editmilestones.cgi b/webtools/bugzilla/editmilestones.cgi index 63e27b440e53..fccf7253362c 100755 --- a/webtools/bugzilla/editmilestones.cgi +++ b/webtools/bugzilla/editmilestones.cgi @@ -146,6 +146,7 @@ sub PutTrailer (@) # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editparams.cgi b/webtools/bugzilla/editparams.cgi index dc6febb957ce..40f5ad537bf6 100755 --- a/webtools/bugzilla/editparams.cgi +++ b/webtools/bugzilla/editparams.cgi @@ -32,6 +32,7 @@ require "defparams.pl"; use vars @::param_desc, @::param_list; +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editproducts.cgi b/webtools/bugzilla/editproducts.cgi index 611a9810011d..1b3441a8a390 100755 --- a/webtools/bugzilla/editproducts.cgi +++ b/webtools/bugzilla/editproducts.cgi @@ -175,6 +175,7 @@ sub PutTrailer (@) # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editusers.cgi b/webtools/bugzilla/editusers.cgi index ebc07f2e40dd..f9800c704a81 100755 --- a/webtools/bugzilla/editusers.cgi +++ b/webtools/bugzilla/editusers.cgi @@ -231,6 +231,7 @@ sub PutTrailer (@) # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/editversions.cgi b/webtools/bugzilla/editversions.cgi index fafdb5683aef..950d597a798f 100755 --- a/webtools/bugzilla/editversions.cgi +++ b/webtools/bugzilla/editversions.cgi @@ -155,6 +155,7 @@ sub PutTrailer (@) # Preliminary checks: # +ConnectToDatabase(); confirm_login(); print "Content-type: text/html\n\n"; diff --git a/webtools/bugzilla/move.pl b/webtools/bugzilla/move.pl index b20ee528ba72..66a75f95fbb7 100755 --- a/webtools/bugzilla/move.pl +++ b/webtools/bugzilla/move.pl @@ -37,6 +37,7 @@ unless ( Param("move-enabled") ) { } ConnectToDatabase(); +confirm_login(); sub Log { my ($str) = (@_); @@ -80,7 +81,6 @@ if ( !defined $::FORM{'buglist'} ) { exit; } -confirm_login(); my $exporter = $::COOKIE{"Bugzilla_login"}; my $movers = Param("movers"); $movers =~ s/\w?,\w?/|/g; diff --git a/webtools/bugzilla/post_bug.cgi b/webtools/bugzilla/post_bug.cgi index c04e34db0f44..fe08711911a9 100755 --- a/webtools/bugzilla/post_bug.cgi +++ b/webtools/bugzilla/post_bug.cgi @@ -50,6 +50,7 @@ sub sillyness { # Use global template variables. use vars qw($vars $template); +ConnectToDatabase(); confirm_login(); @@ -89,7 +90,6 @@ if (defined $::FORM{'maketemplate'}) { } umask 0; -ConnectToDatabase(); # Some sanity checking if(Param("usebuggroupsentry") && GroupExists($product)) { diff --git a/webtools/bugzilla/process_bug.cgi b/webtools/bugzilla/process_bug.cgi index e64cdac76d1f..db19916a35b7 100755 --- a/webtools/bugzilla/process_bug.cgi +++ b/webtools/bugzilla/process_bug.cgi @@ -53,6 +53,7 @@ use vars qw(%versions %superusergroupset $next_bug); +ConnectToDatabase(); my $whoid = confirm_login(); my $requiremilestone = 0; @@ -124,8 +125,6 @@ if ( Param("usetargetmilestone") ) { CheckFormFieldDefined(\%::FORM, 'target_milestone'); } -ConnectToDatabase(); - # # This function checks if there is a comment required for a specific # function and tests, if the comment was given. diff --git a/webtools/bugzilla/queryhelp.cgi b/webtools/bugzilla/queryhelp.cgi index 3b2da379fda7..48a4e08552c3 100755 --- a/webtools/bugzilla/queryhelp.cgi +++ b/webtools/bugzilla/queryhelp.cgi @@ -32,6 +32,8 @@ use lib qw(.); require "CGI.pl"; ConnectToDatabase(); +quietly_check_login(); + GetVersionTable(); print "Content-type: text/html\n\n"; @@ -558,8 +560,6 @@ user with the proper permissions can edit these keywords. The following is a lis stored on this version of Bugzilla: }; -ConnectToDatabase(); - my $tableheader = qq{

@@ -609,7 +609,6 @@ while (MoreSQLData()) { print "

\n"; -quietly_check_login(); if (UserInGroup("editkeywords")) { print qq{

Edit keywords\n}; diff --git a/webtools/bugzilla/quips.cgi b/webtools/bugzilla/quips.cgi index e685fb2070c3..7441f51fc197 100755 --- a/webtools/bugzilla/quips.cgi +++ b/webtools/bugzilla/quips.cgi @@ -34,6 +34,11 @@ use lib qw(.); require "CGI.pl"; +# Even though quips aren't (yet) in the database, we need to check +# logins for the footer +ConnectToDatabase(); +quietly_check_login(); + my $action = $::FORM{'action'} || ""; if ($action eq "show") { diff --git a/webtools/bugzilla/sidebar.cgi b/webtools/bugzilla/sidebar.cgi index 2f1b92a6910e..a7e0587f58d3 100755 --- a/webtools/bugzilla/sidebar.cgi +++ b/webtools/bugzilla/sidebar.cgi @@ -29,13 +29,11 @@ use vars qw( ); ConnectToDatabase(); +quietly_check_login(); # Needed for $::anyvotesallowed GetVersionTable(); -# Check to see if the user has logged in yet. -quietly_check_login(); - ############################################################################### # Main Body Execution ############################################################################### diff --git a/webtools/bugzilla/token.cgi b/webtools/bugzilla/token.cgi index e1ae0b35b3e2..72406223f374 100755 --- a/webtools/bugzilla/token.cgi +++ b/webtools/bugzilla/token.cgi @@ -37,6 +37,7 @@ require "CGI.pl"; # Establish a connection to the database backend. ConnectToDatabase(); +quietly_check_login(); # Use the "Token" module that contains functions for doing various # token-related tasks. diff --git a/webtools/bugzilla/userprefs.cgi b/webtools/bugzilla/userprefs.cgi index 2205dd61a17d..649008864497 100755 --- a/webtools/bugzilla/userprefs.cgi +++ b/webtools/bugzilla/userprefs.cgi @@ -359,6 +359,8 @@ sub DoPermissions { ############################################################################### # Live code (not subroutine definitions) starts here ############################################################################### + +ConnectToDatabase(); confirm_login(); GetVersionTable(); diff --git a/webtools/bugzilla/xml.cgi b/webtools/bugzilla/xml.cgi index f35a13cd9f70..8a0bbf1e451e 100755 --- a/webtools/bugzilla/xml.cgi +++ b/webtools/bugzilla/xml.cgi @@ -32,6 +32,9 @@ require "CGI.pl"; use vars qw($template $vars); +ConnectToDatabase(); +quietly_check_login(); + if (!defined $::FORM{'id'} || !$::FORM{'id'}) { print "Content-Type: text/html\n\n"; $template->process("bug/choose-xml.html.tmpl", $vars) @@ -39,8 +42,6 @@ if (!defined $::FORM{'id'} || !$::FORM{'id'}) { exit; } -quietly_check_login(); - my $exporter = $::COOKIE{"Bugzilla_login"} || undef; my @ids = split (/[, ]+/, $::FORM{'id'});