# Craig Barratt <cbarratt@users.sourceforge.net>
#
# 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
#
#========================================================================
#
-# 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;
$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)
}
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 {
# 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
close(WH);
last;
}
+ binmode(TAR);
if ( !$tarPid ) {
#
# This is the tar child. Close the write end of the pipe,
open(NEW_FILES, ">", "$TopDir/pc/$client/NewFileList")
|| die("can't open $TopDir/pc/$client/NewFileList");
$newFilesFH = *NEW_FILES;
+ binmode(NEW_FILES);
}
#
# the transfer.
#
if ( my $errMsg = CorrectHostCheck($hostIP, $host) ) {
- $stat{hostError} = $errMsg;
+ $stat{hostError} = $errMsg if ( $stat{hostError} eq "" );
last SCAN;
}
}
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 != $$ );
LOG => *LOG,
XferLOG => $XferLOG,
stat => \%stat,
- xferOK => $stat{xferOK},
+ xferOK => $stat{xferOK} || 0,
type => $type,
};
my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);