X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FSmb.pm;h=3d6dd5278070de8afde323b901170ee455bf58e9;hp=3f88c3c01f928aa21798fd7f899ca0e28a33af4d;hb=2460880d23902e74d5d8541f9c2fbb9538eaf4cb;hpb=5729095faa3ef12dc5d4f02538c3650ac81912ef diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm index 3f88c3c..3d6dd52 100644 --- a/lib/BackupPC/Xfer/Smb.pm +++ b/lib/BackupPC/Xfer/Smb.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.1.0_CVS, released 13 Mar 2004. # # See http://backuppc.sourceforge.net. # @@ -197,6 +197,7 @@ sub start # # Run smbclient. # + alarm(0); $bpc->cmdExecOrEval($smbClientCmd, $args); # should not be reached, but just in case... $t->{_errStr} = "Can't exec $conf->{SmbClientPath}"; @@ -226,17 +227,24 @@ sub readOutput while ( $t->{smbOut} =~ /(.*?)[\n\r]+(.*)/s ) { $_ = $1; $t->{smbOut} = $2; - $t->{XferLOG}->write(\"$_\n"); + # + # ignore the log file time stamps from smbclient introduced + # in version 3.0.0 - don't even write them to the log file. + # + if ( m{^\[\d+/\d+/\d+ +\d+:\d+:\d+.*\] +(client/cli|lib/util_unistr).*\(\d+\)} ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 5 ); + next; + } # # refresh our inactivity alarm # - alarm($conf->{ClientTimeout}); + alarm($conf->{ClientTimeout}) if ( !$t->{abort} ); $t->{lastOutputLine} = $_ if ( !/^$/ ); # # This section is highly dependent on the version of smbclient. # If you upgrade Samba, make sure that these regexp are still valid. # - if ( /^\s*(-?\d+) \(\s*\d+\.\d kb\/s\) (.*)$/ ) { + if ( /^\s*(-?\d+) \(\s*\d+[.,]\d kb\/s\) (.*)$/ ) { my $sambaFileSize = $1; my $pcFileName = $2; (my $fileName = $pcFileName) =~ s/\\/\//g; @@ -244,30 +252,36 @@ sub readOutput $fileName =~ s/^\/*//; $t->{byteCnt} += $sambaFileSize; $t->{fileCnt}++; + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 ); } elsif ( /restore tar file (.*) of size (\d+) bytes/ ) { $t->{byteCnt} += $2; $t->{fileCnt}++; - } elsif ( /tar: dumped \d+ files/ ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 ); + } elsif ( /^\s*tar: dumped \d+ files/ ) { $t->{xferOK} = 1; - } elsif ( /^tar: restored \d+ files/ ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); + } elsif ( /^\s*tar: restored \d+ files/ ) { $t->{xferOK} = 1; - } elsif ( /^read_socket_with_timeout: timeout read. /i ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); + } elsif ( /^\s*read_socket_with_timeout: timeout read. /i ) { $t->{hostAbort} = 1; + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); } 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 - || /^tree connect failed: ERRDOS - ERRnoaccess \(Access denied\.\)/ - || /^tree connect failed: NT_STATUS_BAD_NETWORK_NAME/ + || /^\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/ ) { if ( $t->{hostError} eq "" ) { $t->{XferLOG}->write(\"This backup will fail because: $_\n"); $t->{hostError} = $_; } - } elsif ( /^NT_STATUS_ACCESS_DENIED listing (.*)/ - || /^ERRDOS - ERRnoaccess \(Access denied\.\) listing (.*)/ ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); + } elsif ( /^\s*NT_STATUS_ACCESS_DENIED listing (.*)/ + || /^\s*ERRDOS - ERRnoaccess \(Access denied\.\) listing (.*)/ ) { my $badDir = $1; $badDir =~ s{\\}{/}g; $badDir =~ s{/+}{/}g; @@ -277,17 +291,23 @@ sub readOutput $t->{XferLOG}->write(\"This backup will fail because: $_\n"); $t->{hostError} ||= $_; } + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); + } elsif ( /^\s*directory \\/i ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 ); } 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*restore directory \\/i + || /^\s*Output is \/dev\/null/i + || /^\s*Timezone is/i + || /^\s*creating lame (up|low)case table/i + ) { # ignore these messages + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 ); } else { $t->{xferErrCnt}++; $t->{xferBadShareCnt}++ if ( /^ERRDOS - ERRbadshare/ ); @@ -320,11 +340,20 @@ sub readOutput file => $badFile }); } + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 ); } } return 1; } +sub abort +{ + my($t, $reason) = @_; + + $t->{abort} = 1; + $t->{abortReason} = $reason; +} + sub setSelectMask { my($t, $FDreadRef) = @_;