X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_dump;h=79393bf422c043b9e474602bb4d405e51b69eec6;hp=e6d75f385c0a50f9563379a18b916193bd09fc59;hb=329e870f56fb6572fa697998d33676588034c149;hpb=7dee89bfce659051d486cc66515bb7f22bbc4f09 diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index e6d75f3..79393bf 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -52,7 +52,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001 Craig Barratt +# Copyright (C) 2001-2003 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 @@ -70,19 +70,21 @@ # #======================================================================== # -# Version 2.0.0beta1, released 30 Mar 2003. +# Version 2.1.0_CVS, released 3 Jul 2003. # # See http://backuppc.sourceforge.net. # #======================================================================== use strict; +no utf8; use lib "/usr/local/BackupPC/lib"; use BackupPC::Lib; use BackupPC::FileZIO; use BackupPC::Xfer::Smb; use BackupPC::Xfer::Tar; use BackupPC::Xfer::Rsync; +use Socket; use File::Path; use Getopt::Std; @@ -146,7 +148,8 @@ if ( $opts{d} ) { $Hosts = $bpc->HostInfoRead($client); } if ( !defined($Hosts->{$client}) ) { - print("Exiting because host $client does not exist in the hosts file\n"); + print("Exiting because host $client does not exist in the hosts file\n") + if ( $opts{v} ); exit(1) } @@ -215,9 +218,8 @@ if ( !$opts{d} ) { print("Name server doesn't know about $host; trying NetBios\n") if ( $opts{v} ); if ( !defined($hostIP = $bpc->NetBiosHostIPFind($host)) ) { - print(LOG $bpc->timeStamp, - "dump failed: Can't find host $host\n"); - print("dump failed: Can't find host $host\n"); + print(LOG $bpc->timeStamp, "Can't find host $host via netbios\n"); + print("host not found\n"); exit(1); } } else { @@ -446,12 +448,22 @@ for my $shareName ( @$ShareNames ) { # This xfer method outputs a tar format file, so we start a # BackupPC_tarExtract to extract the data. # - # Create a pipe to connect the Xfer method to BackupPC_tarExtract + # Create a socketpair to connect the Xfer method to BackupPC_tarExtract # WH is the write handle for writing, provided to the transport - # program, and RH is the other end of the pipe for reading, + # program, and RH is the other end of the socket for reading, # provided to BackupPC_tarExtract. # - pipe(RH, WH); + if ( socketpair(RH, WH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) ) { + shutdown(RH, 1); # no writing to this socket + shutdown(WH, 0); # no reading from this socket + setsockopt(RH, SOL_SOCKET, SO_RCVBUF, 8 * 65536); + setsockopt(WH, SOL_SOCKET, SO_SNDBUF, 8 * 65536); + } else { + # + # Default to pipe() if socketpair() doesn't work. + # + pipe(RH, WH); + } # # fork a child for BackupPC_tarExtract. TAR is a file handle @@ -465,6 +477,7 @@ for my $shareName ( @$ShareNames ) { close(WH); last; } + binmode(TAR); if ( !$tarPid ) { # # This is the tar child. Close the write end of the pipe, @@ -491,6 +504,7 @@ for my $shareName ( @$ShareNames ) { open(NEW_FILES, ">", "$TopDir/pc/$client/NewFileList") || die("can't open $TopDir/pc/$client/NewFileList"); $newFilesFH = *NEW_FILES; + binmode(NEW_FILES); } # @@ -601,7 +615,7 @@ for my $shareName ( @$ShareNames ) { # the transfer. # if ( my $errMsg = CorrectHostCheck($hostIP, $host) ) { - $stat{hostError} = $errMsg; + $stat{hostError} = $errMsg if ( $stat{hostError} eq "" ); last SCAN; } } @@ -808,7 +822,12 @@ sub catch_signal my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : ""; # - # Ignore signals in children + # Children quit quietly on ALRM + # + exit(1) if ( $Pid != $$ && $signame eq "ALRM" ); + + # + # Ignore other signals in children # return if ( $Pid != $$ ); @@ -977,7 +996,7 @@ sub UserCommandRun LOG => *LOG, XferLOG => $XferLOG, stat => \%stat, - xferOK => $stat{xferOK}, + xferOK => $stat{xferOK} || 0, type => $type, }; my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);