Bug #5575 mysqlhotcopy is broken when using --noindices
Submitted: 14 Sep 2004 18:00 Modified: 7 Oct 2004 17:13
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.0.21 OS:Linux (Debian GNU/Linux)
Assigned to: CPU Architecture:Any

[14 Sep 2004 18:00] Christian Hammers
Description:
Hello Sergei

Debian user Martin Pitt just complained in
  http://bugs.debian.org/271632
that mysqlhotcopy has been broken in the last release. 

Seems your fix to the latest mysqlhotcopy security problem (http://lists.mysql.com/internals/15185) has been included without being presented to the Quality Assurance :-)

And there are even *two* bugs!

bye,

-christian-

How to repeat:

Bug #1

# mysqlhotcopy --method="scp"  test  ch@localhost:/tmp/  --noindices
Locked 3 tables in 0 seconds.
Flushed tables (`test`.`articles`, `test`.`i`, `test`.`partall`) in 0 seconds.
Copying 5 files...
Password: 
Copying indices for 2 files...
Undefined subroutine &main::tempfile called at /usr/bin/mysqlhotcopy line 642.

(Fix with "qw(tempfile)" after the "use File::Temp")

Bug #2

# mysqlhotcopy --method="scp"  test  ch@localhost:/tmp/  --noindices
Locked 3 tables in 0 seconds.
Flushed tables (`test`.`articles`, `test`.`i`, `test`.`partall`) in 0 seconds.
Copying 5 files...
Password: 
Copying indices for 2 files...
Can't create/open file in /tmp

(There's some kind of "or" missing before the die although tempfile() probably dies itself)
     my ($fh, $tmp)=tempfile('mysqlhotcopy-XXXXXX', DIR => $opt_tmpdir);
     die "Can\'t create/open file in $opt_tmpdir\n";

Suggested fix:
Martin was so kind to produce a patch for it. Please check if tempfile really dies itself, though.

http://make.it.work.again.no-name-yet.com/patches/mysql-dfsg.fix-hotcopy.diff
[7 Oct 2004 17:13] Jani Tolonen
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[19 Oct 2004 22:04] Christian Hammers
You might want to fix that bug in 4.1.6, too...

--- old/scripts/mysqlhotcopy.sh.orig    2004-09-14 10:47:56.000000000 +0200
+++ new/scripts/mysqlhotcopy.sh 2004-09-14 10:49:44.000000000 +0200
@@ -8,7 +8,7 @@
 use DBI;
 use Sys::Hostname;
 use File::Copy;
-use File::Temp;
+use File::Temp qw/ tempfile /;
 
 =head1 NAME
 
@@ -655,7 +655,6 @@
     elsif ($opt{method} =~ /^scp\b/)
     {
       my ($fh, $tmp)=tempfile('mysqlhotcopy-XXXXXX', DIR => $opt_tmpdir);
-      die "Can\'t create/open file in $opt_tmpdir\n";
       if (syswrite($fh,$buff) != length($buff))
       {
        die "Error when writing data to $tmp: $!\n";