* Fixed stupid last-minute change in octal size conversion in
[BackupPC.git] / lib / BackupPC / Xfer / Smb.pm
index 5e1df82..eec4447 100644 (file)
@@ -11,7 +11,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
-#   Copyright (C) 2001-2003  Craig Barratt
+#   Copyright (C) 2001  Craig Barratt
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
-# Version 2.1.0_CVS, released 3 Jul 2003.
+# Version 2.0.2, released 6 Oct 2003.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -121,9 +121,11 @@ sub start
                };
            }
        }
+       $t->{fileIncludeHash} = {};
         if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) {
             foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) {
                push(@fileList, $file);
+               $t->{fileIncludeHash}{$file} = 1;
             }
         } elsif ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) {
             foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} )
@@ -224,6 +226,11 @@ sub readOutput
     while ( $t->{smbOut} =~ /(.*?)[\n\r]+(.*)/s ) {
         $_ = $1;
         $t->{smbOut} = $2;
+       #
+       # ignore the log file time stamps from smbclient introduced
+       # in version 3.0.0 - don't even write them to the log file.
+       #
+       next if ( m{^\[\d+/\d+/\d+ +\d+:\d+:\d+.*\] +(client/cli|lib/util_unistr).*\(\d+\)} );
         $t->{XferLOG}->write(\"$_\n");
         #
         # refresh our inactivity alarm
@@ -245,30 +252,49 @@ sub readOutput
         } elsif ( /restore tar file (.*) of size (\d+) bytes/ ) {
             $t->{byteCnt} += $2;
             $t->{fileCnt}++;
-        } elsif ( /tar: dumped \d+ files/ ) {
+        } elsif ( /^\s*tar: dumped \d+ files/ ) {
             $t->{xferOK} = 1;
-        } elsif ( /^tar: restored \d+ files/ ) {
+        } elsif ( /^\s*tar: restored \d+ files/ ) {
             $t->{xferOK} = 1;
-        } elsif ( /^read_socket_with_timeout: timeout read. /i ) {
+        } elsif ( /^\s*read_socket_with_timeout: timeout read. /i ) {
             $t->{hostAbort} = 1;
         } elsif ( /^code 0 listing /
-                    || /^code 0 opening /
-                    || /^abandoning restore/i
-                    || /^Error: Looping in FIND_NEXT/i
-                    || /^SUCCESS - 0/i
-                    || /^Call timed out: server did not respond/i
+                    || /^\s*code 0 opening /
+                    || /^\s*abandoning restore/i
+                    || /^\s*Error: Looping in FIND_NEXT/i
+                    || /^\s*SUCCESS - 0/i
+                    || /^\s*Call timed out: server did not respond/i
+                   || /^\s*tree connect failed: ERRDOS - ERRnoaccess \(Access denied\.\)/
+                   || /^\s*tree connect failed: NT_STATUS_BAD_NETWORK_NAME/
                  ) {
-            $t->{hostError} ||= $_;
+           if ( $t->{hostError} eq "" ) {
+               $t->{XferLOG}->write(\"This backup will fail because: $_\n");
+               $t->{hostError} = $_;
+           }
+        } elsif ( /^\s*NT_STATUS_ACCESS_DENIED listing (.*)/
+              || /^\s*ERRDOS - ERRnoaccess \(Access denied\.\) listing (.*)/ ) {
+           my $badDir = $1;
+           $badDir =~ s{\\}{/}g;
+           $badDir =~ s{/+}{/}g;
+           $badDir =~ s{/\*$}{};
+           if ( $t->{hostError} eq ""
+                   && ($badDir eq "" || $t->{fileIncludeHash}{$badDir}) ) {
+               $t->{XferLOG}->write(\"This backup will fail because: $_\n");
+               $t->{hostError} ||= $_;
+           }
         } elsif ( /smb: \\>/
-                || /^added interface/i
-                || /^tarmode is now/i
-                || /^Total bytes written/i
-                || /^Domain=/i
+                || /^\s*added interface/i
+                || /^\s*tarmode is now/i
+                || /^\s*Total bytes written/i
+                || /^\s*Domain=/i
                 || /^\([\d\.]* kb\/s\) \(average [\d\.]* kb\/s\)$/i
-                || /^Getting files newer than/i
-                || /^\s+directory \\/i
-                || /^Output is \/dev\/null/i
-                || /^Timezone is/i ) {
+                || /^\s*Getting files newer than/i
+                || /^\s*directory \\/i
+                || /^\s*restore directory \\/i
+                || /^\s*Output is \/dev\/null/i
+                || /^\s*Timezone is/i
+                || /^\s*creating lame (up|low)case table/i
+           ) {
             # ignore these messages
         } else {
             $t->{xferErrCnt}++;
@@ -297,7 +323,10 @@ sub readOutput
                 my $badFile = $1;
                 $badFile =~ s{\\}{/}g;
                 $badFile =~ s{^/}{};
-                push(@{$t->{badFiles}}, "$t->{shareName}/$badFile");
+                push(@{$t->{badFiles}}, {
+                       share => $t->{shareName},
+                       file  => $badFile
+                   });
             }
         }
     }