From 87b2b80d808ec802ab744418510650edc98307ec Mon Sep 17 00:00:00 2001 From: "justdave%syndicomm.com" <> Date: Mon, 11 Jun 2001 00:38:15 +0000 Subject: Fix for bug 84596: Syncshadowdb wasn't using the db_user and db_pass from localconfig, which meant that it previously wouldn't run unless it was running under a user that had access to the bugs and shadowbugs dbs and didn't have a password. It now looks for db_user and db_pass and specifies them on the command line to mysqldump and mysql if they're in use. r= tara --- syncshadowdb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/syncshadowdb b/syncshadowdb index 471b6d6ad..4733dbb58 100755 --- a/syncshadowdb +++ b/syncshadowdb @@ -72,9 +72,6 @@ sub Verbose ($) { } } } - -my $db_name = "bugs"; -require "localconfig"; if (!Param("shadowdb")) { Verbose("We don't have shadow databases turned on; no syncing performed."); @@ -101,7 +98,7 @@ if (!FetchOneColumn()) { exit; } -my $shadowtable = "$db_name.shadowlog"; +my $shadowtable = "$::db_name.shadowlog"; if (!$syncall) { Verbose("Looking for requests to sync the whole database."); @@ -147,7 +144,7 @@ if ($syncall) { # into the shadowdb database. Then mark everything in the shadowlog # as reflected. Only then unlock everything. This sequence causes # us to be sure not to miss anything or get something twice. - SendSQL("USE $db_name"); + SendSQL("USE $::db_name"); SendSQL("SHOW TABLES"); @tables = (); $query = "LOCK TABLES shadowlog WRITE"; @@ -162,15 +159,21 @@ if ($syncall) { SendSQL($query); my $tempfile = "data/tmpsyncshadow.$$"; Verbose("Dumping database to a temp file ($tempfile)."); + my @ARGS = ("-u", $::db_user); + if ($::db_pass) { push @ARGS, "-p$::db_pass" } + push @ARGS, "-l", "-e", $::db_name, @tables; 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); + system("mysqldump", @ARGS); open STDOUT, ">&SAVEOUT"; # redirect back to original stream Verbose("Restoring from tempfile into shadowdb"); - my $extra = ""; + my $extra = "-u $::db_user"; + if ($::db_pass) { + $extra .= " -p$::db_pass"; + } if ($verbose) { - $extra = "-v"; + $extra .= " -v"; } open(MYSQL, "cat $tempfile | mysql $extra " . Param("shadowdb") . "|") || die "Couldn't do db copy"; -- cgit v1.2.3-24-g4f1b