From ec2bcb4768cc662362eb942ec52af9fe1046afaa Mon Sep 17 00:00:00 2001 From: Kirill Miazine Date: Fri, 4 Nov 2016 23:33:07 +0100 Subject: [PATCH] New server, FileBin instead of $ENV{BFConfDir}, and custom Captcha The BuildFarm has migated to a new server, thus URLs needed updating. $ENV{BFConfDir} in require have been replaced by $RealBin set by FileBin(). Google's reCAPTCHA replaced by home-written math challenge. --- bf-alerts.pl | 4 +++- cgi-bin/addnotes.pl | 6 ++--- cgi-bin/envtest.pl | 2 +- cgi-bin/eximstatus.pl | 6 +++-- cgi-bin/get_bf_status_soap.pl | 5 ++--- cgi-bin/register-form.pl | 22 ++++++++----------- cgi-bin/register.pl | 34 ++++++++++------------------- cgi-bin/show_failures.pl | 5 ++--- cgi-bin/show_history.pl | 5 ++--- cgi-bin/show_log.pl | 4 ++-- cgi-bin/show_members.pl | 5 ++--- cgi-bin/show_stage_log.pl | 8 +++---- cgi-bin/show_status.pl | 4 ++-- cgi-bin/show_status_soap.pl | 8 ++----- cgi-bin/test.pl | 2 -- cgi-bin/typedefs.pl | 3 ++- cgi-bin/upgrade.pl | 6 ++--- schema/missing.sql | 2 +- scripts/approve_system.pl | 4 +++- scripts/delete_host.pl | 4 +++- scripts/delete_unlisted_branches.pl | 6 +++-- scripts/gen_alias_list.pl | 4 +++- scripts/list_buildsystems.pl | 4 +++- scripts/purge_old_logs.pl | 6 +++-- scripts/rename_system.pl | 4 +++- scripts/show_passwords.pl | 4 +++- 26 files changed, 79 insertions(+), 88 deletions(-) diff --git a/bf-alerts.pl b/bf-alerts.pl index 8c93210..c038f96 100755 --- a/bf-alerts.pl +++ b/bf-alerts.pl @@ -23,7 +23,9 @@ use vars qw($dbhost $dbname $dbuser $dbpass $dbport $default_host ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/cgi-bin/addnotes.pl b/cgi-bin/addnotes.pl index 11186dd..3a760a2 100755 --- a/cgi-bin/addnotes.pl +++ b/cgi-bin/addnotes.pl @@ -29,7 +29,8 @@ my $sysnotes = $query->param('sysnotes'); my $content = "animal=$animal\&sysnotes=$sysnotes"; -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -119,6 +120,3 @@ $db->disconnect; print "Content-Type: text/plain\n\n"; print "request was on:\n$content\n"; - - - diff --git a/cgi-bin/envtest.pl b/cgi-bin/envtest.pl index f86621f..998ff07 100644 --- a/cgi-bin/envtest.pl +++ b/cgi-bin/envtest.pl @@ -2,7 +2,7 @@ print "Content-Type: text/plain\n\n"; -print "Conf: $ENV{BFConfDir}\n"; +print "Conf: /home/farm/server\n"; print `pwd`; diff --git a/cgi-bin/eximstatus.pl b/cgi-bin/eximstatus.pl index 9f68757..af68f10 100755 --- a/cgi-bin/eximstatus.pl +++ b/cgi-bin/eximstatus.pl @@ -30,8 +30,10 @@ use Mail::Send; use Time::ParseDate; use Storable qw(thaw); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -my $buildlogs = "$ENV{BFConfDir}/buildlogs"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; + +my $buildlogs = "/home/farm/server/buildlogs"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/cgi-bin/get_bf_status_soap.pl b/cgi-bin/get_bf_status_soap.pl index 051f3f4..514de3b 100755 --- a/cgi-bin/get_bf_status_soap.pl +++ b/cgi-bin/get_bf_status_soap.pl @@ -11,8 +11,8 @@ See accompanying License file for license details use SOAP::Lite ; my $obj = SOAP::Lite - ->uri('http://eximbuild.mrball.net/EximBuildFarm') - ->proxy('http://eximbuild.mrball.net/cgi-bin/show_status_soap.pl') + ->uri('http://buildfarm.exim.org/EximBuildFarm') + ->proxy('http://buildfarm.exim.org/cgi-bin/show_status_soap.pl') ; my $data = $obj->get_status->result; @@ -32,4 +32,3 @@ foreach my $datum (@$data) my $line = join (' | ', @{$datum}{@fields}); print $line,"\n"; } - diff --git a/cgi-bin/register-form.pl b/cgi-bin/register-form.pl index 91d0826..4152776 100755 --- a/cgi-bin/register-form.pl +++ b/cgi-bin/register-form.pl @@ -10,25 +10,21 @@ See accompanying License file for license details use strict; use Template; -use Captcha::reCAPTCHA; -use vars qw( $template_dir $captcha_pubkey ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use vars qw( $template_dir ); - -my $c = Captcha::reCAPTCHA->new; - -my $captcha = $c->get_html($captcha_pubkey); +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $template_opts = { INCLUDE_PATH => $template_dir }; my $template = new Template($template_opts); print "Content-Type: text/html\n\n"; +my $argop = '+'; +$argop = '-' if time % 2; +my $arg1 = int(rand(100)); +$arg1 += 11 if $arg1 < 12; +my $arg2 = int(rand(10) + 1); -$template->process('register-form.tt',{captcha => $captcha}); - - - - - +$template->process('register-form.tt', {arg1 => $arg1, arg2 => $arg2, argop => $argop}); diff --git a/cgi-bin/register.pl b/cgi-bin/register.pl index 1e3aba4..80663b6 100755 --- a/cgi-bin/register.pl +++ b/cgi-bin/register.pl @@ -13,12 +13,12 @@ use DBI; use Template; use CGI; use Template; -use Captcha::reCAPTCHA; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp - $captcha_pubkey $captcha_privkey $template_dir $default_host); + $template_dir $default_host); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $dsn="dbi:Pg:dbname=$dbname"; $dsn .= ";host=$dbhost" if $dbhost; @@ -30,22 +30,18 @@ my $query = new CGI; my $params = $query->Vars; -my ($os, $osv, $comp, $compv, $arch, $email, $owner, $challenge, $response ) = - @{$params}{ - qw(os osv comp compv arch email owner recaptcha_challenge_field - recaptcha_response_field)}; - -my $captcha = Captcha::reCAPTCHA->new; -my $captcha_ok = $captcha->check_answer - ( - $captcha_privkey, - $ENV{'REMOTE_ADDR'}, - $challenge, $response - ); +my ($os, $osv, $comp, $compv, $arch, $email, $owner, $arg1, $arg2, $argop, $res ) = + @{$params}{qw(os osv comp compv arch email owner arg1 arg2 op res)}; +$argop = '-' if !$argop or $argop ne '+'; +$arg1 = int($arg1 || 0); +$arg2 = int($arg2 || 0); +$res = int($res || 0); +my $captcha_ok = ($arg1 and $argop and $arg2 and $res + and int(eval "$arg1 $argop $arg2") == $res) ? 1 : 0; unless ($os && $osv && $comp && $compv && $arch && $email && $owner && - $captcha_ok->{is_valid}) + $captcha_ok) { print "Content-Type: text/html\n\n"; $template->process('register-incomplete.tt'); @@ -162,9 +158,3 @@ print $fh "\n\nName: $dummyname\n", "Comp: $comp: $compv\n", "Owner: $owner <$email>\n"; $fh->close; - - - - - - diff --git a/cgi-bin/show_failures.pl b/cgi-bin/show_failures.pl index bfa38e9..592ab4f 100755 --- a/cgi-bin/show_failures.pl +++ b/cgi-bin/show_failures.pl @@ -15,8 +15,8 @@ use CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir); - -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $query = new CGI; my @members = grep {$_ ne "" } $query->param('member'); @@ -149,4 +149,3 @@ $template->process('fstatus.tt', qstages => \@stages} ); exit; - diff --git a/cgi-bin/show_history.pl b/cgi-bin/show_history.pl index 2b822ca..c57a617 100755 --- a/cgi-bin/show_history.pl +++ b/cgi-bin/show_history.pl @@ -15,9 +15,8 @@ use CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir); - -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -#require "BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/cgi-bin/show_log.pl b/cgi-bin/show_log.pl index 7fea634..ab3d3cd 100755 --- a/cgi-bin/show_log.pl +++ b/cgi-bin/show_log.pl @@ -16,7 +16,8 @@ use CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir @log_file_names $local_git_clone); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $template_opts = { INCLUDE_PATH => $template_dir, EVAL_PERL => 1}; my $template = new Template($template_opts); @@ -240,4 +241,3 @@ sub process_changed } return (\@changed_rows,\@commit_logs); } - diff --git a/cgi-bin/show_members.pl b/cgi-bin/show_members.pl index 6c7ea90..f35c66a 100755 --- a/cgi-bin/show_members.pl +++ b/cgi-bin/show_members.pl @@ -15,8 +15,8 @@ use Template; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir $sort_by); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -#require "BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $query = new CGI; my %sort_ok = ('name' => 'lower(name)' , @@ -99,4 +99,3 @@ $template->process('members.tt', {statrows=>$statrows}); exit; - diff --git a/cgi-bin/show_stage_log.pl b/cgi-bin/show_stage_log.pl index fc40fa6..38ccf89 100755 --- a/cgi-bin/show_stage_log.pl +++ b/cgi-bin/show_stage_log.pl @@ -16,9 +16,8 @@ use File::Temp qw(tempfile); use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names); - -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -#require "BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -80,7 +79,7 @@ if ($system && $logdate && $stage) "-------------------------------------------------\n\n", "Hosting for the Exim BuildFarm is generously ", - "provided by: Todd Lyons"; + "provided by: Host1"; } @@ -89,4 +88,3 @@ else print "Status: 460 bad parameters\n", "Content-Type: text/plain\n\n"; } - diff --git a/cgi-bin/show_status.pl b/cgi-bin/show_status.pl index 04c918c..f371bdc 100755 --- a/cgi-bin/show_status.pl +++ b/cgi-bin/show_status.pl @@ -15,8 +15,8 @@ use CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir); - -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $query = new CGI; my @members = $query->param('member'); diff --git a/cgi-bin/show_status_soap.pl b/cgi-bin/show_status_soap.pl index e44f8d1..82a6dc7 100755 --- a/cgi-bin/show_status_soap.pl +++ b/cgi-bin/show_status_soap.pl @@ -12,7 +12,8 @@ use strict; use vars qw($dbhost $dbname $dbuser $dbpass $dbport); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; use SOAP::Transport::HTTP; @@ -76,8 +77,3 @@ EOS } 1; - - - - - diff --git a/cgi-bin/test.pl b/cgi-bin/test.pl index 9b179d2..bc7a04f 100755 --- a/cgi-bin/test.pl +++ b/cgi-bin/test.pl @@ -20,5 +20,3 @@ url = $url base = $base EOF - - diff --git a/cgi-bin/typedefs.pl b/cgi-bin/typedefs.pl index 63c0fc5..b70a92e 100755 --- a/cgi-bin/typedefs.pl +++ b/cgi-bin/typedefs.pl @@ -16,7 +16,8 @@ my $query = new CGI; use vars qw($dbhost $dbname $dbuser $dbpass $dbport); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; my $dsn="dbi:Pg:dbname=$dbname"; $dsn .= ";host=$dbhost" if $dbhost; diff --git a/cgi-bin/upgrade.pl b/cgi-bin/upgrade.pl index a34f4ed..e16fe8e 100755 --- a/cgi-bin/upgrade.pl +++ b/cgi-bin/upgrade.pl @@ -33,7 +33,8 @@ my $content = "animal=$animal\&ts=$ts"; $content .= "\&new_os=$os_version" if $os_version; $content .= "\&new_compiler=$compiler_version" if $compiler_version; -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -152,6 +153,3 @@ $db->disconnect; print "Content-Type: text/plain\n\n"; print "request was on:\n$content\n"; - - - diff --git a/schema/missing.sql b/schema/missing.sql index 23adcc4..e73998d 100644 --- a/schema/missing.sql +++ b/schema/missing.sql @@ -3,7 +3,7 @@ -- CREATE VIEW build_status_recent_500 AS - SELECT bs.sysname, bs.status, bs.snapshot, bs.stage, bs.conf_sum, bs.branch, bs.changed_this_run, bs.changed_since_success, bs.log_archive_filenames, bs.build_flags, bs.report_time, bs.log FROM build_status AS bs WHERE ((build_status.snapshot + '3 mons'::interval) > ('now'::text)::timestamp(6) with time zone); + SELECT bs.sysname, bs.status, bs.snapshot, bs.stage, bs.conf_sum, bs.branch, bs.changed_this_run, bs.changed_since_success, bs.log_archive_filenames, bs.build_flags, bs.report_time, bs.log FROM build_status AS bs WHERE ((bs.snapshot + '3 mons'::interval) > ('now'::text)::timestamp(6) with time zone); ALTER TABLE public.build_status_recent_500 OWNER TO eximbuild; diff --git a/scripts/approve_system.pl b/scripts/approve_system.pl index 55424c9..330fad0 100755 --- a/scripts/approve_system.pl +++ b/scripts/approve_system.pl @@ -12,7 +12,9 @@ use vars qw($dbhost $dbname $dbuser $dbpass $dbport $user_list_format $default_host $mail_from ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/scripts/delete_host.pl b/scripts/delete_host.pl index 1c1baad..0a77e0f 100755 --- a/scripts/delete_host.pl +++ b/scripts/delete_host.pl @@ -10,7 +10,9 @@ die "Must pass one and only one sysname to delete\n" use vars qw($dbhost $dbname $dbuser $dbpass $dbport ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/scripts/delete_unlisted_branches.pl b/scripts/delete_unlisted_branches.pl index fd37fd2..2dba66c 100755 --- a/scripts/delete_unlisted_branches.pl +++ b/scripts/delete_unlisted_branches.pl @@ -7,7 +7,9 @@ use Data::Dumper; use vars qw($dbhost $dbname $dbuser $dbpass $dbport ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -21,7 +23,7 @@ my $db = DBI->connect($dsn,$dbuser,$dbpass); die $DBI::errstr unless $db; my ($brhandle,@branches_of_interest); -if (open($brhandle,"$ENV{BFConfDir}/htdocs/branches_of_interest.txt")) +if (open($brhandle,"/home/farm/server/htdocs/branches_of_interest.txt")) { @branches_of_interest = <$brhandle>; close($brhandle); diff --git a/scripts/gen_alias_list.pl b/scripts/gen_alias_list.pl index 477c058..46fca5b 100755 --- a/scripts/gen_alias_list.pl +++ b/scripts/gen_alias_list.pl @@ -9,7 +9,9 @@ use Getopt::Long; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $user_list_format ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/scripts/list_buildsystems.pl b/scripts/list_buildsystems.pl index f64bdbc..69df1fb 100755 --- a/scripts/list_buildsystems.pl +++ b/scripts/list_buildsystems.pl @@ -8,7 +8,9 @@ use Data::Dumper; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $user_list_format ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/scripts/purge_old_logs.pl b/scripts/purge_old_logs.pl index 7182f0d..ad267bd 100755 --- a/scripts/purge_old_logs.pl +++ b/scripts/purge_old_logs.pl @@ -10,7 +10,9 @@ use Data::Dumper; use vars qw($dbhost $dbname $dbuser $dbpass $dbport ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -35,7 +37,7 @@ my $del_recent_sth = $db->prepare(q[ $del_sth->execute(); $del_recent_sth->execute(); -my $buildlogs = "$ENV{BFConfDir}/buildlogs"; +my $buildlogs = "/home/farm/server/buildlogs"; my @dirs = `find $buildlogs -mindepth 1 -type d -ctime +95`; foreach my $dir (@dirs) { diff --git a/scripts/rename_system.pl b/scripts/rename_system.pl index 9e320cb..9cee13f 100755 --- a/scripts/rename_system.pl +++ b/scripts/rename_system.pl @@ -10,7 +10,9 @@ die "Must pass current and new sysnames\n" unless scalar @ARGV == 2; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $user_list_format ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; diff --git a/scripts/show_passwords.pl b/scripts/show_passwords.pl index 687896f..073d248 100755 --- a/scripts/show_passwords.pl +++ b/scripts/show_passwords.pl @@ -8,7 +8,9 @@ use Data::Dumper; use vars qw($dbhost $dbname $dbuser $dbpass $dbport $user_list_format ); -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; -- 2.30.2