From fe52fe9957ce904a57f856716046276e8db72697 Mon Sep 17 00:00:00 2001 From: "justdave%syndicomm.com" <> Date: Thu, 7 Jun 2001 04:17:39 +0000 Subject: Fix for bug 21253: removing all single-parameter system() calls from Bugzilla Patch by Dave Miller r= tara@tequilarista.org --- checksetup.pl | 6 +++--- collectstats.pl | 4 ++-- globals.pl | 23 +++++++++++++++++++++-- process_bug.cgi | 4 ++-- syncshadowdb | 7 +++++-- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/checksetup.pl b/checksetup.pl index 672371fa6..68d72b39e 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -1233,7 +1233,7 @@ CheckEnumField('bugs', 'rep_platform', @my_platforms); # that login, if it doesn't exist already, and make it a member of all groups. sub bailout { # this is just in case we get interrupted while getting passwd - system("stty echo"); # re-enable input echoing + system("stty","echo"); # re-enable input echoing exit 1; } @@ -1313,7 +1313,7 @@ _End_Of_SQL_ $SIG{QUIT} = \&bailout; $SIG{TERM} = \&bailout; - system("stty -echo"); # disable input echoing + system("stty","-echo"); # disable input echoing while( $pass1 ne $pass2 ) { while( $pass1 eq "" ) { @@ -1334,7 +1334,7 @@ _End_Of_SQL_ } } - system("stty echo"); # re-enable input echoing + system("stty","echo"); # re-enable input echoing $SIG{HUP} = 'DEFAULT'; # and remove our interrupt hooks $SIG{INT} = 'DEFAULT'; $SIG{QUIT} = 'DEFAULT'; diff --git a/collectstats.pl b/collectstats.pl index e36a3ca90..4e69ab9b5 100755 --- a/collectstats.pl +++ b/collectstats.pl @@ -131,8 +131,8 @@ sub calculate_dupes { # Save % count here in a date-named file # so we can read it back in to do changed counters # First, delete it if it exists, so we don't add to the contents of an old file - if () { - system("rm -f data/duplicates/dupes$today*"); + if (my @files = ) { + unlink @files; } dbmopen(%count, "data/duplicates/dupes$today", 0644) || die "Can't open DBM dupes file: $!"; diff --git a/globals.pl b/globals.pl index e81363673..8d539f035 100644 --- a/globals.pl +++ b/globals.pl @@ -109,8 +109,27 @@ sub ReconnectToShadowDatabase { my $shadowchanges = 0; sub SyncAnyPendingShadowChanges { if ($shadowchanges) { - system("./syncshadowdb &"); - $shadowchanges = 0; + my $pid; + FORK: { + if ($pid = fork) { # create a fork + # parent code runs here + $shadowchanges = 0; + return; + } elsif (defined $pid) { + # child process code runs here + exec("./syncshadowdb",[]) or die "Unable to exec syncshadowdb: $!"; + # passing the empty list as a second parameter tricks it into + # using execvp instead of running a shell, but still doesn't + # pass any parameters to syncshadowdb + } elsif ($! =~ /No more process/) { + # recoverable fork error, try again in 5 seconds + sleep 5; + redo FORK; + } else { + # something weird went wrong + die "Can't create background process to run syncshadowdb: $!"; + } + } } } diff --git a/process_bug.cgi b/process_bug.cgi index b2327b0fd..81f6846b8 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -993,7 +993,7 @@ The changes made were: print "

Changes to bug $id submitted

\n"; SendSQL("unlock tables"); - my @ARGLIST = ("./processmail"); + my @ARGLIST = (); if ( $removedCcString ne "" ) { push @ARGLIST, ("-forcecc", $removedCcString); } @@ -1004,7 +1004,7 @@ The changes made were: push @ARGLIST, ( "-forceqacontact", $origQaContact); } push @ARGLIST, ($id, $::FORM{'who'}); - system @ARGLIST; + system ("./processmail",@ARGLIST); print "
Back To BUG# $id
\n"; diff --git a/syncshadowdb b/syncshadowdb index 94e492044..985bd16b8 100755 --- a/syncshadowdb +++ b/syncshadowdb @@ -156,10 +156,13 @@ if ($syncall) { } Verbose("Locking entire database"); SendSQL($query); - my $tablelist = join(' ', @tables); my $tempfile = "data/tmpsyncshadow.$$"; Verbose("Dumping database to a temp file ($tempfile)."); - system("mysqldump -l -e $db_name $tablelist > $tempfile"); + open SAVEOUT, ">&STDOUT"; # stash the original output stream + open STDOUT, ">$tempfile"; # redirect to file + select STDOUT; $| = 1; # disable buffering + system("mysqldump","-l","-e",$db_name,@tables); + open STDOUT, ">&SAVEOUT"; # redirect back to original stream Verbose("Restoring from tempfile into shadowdb"); my $extra = ""; if ($verbose) { -- cgit v1.2.3-24-g4f1b