From 53edeadb0ca0eefa039a11ff7a4a269e1fe6f228 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" Date: Fri, 25 Feb 2005 01:02:47 +0000 Subject: [PATCH] checking in changes that have been hanging around here for way too long --- webtools/despot/despot.cgi | 72 ++++++++++++++++++++++++++++---------- webtools/despot/syncit.pl | 12 +++---- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/webtools/despot/despot.cgi b/webtools/despot/despot.cgi index bd6a978c41ac..35fcf57dad24 100755 --- a/webtools/despot/despot.cgi +++ b/webtools/despot/despot.cgi @@ -28,8 +28,8 @@ use diagnostics; # a few configurables # -my $despotOwnerMailTo = "mailto:endico\@mozilla.org"; -my $despotOwner = "endico"; +my $despotOwnerMailTo = "mailto:sysadmins\@mozilla.org"; +my $despotOwner = "sysadmins"; # Shut up misguided -w warnings about "used only once". "use vars" just # doesn't work for me. @@ -68,10 +68,19 @@ if (!defined $::despot) { # (f.e. AddUser) result in PrintHeader() getting called twice. $::header_done = 0; +$::disabled = ""; +#$::disabled = "Despot is temporarily disabled. Please try again later."; +if ($::disabled) { + PrintHeader(); + print h1("Despot -- access control for mozilla.org."); + print p($::disabled); + exit; +} + if (!param()) { PrintHeader(); print h1("Despot -- access control for mozilla.org."); - if (!exists $ENV{"HTTPS"} || $ENV{"HTTPS"} ne "ON") { + if (!exists $ENV{"HTTPS"} || lc($ENV{"HTTPS"}) ne "on") { my $fixedurl = "https://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}"; print b("If possible, please use the " . a({href=>$fixedurl}, "secure version of this form") . @@ -91,7 +100,7 @@ import_names("F"); # Makes all form values available as F::. use Mysql; -$::db = Mysql->Connect("localhost", "mozusers", $F::loginname, "") +$::db = Mysql->Connect(undef, "mozusers", "root", "") || die "Can't connect to database server"; @@ -205,7 +214,9 @@ sub PrintHeader { sub PrintLoginForm { - print start_form(-method=>$::POSTTYPE); + # CGI seems to be misbehaving; creating the form tag manually as a workaround. + print qq|
\n|; +# print start_form(-method=>$::POSTTYPE); print table(Tr(th({-align=>"right"}, "Email address:"), td(textfield(-name=>"loginname", -size=>20))), @@ -719,40 +730,61 @@ sub ViewAccount { sub FindPartition { my $repid = $F::repid; my $file = $F::file; - my $query = Query("select files.pattern,partitions.name,partitions.id from files,partitions where partitions.id=files.partitionid and partitions.repositoryid=$repid"); + # Excludes the mozilla-toplevel module which would otherwise always match. + my $query = Query("select files.pattern,partitions.name,partitions.id from files,partitions where partitions.id=files.partitionid and partitions.repositoryid=$repid and files.pattern != 'mozilla/%'"); my @matches = (); while (@row = $query->fetchrow()) { my ($pattern,$name,$id) = (@row); if (FileMatches($file, $pattern) || FileMatches($pattern, $file)) { push(@matches, { 'name' => $name, 'id' => $id, 'pattern' => $pattern }); } + elsif ($file !~ /^mozilla(-org)?\// + && (FileMatches("mozilla/$file", $pattern) + || FileMatches($pattern, "mozilla/$file") + || FileMatches("mozilla-org/$file", $pattern) + || FileMatches($pattern, "mozilla-org/$file"))) + { + push(@matches, { 'name' => $name, 'id' => $id, 'pattern' => $pattern }); + } } if (scalar(@matches) > 0) { # The "view" parameter means the request came from the "look up owners of file" # form on the owners page, so we should redirect the user to the anchor on that - # page for the first matching module. - if (param("view")) { + # page for a single match. + if (scalar(@matches) == 1 && param("view")) { print "Location: http://www.mozilla.org/owners.html#$matches[0]->{name}\n\n"; exit; } PrintHeader(); print h1("Searching for partitions matching $file ..."); foreach my $match (@matches) { - print MyForm("EditPartition") . - hidden("partitionid", $match->{id}) . - submit($match->{name}) . - "(matches pattern $match->{pattern})" . - end_form(); + if (param("view")) { + # This should display modules just as they are displayed + # on owners.html, but that code is embedded into syncit.pl. + print qq|Module: $match->{name} + (matches pattern $match->{pattern})
\n|; + } + else { + print MyForm("EditPartition") . + hidden("partitionid", $match->{id}) . + submit($match->{name}) . + "(matches pattern $match->{pattern})" . + end_form(); + } } } else { PrintHeader(); print h1("Searching for partitions matching $file ..."); print "No partitions found."; - if ($file !~ /^mozilla/) { - print p("Generally, your filename should start with mozilla/ or mozilla-org/."); - } + } + + if (param("view")) { + # No need for the footer with the "Main Menu" button + # for "look up owners of file" users. + print "\n"; + exit; } } @@ -1034,7 +1066,9 @@ sub ChangePassword { PrintHeader(); print h1("Change your mozilla.org password."); $F::loginpassword = ""; - print start_form($::POSTTYPE); + # CGI seems to be misbehaving; creating the form tag manually as a workaround. + print qq|\n|; +# print start_form(-method=>$::POSTTYPE); print hidden("loginname", $F::loginname); print hidden(-name=>"command", -default=>"SetNewPassword", @@ -1080,7 +1114,9 @@ sub SetNewPassword { sub MyForm { my ($command) = @_; - my $result = start_form($::POSTTYPE) . hidden("loginname", $F::loginname) . + # CGI seems to be misbehaving; creating the form tag manually as a workaround. + my $result = qq|| . + hidden("loginname", $F::loginname) . hidden("_despot") . hidden("loginpassword", $F::loginpassword) . hidden(-name=>"command", -value=>$command, -override=>1); diff --git a/webtools/despot/syncit.pl b/webtools/despot/syncit.pl index fd3fd5615fe8..16d23aec8ace 100755 --- a/webtools/despot/syncit.pl +++ b/webtools/despot/syncit.pl @@ -22,18 +22,18 @@ # $F::debug = 1; -$cvs = "/opt/cvs-tools/bin/cvs"; -$whoami = "/usr/ucb/whoami"; +#$cvs = "/opt/cvs-tools/bin/cvs"; +#$whoami = "/usr/ucb/whoami"; #$perlbin = "/tools/ns/bin/perl5.004"; -#$cvs = "/usr/bin/cvs"; -#$whoami = "/usr/bin/whoami"; +$cvs = "/usr/bin/cvs"; +$whoami = "/usr/bin/whoami"; $perlbin = "/usr/bin/perl"; #$curdir = `pwd`; #chop($curdir); #$ENV{"CVS_PASSFILE"} = "$curdir/.cvspass"; - +$ENV{"CVS_RSH"} = "ssh"; $ENV{"CVS_PASSFILE"} = "/usr/local/etc/despot-cvspass"; $dontcommit = 0; @@ -58,7 +58,7 @@ chdir $srcdir || die "Couldn't chdir to $srcdir"; use Mysql; require 'utils.pl'; -$db = Mysql->Connect("localhost", "mozusers") +$db = Mysql->Connect("localhost", "mozusers", "root") || die "Can't connect to database server"; $db = $db; # Make -w shut up.