From paddy at zmanda.com Wed Feb 3 17:14:22 2010 From: paddy at zmanda.com (Paddy Sreenivasan) Date: Wed, 3 Feb 2010 17:14:22 -0800 Subject: [mysql-zrm-users] mysql-zrm-verify-backup failing In-Reply-To: <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> References: <4B59B537.4080409@robinbowes.com> <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> Message-ID: <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> Thanks for the patch. Modifications were made to the match to make it easier to understand. This fix will be part of 2.2 release. Paddy On Fri, Jan 22, 2010 at 2:22 PM, Paddy Sreenivasan wrote: > thanks Robin. > > Let me check and get back to you. > > Paddy > > On Fri, Jan 22, 2010 at 6:24 AM, Robin Bowes wrote: >> Hi, >> >> I've noticed that mysql-zrm-verify-backup doesn't work correctly if you >> append a trailing slash to the --source-directory specified on the >> command-line. >> >> eg. this works: >> >> mysql-zrm-verify-backup --source-directory >> /var/lib/mysql-zrm/b016-project/20100122100515 --backup-set b016-project >> >> this doesn't: >> >> mysql-zrm-verify-backup --source-directory >> /var/lib/mysql-zrm/b016-project/20100122100515/ --backup-set b016-project >> >> I've tracked it down to a trailing slash in the key used to get the md5 >> sum from the checksum file in verifyCMForFile(): >> >> sub verifyCMForFile() >> { >> ? ? ? ?my $sep = "/"; >> ? ? ? ?if( $^O eq "MSWin32" ) { >> ? ? ? ? ? ? ? ?$sep = "\\"; >> ? ? ? ?} >> ? ? ? ?my $dir = $_[2]; >> ? ? ? ?my $newSum=$_[1]; >> ? ? ? ?my $x = $_[0]; >> ? ? ? ?my $file = $x; >> ? ? ? ?my $p = $dir; >> ? ? ? ?$p =~ s{(?:\Q$sep\E)*$}{$sep}; >> ? ? ? ?$x=~/$p/; >> ? ? ? ?$x = catfile($indexdata{"backup-directory"}, $' ); >> ? ? ? ?my $oldSum=$indexdata{$x} >> >> This code fails if $dir has a separator at the end. >> >> Here's a patch that fixes the issue: >> >> --- mysql-zrm-verify-backup.orig ? ? ? ?2009-08-25 18:51:13.000000000 +0000 >> +++ mysql-zrm-verify-backup ? ? 2010-01-22 14:03:54.000000000 +0000 >> @@ -85,8 +85,8 @@ >> ? ? ? ? my $newSum=$_[1]; >> ? ? ? ?my $x = $_[0]; >> ? ? ? ?my $file = $x; >> - ? ? ? ?my $p = $dir.$sep; >> - ? ? ? $x=~/$p/; >> + ? ? ? ?$dir =~ s{(?:\Q$sep\E)*$}{$sep}; # make sure $dir has exactly >> one separator char at the end >> + ? ? ? $x=~/$dir/; >> ? ? ? ?$x = catfile($indexdata{"backup-directory"}, $' ); >> ? ? ? ?my $oldSum=$indexdata{$x}; >> ? ? ? ?if(defined $oldSum && $newSum eq $oldSum){ >> >> It's arguable whether or not the input parameters should be sanitised >> when they are processed to ensure that things like trailing slashes are >> consistent throughout the code. >> >> R. >> _______________________________________________ >> More information on ZRM for MySQL is available at http://http://www.zmanda.com/mysql-backup.html >> To Unsubscribe send a blank email to mysql-zrm-users-unsubscribe at zmanda.com >> > > > > -- > Amanda http://amanda.zmanda.com > ZRM for MySQL http://www.zmanda.com/backup-mysql.html > -- Amanda http://amanda.zmanda.com ZRM for MySQL http://www.zmanda.com/backup-mysql.html From robin-lists at robinbowes.com Wed Feb 3 17:24:57 2010 From: robin-lists at robinbowes.com (Robin Bowes) Date: Thu, 04 Feb 2010 01:24:57 +0000 Subject: [mysql-zrm-users] mysql-zrm-verify-backup failing In-Reply-To: <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> References: <4B59B537.4080409@robinbowes.com> <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> Message-ID: <4B6A21E9.5080206@robinbowes.com> On 04/02/10 01:14, Paddy Sreenivasan wrote: > Thanks for the patch. Modifications were made to the match to make it > easier to understand. This fix > will be part of 2.2 release. Can I take a look at it? R. From paddy at zmanda.com Wed Feb 3 17:43:38 2010 From: paddy at zmanda.com (Paddy Sreenivasan) Date: Wed, 3 Feb 2010 17:43:38 -0800 Subject: [mysql-zrm-users] mysql-zrm-verify-backup failing In-Reply-To: <4B6A21E9.5080206@robinbowes.com> References: <4B59B537.4080409@robinbowes.com> <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> <4B6A21E9.5080206@robinbowes.com> Message-ID: <88f60b861002031743n26623c33k9385707156bfded2@mail.gmail.com> @@ -85,8 +85,8 @@ my $newSum=$_[1]; my $x = $_[0]; my $file = $x; - my $p = $dir.$sep; - $x=~/$p/; + $dir=~ s/$sep*$/$sep/; # make sure $dir has exactly one separator char at the end + $x=~/$dir/; $x = catfile($indexdata{"backup-directory"}, $' ); my $oldSum=$indexdata{$x}; if(defined $oldSum && $newSum eq $oldSum){ On Wed, Feb 3, 2010 at 5:24 PM, Robin Bowes wrote: > On 04/02/10 01:14, Paddy Sreenivasan wrote: >> Thanks for the patch. Modifications were made to the match to make it >> easier to understand. This fix >> will be part of 2.2 release. > > Can I take a look at it? > > R. > -- Amanda http://amanda.zmanda.com ZRM for MySQL http://www.zmanda.com/backup-mysql.html From robin-lists at robinbowes.com Wed Feb 3 18:02:46 2010 From: robin-lists at robinbowes.com (Robin Bowes) Date: Thu, 04 Feb 2010 02:02:46 +0000 Subject: [mysql-zrm-users] mysql-zrm-verify-backup failing In-Reply-To: <88f60b861002031743n26623c33k9385707156bfded2@mail.gmail.com> References: <4B59B537.4080409@robinbowes.com> <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> <4B6A21E9.5080206@robinbowes.com> <88f60b861002031743n26623c33k9385707156bfded2@mail.gmail.com> Message-ID: <4B6A2AC6.8050109@robinbowes.com> On 04/02/10 01:43, Paddy Sreenivasan wrote: > + $dir=~ s/$sep*$/$sep/; # make sure $dir has exactly one > separator char at the end Paddy, I'm all for simplification to aid better understanding, but that will fail on windows, ie. if $sep = "\\". Try it: $ perl -e '$sep = q{\\} ; $dir = q{c:\\some\\path\\\\\\} ; $dir=~ s/$sep*$/$sep/; print "dir: $dir\n"' dir: c:\some\path\\\ The non-capturing group is not required if you're sure that separator will never be more than one character, and the braces instead of slashes are just a matter of personal style but you need to escape $sep with \Q and \E at the very least: $ perl -e '$sep = q{\\} ; $dir = q{c:\\some\\path\\\\\\} ; $dir=~ s/\Q$sep\E*$/$sep/; print "dir: $dir\n"' dir: c:\some\path\ R. From paddy at zmanda.com Wed Feb 3 18:11:08 2010 From: paddy at zmanda.com (Paddy Sreenivasan) Date: Wed, 3 Feb 2010 18:11:08 -0800 Subject: [mysql-zrm-users] mysql-zrm-verify-backup failing In-Reply-To: <4B6A2AC6.8050109@robinbowes.com> References: <4B59B537.4080409@robinbowes.com> <88f60b861001221422j56369737ja2b064a1be0b8ff4@mail.gmail.com> <88f60b861002031714g75ef445hb0e819b1b7f09f0c@mail.gmail.com> <4B6A21E9.5080206@robinbowes.com> <88f60b861002031743n26623c33k9385707156bfded2@mail.gmail.com> <4B6A2AC6.8050109@robinbowes.com> Message-ID: <88f60b861002031811r1f43a4fwddf45c5d6dc5f419@mail.gmail.com> You are correct. We did not test this code on Windows. Paddy On Wed, Feb 3, 2010 at 6:02 PM, Robin Bowes wrote: > On 04/02/10 01:43, Paddy Sreenivasan wrote: > >> + ? ? ? $dir=~ s/$sep*$/$sep/; # make sure $dir has exactly one >> separator char at the end > > Paddy, > > I'm all for simplification to aid better understanding, but that will > fail on windows, ie. if $sep = "\\". > > Try it: > > $ perl -e '$sep = q{\\} ; $dir = q{c:\\some\\path\\\\\\} ; $dir=~ > s/$sep*$/$sep/; print "dir: $dir\n"' > dir: c:\some\path\\\ > > The non-capturing group is not required if you're sure that separator > will never be more than one character, and the braces instead of slashes > are just a matter of personal style but you need to escape $sep with \Q > and \E at the very least: > > $ perl -e '$sep = q{\\} ; $dir = q{c:\\some\\path\\\\\\} ; $dir=~ > s/\Q$sep\E*$/$sep/; print "dir: $dir\n"' > dir: c:\some\path\ > > R. > -- Amanda http://amanda.zmanda.com ZRM for MySQL http://www.zmanda.com/backup-mysql.html