- Significant documentation changes for 2.0.0beta0
[BackupPC.git] / bin / BackupPC_dump
index bc09e4e..3160bc9 100755 (executable)
@@ -68,7 +68,7 @@
 #
 #========================================================================
 #
-# Version 2.0.0_CVS, released 18 Jan 2003.
+# Version 2.0.0_CVS, released 3 Feb 2003.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -93,6 +93,7 @@ my $TopDir = $bpc->TopDir();
 my $BinDir = $bpc->BinDir();
 my %Conf   = $bpc->Conf();
 my $NeedPostCmd;
+my $Hosts;
 
 $bpc->ChildInit();
 
@@ -119,12 +120,15 @@ if ( $opts{d} ) {
     # host name via NetBios using nmblookup.
     #
     $hostIP = $client;
-    exit(1) if ( $bpc->CheckHostAlive($hostIP) < 0 );
+    exit(1) if ( $bpc->CheckHostAlive($hostIP) < 0
+                   || $Conf{NmbLookupCmd} eq "" );
     ($client, $user) = $bpc->NetBiosInfoGet($hostIP);
     exit(1) if ( $host !~ /^([\w\.\s-]+)$/ );
-    my $hosts = $bpc->HostInfoRead($client);
-    exit(1) if ( !defined($hosts->{$client}) );
+    $Hosts = $bpc->HostInfoRead($client);
+    exit(1) if ( !defined($Hosts->{$client}) );
     $host = $client;
+} else {
+    $Hosts = $bpc->HostInfoRead($client);
 }
 
 my $Dir     = "$TopDir/pc/$client";
@@ -147,6 +151,8 @@ if ( defined(my $error = $bpc->ConfigRead($client)) ) {
 $SIG{INT}  = \&catch_signal;
 $SIG{ALRM} = \&catch_signal;
 $SIG{TERM} = \&catch_signal;
+$SIG{PIPE} = \&catch_signal;
+my $Pid = $$;
 
 #
 # Make sure we eventually timeout if there is no activity from
@@ -161,6 +167,14 @@ if ( !-f "$Dir/LOCK" ) {
 open(LOG, ">>", "$Dir/LOG");
 select(LOG); $| = 1; select(STDOUT);
 
+#
+# For the -e option we just expire backups and quit
+#
+if ( $opts{e} ) {
+    BackupExpire($client);
+    exit(0);
+}
+
 if ( !$opts{d} ) {
     #
     # In the non-DHCP case, make sure the host can be looked up
@@ -191,14 +205,6 @@ if ( !$opts{d} ) {
 # Figure out what to do and do it
 ###########################################################################
 
-#
-# For the -e option we just expire backups and quit
-#
-if ( $opts{e} ) {
-    BackupExpire($client);
-    exit(0);
-}
-
 #
 # See if we should skip this host during a certain range
 # of times.
@@ -771,7 +777,13 @@ sub catch_signal
     my $signame = shift;
     my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
 
+    #
+    # Ignore signals in children
+    #
+    return if ( $Pid != $$ );
+
     print(LOG $bpc->timeStamp, "cleaning up after signal $signame\n");
+    $SIG{$signame} = 'IGNORE';
     UserCommandRun("DumpPostUserCmd") if ( $NeedPostCmd );
     $XferLOG->write(\"exiting after signal $signame\n");
     $XferLOG->close();
@@ -890,10 +902,11 @@ sub BackupExpire
 sub CorrectHostCheck
 {
     my($hostIP, $host) = @_;
-    return if ( $hostIP eq $host && !$Conf{FixedIPNetBiosNameCheck} );
+    return if ( $hostIP eq $host && !$Conf{FixedIPNetBiosNameCheck}
+               || $Conf{NmbLookupCmd} eq "" );
     my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($hostIP);
     return "host $host has mismatching netbios name $netBiosHost"
-            if ( $netBiosHost ne $host );
+               if ( $netBiosHost ne $host );
     return;
 }
 
@@ -906,19 +919,21 @@ sub UserCommandRun
 
     return if ( !defined($Conf{$type}) );
     my $vars = {
-        xfer    => $xfer,
-        client  => $client,
-        host    => $host,
-        hostIP  => $hostIP,
-        share   => $ShareNames->[0],
-        shares  => $ShareNames,
+        xfer       => $xfer,
+        client     => $client,
+        host       => $host,
+        hostIP     => $hostIP,
+       user       => $Hosts->{$client}{user},
+       moreUsers  => $Hosts->{$client}{moreUsers},
+        share      => $ShareNames->[0],
+        shares     => $ShareNames,
         XferMethod => $Conf{XferMethod},
-        sshPath => $Conf{SshPath},
-        LOG     => *LOG,
-        XferLOG => $XferLOG,
-        stat    => \%stat,
-        xferOK  => $stat{xferOK},
-       type    => $type,
+        sshPath    => $Conf{SshPath},
+        LOG        => *LOG,
+        XferLOG    => $XferLOG,
+        stat       => \%stat,
+        xferOK     => $stat{xferOK},
+       type       => $type,
     };
     my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars);
     $XferLOG->write(\"Executing $type: @$cmd\n");