diff options
author | justdave%syndicomm.com <> | 2001-06-11 02:38:15 +0200 |
---|---|---|
committer | justdave%syndicomm.com <> | 2001-06-11 02:38:15 +0200 |
commit | 87b2b80d808ec802ab744418510650edc98307ec (patch) | |
tree | cd51421306268b41776ddf6efc05aea27fdef371 | |
parent | 808408770704c74994a322632c334d248dbc189b (diff) | |
download | bugzilla-87b2b80d808ec802ab744418510650edc98307ec.tar.gz bugzilla-87b2b80d808ec802ab744418510650edc98307ec.tar.xz |
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
-rwxr-xr-x | syncshadowdb | 19 |
1 files 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"; |