X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC;h=d61aa56f145b6da5868717c86bbcaa4fd93e407d;hp=ab70f88bbcf6b3d3f58e82ec7c79cd9c323fb7f2;hb=c6cebe03e53dcc49f889cf15ccda5b0fe3acd235;hpb=2fb1e8b5cee74c72bbb8ecc7722c05256cbdc6bf diff --git a/bin/BackupPC b/bin/BackupPC index ab70f88..d61aa56 100755 --- a/bin/BackupPC +++ b/bin/BackupPC @@ -47,7 +47,7 @@ # #======================================================================== # -# Version 1.6.0_CVS, released 10 Dec 2002. +# Version 2.0.0_CVS, released 3 Feb 2003. # # See http://backuppc.sourceforge.net. # @@ -249,8 +249,8 @@ sub Main_Initialize exit(1); } foreach my $progName ( qw(SmbClientPath NmbLookupPath PingPath DfPath - SendmailPath) ) { - next if ( !defined($Conf{$progName}) || -x $Conf{$progName} ); + SendmailPath SshPath) ) { + next if ( $Conf{$progName} eq "" || -x $Conf{$progName} ); print(STDERR $bpc->timeStamp, "\$Conf{$progName} = '$Conf{$progName}' is not a" . " valid executable program\n"); @@ -325,7 +325,7 @@ sub Main_Initialize # Write out our initial status and save our PID # StatusWrite(); - if ( open(PID, ">$TopDir/log/BackupPC.pid") ) { + if ( open(PID, ">", "$TopDir/log/BackupPC.pid") ) { print(PID $$); close(PID); } @@ -364,7 +364,7 @@ sub Main_TryToRun_nightly host => $bpc->trashJob, user => "BackupPC", reqTime => time, - cmd => "$BinDir/BackupPC_trashClean" + cmd => ["$BinDir/BackupPC_trashClean"], }); $CmdQueueOn{$bpc->trashJob} = 1; } @@ -373,7 +373,7 @@ sub Main_TryToRun_nightly host => $bpc->adminJob, user => "BackupPC", reqTime => time, - cmd => "$BinDir/BackupPC_nightly" + cmd => ["$BinDir/BackupPC_nightly"], }); $CmdQueueOn{$bpc->adminJob} = 1; $RunNightlyWhenIdle = 2; @@ -420,8 +420,8 @@ sub Main_TryToRun_CmdQueue } if ( !$pid ) { setpgrp 0,0; - exec($cmd); - print(LOG $bpc->timeStamp, "can't exec $cmd for $host\n"); + exec(@$cmd); + print(LOG $bpc->timeStamp, "can't exec @$cmd for $host\n"); exit(0); } $Jobs{$host}{pid} = $pid; @@ -430,6 +430,7 @@ sub Main_TryToRun_CmdQueue vec($FDread, $Jobs{$host}{fn}, 1) = 1; $Jobs{$host}{startTime} = time; $Jobs{$host}{reqTime} = $req->{reqTime}; + $cmd = join(" ", @$cmd); $Jobs{$host}{cmd} = $cmd; $Jobs{$host}{type} = $Status{$host}{type}; $Status{$host}{state} = "Status_link_running"; @@ -560,7 +561,7 @@ sub Main_TryToRun_Bg_or_User_Queue vec($FDread, $Jobs{$host}{fn}, 1) = 1; $Jobs{$host}{startTime} = time; $Jobs{$host}{reqTime} = $req->{reqTime}; - $Jobs{$host}{cmd} = "$progName " . join(" ", @args); + $Jobs{$host}{cmd} = join(" ", $progName, @args); $Jobs{$host}{user} = $user; $Jobs{$host}{type} = $type; if ( !$req->{dhcp} ) { @@ -775,7 +776,7 @@ sub Main_Check_Job_Messages $Jobs{$host}{mesg} = $2; if ( $Jobs{$host}{dhcp} ) { if ( $mesg =~ /^DHCP (\S+) (\S+)/ ) { - my $newHost = $2; + my $newHost = $bpc->uriUnesc($2); if ( defined($Jobs{$newHost}) ) { print(LOG $bpc->timeStamp, "Backup on $newHost is already running\n"); @@ -882,6 +883,7 @@ sub Main_Check_Job_Messages $Info{"$f[0]FileCntRep"} = $f[7]; $Info{"$f[0]FileRepMax"} = $f[8]; $Info{"$f[0]FileCntRename"} = $f[9]; + $Info{"$f[0]FileLinkMax"} = $f[10]; $Info{"$f[0]Time"} = time; printf(LOG "%s%s nightly clean removed %d files of" . " size %.2fGB\n", @@ -889,11 +891,12 @@ sub Main_Check_Job_Messages $Info{"$f[0]FileCntRm"}, $Info{"$f[0]KbRm"} / (1000 * 1024)); printf(LOG "%s%s is %.2fGB, %d files (%d repeated, " - . "%d max chain), %d directories\n", + . "%d max chain, %d max links), %d directories\n", $bpc->timeStamp, ucfirst($f[0]), $Info{"$f[0]Kb"} / (1000 * 1024), $Info{"$f[0]FileCnt"}, $Info{"$f[0]FileCntRep"}, - $Info{"$f[0]FileRepMax"}, $Info{"$f[0]DirCnt"}); + $Info{"$f[0]FileRepMax"}, + $Info{"$f[0]FileLinkMax"}, $Info{"$f[0]DirCnt"}); } elsif ( $mesg =~ /^BackupPC_nightly lock_off/ ) { $RunNightlyWhenIdle = 0; } elsif ( $mesg =~ /^processState\s+(.+)/ ) { @@ -1012,6 +1015,7 @@ sub Main_Check_Client_Messages $host = $1; my $user = $2; my $backoff = $3; + $host = $bpc->uriUnesc($host); if ( $CmdJob ne $host && defined($Status{$host}) && defined($Jobs{$host}) ) { print(LOG $bpc->timeStamp, @@ -1051,9 +1055,11 @@ sub Main_Check_Client_Messages QueueAllPCs(); } elsif ( $cmd =~ /^backup (\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ ) { my $hostIP = $1; - $host = $2; - my $user = $3; + $host = $2; + my $user = $3; my $doFull = $4; + $host = $bpc->uriUnesc($host); + $hostIP = $bpc->uriUnesc($hostIP); if ( !defined($Status{$host}) ) { print(LOG $bpc->timeStamp, "User $user requested backup of unknown host" @@ -1092,6 +1098,8 @@ sub Main_Check_Client_Messages $host = $2; my $user = $3; my $reqFileName = $4; + $host = $bpc->uriUnesc($host); + $hostIP = $bpc->uriUnesc($hostIP); if ( !defined($Status{$host}) ) { print(LOG $bpc->timeStamp, "User $user requested restore to unknown host" @@ -1141,15 +1149,20 @@ sub Main_Check_Client_Messages } elsif ( $type =~ /^hosts/ ) { push(@values, \%Status); push(@names, qw(*Status)); - } elsif ( $type =~ /^host\((.*)\)/ - && defined($Status{$1}) ) { - push(@values, { - %{$Status{$1}}, - BgQueueOn => $BgQueueOn{$1}, - UserQueueOn => $UserQueueOn{$1}, - CmdQueueOn => $CmdQueueOn{$1}, - }); - push(@names, qw(*StatusHost)); + } elsif ( $type =~ /^host\((.*)\)/ ) { + my $h = $bpc->uriUnesc($1); + if ( defined($Status{$h}) ) { + push(@values, { + %{$Status{$h}}, + BgQueueOn => $BgQueueOn{$h}, + UserQueueOn => $UserQueueOn{$h}, + CmdQueueOn => $CmdQueueOn{$h}, + }); + push(@names, qw(*StatusHost)); + } else { + print(LOG $bpc->timeStamp, + "Unknown host $h for status request\n"); + } } else { print(LOG $bpc->timeStamp, "Unknown status request $type\n"); @@ -1160,6 +1173,7 @@ sub Main_Check_Client_Messages $reply = $dump->Dump; } elsif ( $cmd =~ /^link\s+(.+)/ ) { my($host) = $1; + $host = $bpc->uriUnesc($host); QueueLink($host); } elsif ( $cmd =~ /^log\s+(.*)/ ) { print(LOG $bpc->timeStamp, "$1\n"); @@ -1253,7 +1267,7 @@ sub StatusWrite [ \%Info, \%Status], [qw(*Info *Status)]); $dump->Indent(1); - if ( open(STATUS, ">$TopDir/log/status.pl") ) { + if ( open(STATUS, ">", "$TopDir/log/status.pl") ) { print(STATUS $dump->Dump); close(STATUS); } @@ -1333,7 +1347,7 @@ sub QueueLink host => $host, user => "BackupPC", reqTime => time, - cmd => "$BinDir/BackupPC_link $host" + cmd => ["$BinDir/BackupPC_link", $host], }); $CmdQueueOn{$host} = 1; }