From: cbarratt Date: Sun, 27 Jul 2003 00:55:19 +0000 (+0000) Subject: * In BackupPC_Admin, default REMOTE_USER to $Conf{BackupPCUser} X-Git-Tag: v2_0_1~2 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=b0fa25ab965431b16d2a37186f4b982de8d52df6;p=BackupPC.git * In BackupPC_Admin, default REMOTE_USER to $Conf{BackupPCUser} if it is not defined. This allows the CGI interface to work when AdminUsers = '*'. Reported by Quentin Arce. * For SMB, code that detected files with a read-locked region (eg: outlook .pst files), removed them and then tried to link with an earlier version was broken. This code missed a step of mangling the file names. This is now fixed. Reported by Pierre Bourgin. * A backup of a share that has zero files is now considered fatal. This is used to catch miscellaneous Xfer errors that result in no files being backed up. A new config parameter $Conf{BackupZeroFilesIsFatal} (defaults to 1) and can be set to zero to turn off this check. Suggested by Guillaume Filion. * SMB: now detect NT_STATUS_ACCESS_DENIED on entire share or BackupFilesOnly (also ERRDOS - ERRnoaccess (Access denied.) for older versions of smbclient.) Suggested by Guillaume Filion. * SMB: now detects "tree connect failed: NT_STATUS_BAD_NETWORK_NAME" and the dump is considered failed. * Rsync: Previously BackupFilesOnly = '/' did --include '/' --exclude '/*', which just included the '/' directory and nothing below. Now it does just --include '/', which should include everything. Reported by denon. * Add hostError to DumpPostUserCmd variable substitutions for both dump and restore. * Verbose output in Lib.pm goes to STDERR, not STDOUT. This now makes BackupPC_dump -v work better. * Don't allow browsing with ".." in directory in case a user tries to trick BackupPC_Admin into displaying directories outside where they are allowed. * Required File::RsyncP version is now 0.44, since File::RsyncP 0.44 fixes large file (>2GB) bugs. Large file bugs reported by Steve Waltner. --- diff --git a/ChangeLog b/ChangeLog index 86a98cb..2f617f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,19 +21,46 @@ # Version __VERSION__, __RELEASEDATE__ #------------------------------------------------------------------------ -* Split BackupPC_Admin into a set of modules, one for each major action. - Each action is now a seperate module in lib/BackupPC/CGI. - -* Added directory history display to BackupPC_Admin, allowing the - user to quickly see which files changed between backups. - -* Browsing and directory history now sort the files in a - case-insensitive manner. - -* Swapped the Server and Hosts sections on the Nav bar. Moved the - host search text box to the top of the hosts section. This was - done to move the variable-length part of the Nav bar (when all - hosts are displayed) to the bottom. +* In BackupPC_Admin, default REMOTE_USER to $Conf{BackupPCUser} + if it is not defined. This allows the CGI interface to work + when AdminUsers = '*'. Reported by Quentin Arce. + +* For SMB, code that detected files with a read-locked region (eg: + outlook .pst files), removed them and then tried to link with an + earlier version was broken. This code missed a step of mangling + the file names. This is now fixed. Reported by Pierre Bourgin. + +* A backup of a share that has zero files is now considered + fatal. This is used to catch miscellaneous Xfer errors that + result in no files being backed up. A new config parameter + $Conf{BackupZeroFilesIsFatal} (defaults to 1) and can be set to + zero to turn off this check. Suggested by Guillaume Filion. + +* SMB: now detect NT_STATUS_ACCESS_DENIED on entire share or BackupFilesOnly + (also ERRDOS - ERRnoaccess (Access denied.) for older versions of + smbclient.) Suggested by Guillaume Filion. + +* SMB: now detects "tree connect failed: NT_STATUS_BAD_NETWORK_NAME" and + the dump is considered failed. + +* Rsync: Previously BackupFilesOnly = '/' did --include '/' --exclude '/*', + which just included the '/' directory and nothing below. Now it + does just --include '/', which should include everything. + Reported by denon. + +* Add hostError to DumpPostUserCmd variable substitutions for both dump + and restore. + +* Verbose output in Lib.pm goes to STDERR, not STDOUT. This now + makes BackupPC_dump -v work better. + +* Don't allow browsing with ".." in directory in case a user tries + to trick BackupPC_Admin into displaying directories outside where + they are allowed. + +* Required File::RsyncP version is now 0.44, since File::RsyncP 0.44 + fixes large file (>2GB) bugs. Large file bugs reported by Steve + Waltner. #------------------------------------------------------------------------ # Version 2.0.0, 14 Jun 2003 diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump index 79393bf..588123a 100755 --- a/bin/BackupPC_dump +++ b/bin/BackupPC_dump @@ -52,7 +52,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001 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,7 +70,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -385,7 +385,7 @@ my $sizeExist = 0; my $sizeExistComp = 0; my $nFilesTotal = 0; my $sizeTotal = 0; -my($logMsg, %stat, $xfer, $ShareNames); +my($logMsg, %stat, $xfer, $ShareNames, $noFilesErr); my $newFilesFH; if ( $Conf{XferMethod} eq "tar" ) { @@ -637,6 +637,9 @@ for my $shareName ( @$ShareNames ) { # Merge the xfer status (need to accumulate counts) # my $newStat = $xfer->getStats; + if ( $newStat->{fileCnt} == 0 ) { + $noFilesErr ||= "No files dumped for share $shareName"; + } foreach my $k ( (keys(%stat), keys(%$newStat)) ) { next if ( !defined($newStat->{$k}) ); if ( $k =~ /Cnt$/ ) { @@ -676,6 +679,15 @@ for my $shareName ( @$ShareNames ) { } my $lastNum = -1; +# +# If any share had zero files then consider the dump bad +# +if ( $stat{hostError} eq "" + && length($noFilesErr) && $Conf{BackupZeroFilesIsFatal} ) { + $stat{hostError} = $noFilesErr; + $stat{xferOK} = 0; +} + # # Do one last check to make sure it is still the machine we expect. # @@ -768,25 +780,34 @@ unlink("$Dir/timeStamp.level0"); # Now remove the bad files, replacing them if possible with links to # earlier backups. # -foreach my $file ( $xfer->getBadFiles ) { +foreach my $f ( $xfer->getBadFiles ) { my $j; - unlink("$Dir/$lastNum/$file"); + my $shareM = $bpc->fileNameEltMangle($f->{share}); + my $fileM = $bpc->fileNameMangle($f->{file}); + unlink("$Dir/$lastNum/$shareM/$fileM"); for ( $j = $i - 1 ; $j >= 0 ; $j-- ) { + my $file; + if ( $Backups[$j]{mangle} ) { + $file = "$shareM/$fileM"; + } else { + $file = "$f->{share}/$f->{file}"; + } next if ( !-f "$Dir/$Backups[$j]{num}/$file" ); - if ( !link("$Dir/$Backups[$j]{num}/$file", "$Dir/$lastNum/$file") ) { + if ( !link("$Dir/$Backups[$j]{num}/$file", + "$Dir/$lastNum/$shareM/$fileM") ) { print(LOG $bpc->timeStamp, - "Unable to link $lastNum/$file to" + "Unable to link $lastNum/$shareM/$fileM to" . " $Backups[$j]{num}/$file\n"); } else { print(LOG $bpc->timeStamp, - "Bad file $lastNum/$file replaced by link to" + "Bad file $lastNum/$shareM/$fileM replaced by link to" . " $Backups[$j]{num}/$file\n"); } last; } if ( $j < 0 ) { print(LOG $bpc->timeStamp, - "Removed bad file $lastNum/$file (no older" + "Removed bad file $lastNum/$shareM/$fileM (no older" . " copy to link to)\n"); } } @@ -997,6 +1018,7 @@ sub UserCommandRun XferLOG => $XferLOG, stat => \%stat, xferOK => $stat{xferOK} || 0, + hostError => $stat{hostError}, type => $type, }; my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars); diff --git a/bin/BackupPC_restore b/bin/BackupPC_restore index 56d8b79..dda161e 100755 --- a/bin/BackupPC_restore +++ b/bin/BackupPC_restore @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001 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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -626,6 +626,7 @@ sub UserCommandRun XferLOG => $RestoreLOG, stat => \%stat, xferOK => $stat{xferOK} || 0, + hostError => $stat{hostError}, type => $type, bkupSrcHost => $RestoreReq{hostSrc}, bkupSrcShare => $RestoreReq{shareSrc}, diff --git a/cgi-bin/BackupPC_Admin b/cgi-bin/BackupPC_Admin index c99ba4c..8f5e193 100755 --- a/cgi-bin/BackupPC_Admin +++ b/cgi-bin/BackupPC_Admin @@ -21,7 +21,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001 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 @@ -39,7 +39,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -48,30 +48,98 @@ use strict; no utf8; use CGI; -use CGI::Carp qw(fatalsToBrowser); use lib "/usr/local/BackupPC/lib"; - use BackupPC::Lib; -use BackupPC::CGI::Lib qw(:all); +use BackupPC::FileZIO; +use BackupPC::Attrib qw(:all); +use BackupPC::View; +use Data::Dumper; + +use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc); +use vars qw(%Status %Info %Jobs @BgQueue @UserQueue @CmdQueue + %QueueLen %StatusHost); +use vars qw($Hosts $HostsMTime $ConfigMTime $PrivAdmin); +use vars qw(%UserEmailInfo $UserEmailInfoMTime %RestoreReq); + +use vars qw ($Lang); + +$Cgi = new CGI; +%In = $Cgi->Vars; + +# +# We require that Apache pass in $ENV{SCRIPT_NAME} and $ENV{REMOTE_USER}. +# The latter requires .ht_access style authentication. Replace this +# code if you are using some other type of authentication, and have +# a different way of getting the user name. +# +$ENV{REMOTE_USER} = $Conf{BackupPCUser} if ( !defined($ENV{REMOTE_USER}) ); +$MyURL = $ENV{SCRIPT_NAME}; +$User = $ENV{REMOTE_USER}; + +if ( !defined($bpc) ) { + ErrorExit($Lang->{BackupPC__Lib__new_failed__check_apache_error_log}) + if ( !($bpc = BackupPC::Lib->new(undef, undef, 1)) ); + $TopDir = $bpc->TopDir(); + $BinDir = $bpc->BinDir(); + %Conf = $bpc->Conf(); + $Lang = $bpc->Lang(); + $ConfigMTime = $bpc->ConfigMTime(); +} elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { + $bpc->ConfigRead(); + %Conf = $bpc->Conf(); + $ConfigMTime = $bpc->ConfigMTime(); + $Lang = $bpc->Lang(); +} -BackupPC::CGI::Lib::NewRequest; +# +# Clean up %ENV for taint checking +# +delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; +$ENV{PATH} = $Conf{MyPath}; + +# +# Verify we are running as the correct user +# +if ( $Conf{BackupPCUserVerify} + && $> != (my $uid = (getpwnam($Conf{BackupPCUser}))[2]) ) { + ErrorExit(eval("qq{$Lang->{Wrong_user__my_userid_is___}}"), < +This is an installation problem. If you are using mod_perl then +it appears that Apache is not running as user $Conf{BackupPCUser}. +If you are not using mod_perl, then most like setuid is not working +properly on BackupPC_Admin. Check the permissions on +$Conf{CgiDir}/BackupPC_Admin and look at the documentation. +EOF +} + +if ( !defined($Hosts) || $bpc->HostsMTime() != $HostsMTime ) { + $HostsMTime = $bpc->HostsMTime(); + $Hosts = $bpc->HostInfoRead(); + + # turn moreUsers list into a hash for quick lookups + foreach my $host (keys %$Hosts) { + $Hosts->{$host}{moreUsers} = + {map {$_, 1} split(",", $Hosts->{$host}{moreUsers}) } + } +} my %ActionDispatch = ( - "summary" => "Summary", - $Lang->{Start_Incr_Backup} => "StartStopBackup", - $Lang->{Start_Full_Backup} => "StartStopBackup", - $Lang->{Stop_Dequeue_Backup} => "StartStopBackup", - "queue" => "Queue", - "view" => "View", - "LOGlist" => "LOGlist", - "emailSummary" => "EmailSummary", - "browse" => "Browse", - "dirHistory" => "DirHistory", - $Lang->{Restore} => "Restore", - "RestoreFile" => "RestoreFile", - "hostInfo" => "HostInfo", - "generalInfo" => "GeneralInfo", - "restoreInfo" => "RestoreInfo", + "summary" => \&Action_Summary, + $Lang->{Start_Incr_Backup} => \&Action_StartStopBackup, + $Lang->{Start_Full_Backup} => \&Action_StartStopBackup, + $Lang->{Stop_Dequeue_Backup} => \&Action_StartStopBackup, + "queue" => \&Action_Queue, + "view" => \&Action_View, + "LOGlist" => \&Action_LOGlist, + "emailSummary" => \&Action_EmailSummary, + "browse" => \&Action_Browse, + $Lang->{Restore} => \&Action_Restore, + "RestoreFile" => \&Action_RestoreFile, + "hostInfo" => \&Action_HostInfo, + "generalInfo" => \&Action_GeneralInfo, + "restoreInfo" => \&Action_RestoreInfo, ); # @@ -79,7 +147,1814 @@ my %ActionDispatch = ( # $In{action} ||= "hostInfo" if ( defined($In{host}) ); $In{action} = "generalInfo" if ( !defined($ActionDispatch{$In{action}}) ); -my $action = $ActionDispatch{$In{action}}; -require "BackupPC/CGI/$action.pm" - if ( !defined($BackupPC::CGI::{"${action}::"}) ); -$BackupPC::CGI::{"${action}::"}{action}(); +$ActionDispatch{$In{action}}(); +exit(0); + +########################################################################### +# Action handling subroutines +########################################################################### + +sub Action_Summary +{ + my($fullTot, $fullSizeTot, $incrTot, $incrSizeTot, $str, + $strNone, $strGood, $hostCntGood, $hostCntNone); + + $hostCntGood = $hostCntNone = 0; + GetStatusInfo("hosts"); + my $Privileged = CheckPermission(); + + if ( !$Privileged ) { + ErrorExit($Lang->{Only_privileged_users_can_view_PC_summaries} ); + } + foreach my $host ( sort(keys(%Status)) ) { + my($fullDur, $incrCnt, $incrAge, $fullSize, $fullRate, $reasonHilite); + my($shortErr); + my @Backups = $bpc->BackupInfoRead($host); + my $fullCnt = $incrCnt = 0; + my $fullAge = $incrAge = -1; + for ( my $i = 0 ; $i < @Backups ; $i++ ) { + if ( $Backups[$i]{type} eq "full" ) { + $fullCnt++; + if ( $fullAge < 0 || $Backups[$i]{startTime} > $fullAge ) { + $fullAge = $Backups[$i]{startTime}; + $fullSize = $Backups[$i]{size} / (1024 * 1024); + $fullDur = $Backups[$i]{endTime} - $Backups[$i]{startTime}; + } + $fullSizeTot += $Backups[$i]{size} / (1024 * 1024); + } else { + $incrCnt++; + if ( $incrAge < 0 || $Backups[$i]{startTime} > $incrAge ) { + $incrAge = $Backups[$i]{startTime}; + } + $incrSizeTot += $Backups[$i]{size} / (1024 * 1024); + } + } + if ( $fullAge < 0 ) { + $fullAge = ""; + $fullRate = ""; + } else { + $fullAge = sprintf("%.1f", (time - $fullAge) / (24 * 3600)); + $fullRate = sprintf("%.2f", + $fullSize / ($fullDur <= 0 ? 1 : $fullDur)); + } + if ( $incrAge < 0 ) { + $incrAge = ""; + } else { + $incrAge = sprintf("%.1f", (time - $incrAge) / (24 * 3600)); + } + $fullTot += $fullCnt; + $incrTot += $incrCnt; + $fullSize = sprintf("%.2f", $fullSize / 1000); + $incrAge = " " if ( $incrAge eq "" ); + $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} + || $Conf{CgiStatusHilightColor}{$Status{$host}{state}}; + $reasonHilite = " bgcolor=\"$reasonHilite\"" if ( $reasonHilite ne "" ); + if ( $Status{$host}{state} ne "Status_backup_in_progress" + && $Status{$host}{state} ne "Status_restore_in_progress" + && $Status{$host}{error} ne "" ) { + ($shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../; + $shortErr = " ($shortErr)"; + } + + $str = < ${HostLink($host)} + ${UserLink(defined($Hosts->{$host}) + ? $Hosts->{$host}{user} : "")} + $fullCnt + $fullAge + $fullSize + $fullRate + $incrCnt + $incrAge + $Lang->{$Status{$host}{state}} + $Lang->{$Status{$host}{reason}}$shortErr +EOF + if ( @Backups == 0 ) { + $hostCntNone++; + $strNone .= $str; + } else { + $hostCntGood++; + $strGood .= $str; + } + } + $fullSizeTot = sprintf("%.2f", $fullSizeTot / 1000); + $incrSizeTot = sprintf("%.2f", $incrSizeTot / 1000); + my $now = timeStamp2(time); + + Header($Lang->{BackupPC__Server_Summary}); + print eval ("qq{$Lang->{BackupPC_Summary}}"); + + Trailer(); +} + +sub Action_StartStopBackup +{ + my($str, $reply); + + my $start = 1 if ( $In{action} eq $Lang->{Start_Incr_Backup} + || $In{action} eq $Lang->{Start_Full_Backup} ); + my $doFull = $In{action} eq $Lang->{Start_Full_Backup} ? 1 : 0; + my $type = $doFull ? "full" : "incremental"; + my $host = $In{host}; + my $Privileged = CheckPermission($host); + + if ( !$Privileged ) { + ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_stop_or_start_backups}}")); + } + ServerConnect(); + + if ( $In{doit} ) { + if ( $start ) { + if ( $Hosts->{$host}{dhcp} ) { + $reply = $bpc->ServerMesg("backup $In{hostIP} ${EscURI($host)}" + . " $User $doFull"); + $str = eval("qq{$Lang->{Backup_requested_on_DHCP__host}}"); + } else { + $reply = $bpc->ServerMesg("backup ${EscURI($host)}" + . " ${EscURI($host)} $User $doFull"); + $str = eval("qq{$Lang->{Backup_requested_on__host_by__User}}"); + } + } else { + $reply = $bpc->ServerMesg("stop ${EscURI($host)} $User $In{backoff}"); + $str = eval("qq{$Lang->{Backup_stopped_dequeued_on__host_by__User}}"); + } + + Header(eval ("qq{$Lang->{BackupPC__Backup_Requested_on__host}}") ); + print (eval ("qq{$Lang->{REPLY_FROM_SERVER}}")); + + Trailer(); + } else { + if ( $start ) { + my $ipAddr = ConfirmIPAddress($host); + + Header(eval("qq{$Lang->{BackupPC__Start_Backup_Confirm_on__host}}")); + print (eval("qq{$Lang->{Are_you_sure_start}}")); + } else { + my $backoff = ""; + GetStatusInfo("host(${EscURI($host)})"); + if ( $StatusHost{backoffTime} > time ) { + $backoff = sprintf("%.1f", + ($StatusHost{backoffTime} - time) / 3600); + } + Header($Lang->{BackupPC__Stop_Backup_Confirm_on__host}); + print (eval ("qq{$Lang->{Are_you_sure_stop}}")); + } + Trailer(); + } +} + +sub Action_Queue +{ + my($strBg, $strUser, $strCmd); + + GetStatusInfo("queues"); + my $Privileged = CheckPermission(); + + if ( !$Privileged ) { + ErrorExit($Lang->{Only_privileged_users_can_view_queues_}); + } + + while ( @BgQueue ) { + my $req = pop(@BgQueue); + my($reqTime) = timeStamp2($req->{reqTime}); + $strBg .= < ${HostLink($req->{host})} + $reqTime + $req->{user} +EOF + } + while ( @UserQueue ) { + my $req = pop(@UserQueue); + my $reqTime = timeStamp2($req->{reqTime}); + $strUser .= < ${HostLink($req->{host})} + $reqTime + $req->{user} +EOF + } + while ( @CmdQueue ) { + my $req = pop(@CmdQueue); + my $reqTime = timeStamp2($req->{reqTime}); + (my $cmd = $req->{cmd}[0]) =~ s/$BinDir\///; + $strCmd .= < ${HostLink($req->{host})} + $reqTime + $req->{user} + $cmd $req->{cmd}[0] +EOF + } + Header($Lang->{BackupPC__Queue_Summary}); + + print ( eval ( "qq{$Lang->{Backup_Queue_Summary}}") ); + + Trailer(); +} + +sub Action_View +{ + my $Privileged = CheckPermission($In{host}); + my $compress = 0; + my $fh; + my $host = $In{host}; + my $num = $In{num}; + my $type = $In{type}; + my $linkHosts = 0; + my($file, $comment); + my $ext = $num ne "" ? ".$num" : ""; + + ErrorExit(eval("qq{$Lang->{Invalid_number__num}}")) if ( $num ne "" && $num !~ /^\d+$/ ); + if ( $type eq "XferLOG" ) { + $file = "$TopDir/pc/$host/SmbLOG$ext"; + $file = "$TopDir/pc/$host/XferLOG$ext" if ( !-f $file && !-f "$file.z"); + } elsif ( $type eq "XferLOGbad" ) { + $file = "$TopDir/pc/$host/SmbLOG.bad"; + $file = "$TopDir/pc/$host/XferLOG.bad" if ( !-f $file && !-f "$file.z"); + } elsif ( $type eq "XferErrbad" ) { + $file = "$TopDir/pc/$host/SmbLOG.bad"; + $file = "$TopDir/pc/$host/XferLOG.bad" if ( !-f $file && !-f "$file.z"); + $comment = $Lang->{Extracting_only_Errors}; + } elsif ( $type eq "XferErr" ) { + $file = "$TopDir/pc/$host/SmbLOG$ext"; + $file = "$TopDir/pc/$host/XferLOG$ext" if ( !-f $file && !-f "$file.z"); + $comment = $Lang->{Extracting_only_Errors}; + } elsif ( $type eq "RestoreLOG" ) { + $file = "$TopDir/pc/$host/RestoreLOG$ext"; + } elsif ( $type eq "RestoreErr" ) { + $file = "$TopDir/pc/$host/RestoreLOG$ext"; + $comment = $Lang->{Extracting_only_Errors}; + } elsif ( $host ne "" && $type eq "config" ) { + $file = "$TopDir/pc/$host/config.pl"; + $file = "$TopDir/conf/$host.pl" + if ( $host ne "config" && -f "$TopDir/conf/$host.pl" + && !-f $file ); + } elsif ( $type eq "docs" ) { + $file = "$BinDir/../doc/BackupPC.html"; + if ( open(LOG, $file) ) { + binmode(LOG); + Header($Lang->{BackupPC__Documentation}); + print while ( ); + close(LOG); + Trailer(); + } else { + ErrorExit(eval("qq{$Lang->{Unable_to_open__file__configuration_problem}}")); + } + return; + } elsif ( $type eq "config" ) { + $file = "$TopDir/conf/config.pl"; + } elsif ( $type eq "hosts" ) { + $file = "$TopDir/conf/hosts"; + } elsif ( $host ne "" ) { + $file = "$TopDir/pc/$host/LOG$ext"; + } else { + $file = "$TopDir/log/LOG$ext"; + $linkHosts = 1; + } + if ( !$Privileged ) { + ErrorExit($Lang->{Only_privileged_users_can_view_log_or_config_files}); + } + if ( !-f $file && -f "$file.z" ) { + $file .= ".z"; + $compress = 1; + } + Header(eval("qq{$Lang->{Backup_PC__Log_File__file}}") ); + print( eval ("qq{$Lang->{Log_File__file__comment}}")); + if ( defined($fh = BackupPC::FileZIO->open($file, 0, $compress)) ) { + my $mtimeStr = $bpc->timeStamp((stat($file))[9], 1); + + print ( eval ("qq{$Lang->{Contents_of_log_file}}")); + + print "
";
+        if ( $type eq "XferErr" || $type eq "XferErrbad"
+				|| $type eq "RestoreErr" ) {
+	    my $skipped;
+            while ( 1 ) {
+                $_ = $fh->readLine();
+                if ( $_ eq "" ) {
+		    print(eval ("qq{$Lang->{skipped__skipped_lines}}"))
+						    if ( $skipped );
+		    last;
+		}
+                if ( /smb: \\>/
+                        || /^\s*(\d+) \(\s*\d+\.\d kb\/s\) (.*)$/
+                        || /^tar: dumped \d+ files/
+                        || /^added interface/i
+                        || /^restore tar file /i
+                        || /^restore directory /i
+                        || /^tarmode is now/i
+                        || /^Total bytes written/i
+                        || /^Domain=/i
+                        || /^Getting files newer than/i
+                        || /^Output is \/dev\/null/
+                        || /^\([\d\.]* kb\/s\) \(average [\d\.]* kb\/s\)$/
+                        || /^\s+directory \\/
+                        || /^Timezone is/
+                        || /^\.\//
+                        || /^  /
+			    ) {
+		    $skipped++;
+		    next;
+		}
+		print(eval("qq{$Lang->{skipped__skipped_lines}}"))
+						     if ( $skipped );
+		$skipped = 0;
+                print ${EscHTML($_)};
+            }
+        } elsif ( $linkHosts ) {
+            while ( 1 ) {
+                $_ = $fh->readLine();
+                last if ( $_ eq "" );
+                my $s = ${EscHTML($_)};
+                $s =~ s/\b([\w-]+)\b/defined($Hosts->{$1})
+                                        ? ${HostLink($1)} : $1/eg;
+                print $s;
+            }
+        } elsif ( $type eq "config" ) {
+            while ( 1 ) {
+                $_ = $fh->readLine();
+                last if ( $_ eq "" );
+                # remove any passwords and user names
+                s/(SmbSharePasswd.*=.*['"]).*(['"])/$1$2/ig;
+                s/(SmbShareUserName.*=.*['"]).*(['"])/$1$2/ig;
+                s/(RsyncdPasswd.*=.*['"]).*(['"])/$1$2/ig;
+                s/(ServerMesgSecret.*=.*['"]).*(['"])/$1$2/ig;
+                print ${EscHTML($_)};
+            }
+        } else {
+            while ( 1 ) {
+                $_ = $fh->readLine();
+                last if ( $_ eq "" );
+                print ${EscHTML($_)};
+            }
+        }
+        $fh->close();
+    } else {
+	printf( eval("qq{$Lang->{_pre___Can_t_open_log_file__file}}"));
+    }
+    print <
+EOF
+    Trailer();
+}
+
+sub Action_LOGlist
+{
+    my $Privileged = CheckPermission($In{host});
+
+    if ( !$Privileged ) {
+        ErrorExit($Lang->{Only_privileged_users_can_view_log_files});
+    }
+    my $host = $In{host};
+    my($url0, $hdr, $root, $str);
+    if ( $host ne "" ) {
+        $root = "$TopDir/pc/$host/LOG";
+        $url0 = "&host=${EscURI($host)}";
+        $hdr = "for host $host";
+    } else {
+        $root = "$TopDir/log/LOG";
+        $url0 = "";
+        $hdr = "";
+    }
+    for ( my $i = -1 ; ; $i++ ) {
+        my $url1 = "";
+        my $file = $root;
+        if ( $i >= 0 ) {
+            $file .= ".$i";
+            $url1 = "&num=$i";
+        }
+        $file .= ".z" if ( !-f $file && -f "$file.z" );
+        last if ( !-f $file );
+        my $mtimeStr = $bpc->timeStamp((stat($file))[9], 1);
+        my $size     = (stat($file))[7];
+        $str .= < $file 
+     $size 
+     $mtimeStr 
+EOF
+    }
+    Header($Lang->{BackupPC__Log_File_History});
+    print (eval("qq{$Lang->{Log_File_History__hdr}}"));
+    Trailer();
+}
+
+sub Action_EmailSummary
+{
+    my $Privileged = CheckPermission();
+
+    if ( !$Privileged ) {
+        ErrorExit($Lang->{Only_privileged_users_can_view_email_summaries});
+    }
+    GetStatusInfo("hosts");
+    ReadUserEmailInfo();
+    my(%EmailStr, $str);
+    foreach my $u ( keys(%UserEmailInfo) ) {
+        next if ( !defined($UserEmailInfo{$u}{lastTime}) );
+        my $emailTimeStr = timeStamp2($UserEmailInfo{$u}{lastTime});
+        $EmailStr{$UserEmailInfo{$u}{lastTime}} .= <${UserLink($u)} 
+    ${HostLink($UserEmailInfo{$u}{lastHost})} 
+    $emailTimeStr 
+    $UserEmailInfo{$u}{lastSubj} 
+EOF
+    }
+    foreach my $t ( sort({$b <=> $a} keys(%EmailStr)) ) {
+        $str .= $EmailStr{$t};
+    }
+    Header($Lang->{Email_Summary});
+    print (eval("qq{$Lang->{Recent_Email_Summary}}"));
+    Trailer();
+}
+
+sub Action_Browse
+{
+    my $Privileged = CheckPermission($In{host});
+    my($i, $dirStr, $fileStr, $attr);
+    my $checkBoxCnt = 0;
+
+    if ( !$Privileged ) {
+        ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_browse_backup_files}}"));
+    }
+    my $host  = $In{host};
+    my $num   = $In{num};
+    my $share = $In{share};
+    my $dir   = $In{dir};
+
+    ErrorExit($Lang->{Empty_host_name}) if ( $host eq "" );
+    #
+    # Find the requested backup and the previous filled backup
+    #
+    my @Backups = $bpc->BackupInfoRead($host);
+    for ( $i = 0 ; $i < @Backups ; $i++ ) {
+        last if ( $Backups[$i]{num} == $num );
+    }
+    if ( $i >= @Backups ) {
+        ErrorExit("Backup number $num for host ${EscHTML($host)} does"
+	        . " not exist.");
+    }
+    my $backupTime = timeStamp2($Backups[$i]{startTime});
+    my $backupAge = sprintf("%.1f", (time - $Backups[$i]{startTime})
+                                    / (24 * 3600));
+    my $view = BackupPC::View->new($bpc, $host, \@Backups);
+
+    if ( $dir eq "" || $dir eq "." || $dir eq ".." ) {
+	$attr = $view->dirAttrib($num, "", "");
+	if ( keys(%$attr) > 0 ) {
+	    $share = (sort(keys(%$attr)))[0];
+	    $dir   = '/';
+	} else {
+            ErrorExit(eval("qq{$Lang->{Directory___EscHTML}}"));
+	}
+    }
+    $dir = "/$dir" if ( $dir !~ /^\// );
+    my $relDir  = $dir;
+    my $currDir = undef;
+    if ( $dir =~ m{(^|/)\.\.(/|$)} ) {
+        ErrorExit($Lang->{Nice_try__but_you_can_t_put});
+    }
+
+    #
+    # Loop up the directory tree until we hit the top.
+    #
+    my(@DirStrPrev);
+    while ( 1 ) {
+        my($fLast, $fLastum, @DirStr);
+
+	$attr = $view->dirAttrib($num, $share, $relDir);
+        if ( !defined($attr) ) {
+            ErrorExit(eval("qq{$Lang->{Can_t_browse_bad_directory_name2}}"));
+        }
+
+        my $fileCnt = 0;          # file counter
+        $fLast = $dirStr = "";
+
+        #
+        # Loop over each of the files in this directory
+        #
+	foreach my $f ( sort(keys(%$attr)) ) {
+            my($dirOpen, $gotDir, $imgStr, $img, $path);
+            my $fURI = $f;                             # URI escaped $f
+            my $shareURI = $share;                     # URI escaped $share
+	    if ( $relDir eq "" ) {
+		$path = "/$f";
+	    } else {
+		($path = "$relDir/$f") =~ s{//+}{/}g;
+	    }
+	    if ( $shareURI eq "" ) {
+		$shareURI = $f;
+		$path  = "/";
+	    }
+            $path =~ s{^/+}{/};
+            $path     =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
+            $fURI     =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
+            $shareURI =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
+            $dirOpen  = 1 if ( defined($currDir) && $f eq $currDir );
+            if ( $attr->{$f}{type} == BPC_FTYPE_DIR ) {
+                #
+                # Display directory if it exists in current backup.
+                # First find out if there are subdirs
+                #
+		my($bold, $unbold, $BGcolor);
+		$img |= 1 << 6;
+		$img |= 1 << 5 if ( $attr->{$f}{nlink} > 2 );
+		if ( $dirOpen ) {
+		    $bold = "";
+		    $unbold = "";
+		    $img |= 1 << 2;
+		    $img |= 1 << 3 if ( $attr->{$f}{nlink} > 2 );
+		}
+		my $imgFileName = sprintf("%07b.gif", $img);
+		$imgStr = "";
+		if ( "$relDir/$f" eq $dir ) {
+		    $BGcolor = " bgcolor=\"$Conf{CgiHeaderBgColor}\"";
+		} else {
+		    $BGcolor = "";
+		}
+		my $dirName = $f;
+		$dirName =~ s/ / /g;
+		push(@DirStr, {needTick => 1,
+			       tdArgs   => $BGcolor,
+			       link     => <$imgStr $bold$dirName$unbold
+EOF
+                $fileCnt++;
+                $gotDir = 1;
+		if ( $dirOpen ) {
+		    my($lastTick, $doneLastTick);
+		    foreach my $d ( @DirStrPrev ) {
+			$lastTick = $d if ( $d->{needTick} );
+		    }
+		    $doneLastTick = 1 if ( !defined($lastTick) );
+		    foreach my $d ( @DirStrPrev ) {
+			$img = 0;
+			if  ( $d->{needTick} ) {
+			    $img |= 1 << 0;
+			}
+			if ( $d == $lastTick ) {
+			    $img |= 1 << 4;
+			    $doneLastTick = 1;
+			} elsif ( !$doneLastTick ) {
+			    $img |= 1 << 3 | 1 << 4;
+			}
+			my $imgFileName = sprintf("%07b.gif", $img);
+			$imgStr = "";
+			push(@DirStr, {needTick => 0,
+				       tdArgs   => $d->{tdArgs},
+				       link     => $imgStr . $d->{link}
+			});
+		    }
+		}
+            }
+            if ( $relDir eq $dir ) {
+                #
+                # This is the selected directory, so display all the files
+                #
+                my $attrStr;
+                if ( defined($a = $attr->{$f}) ) {
+                    my $mtimeStr = $bpc->timeStamp($a->{mtime});
+		    # UGH -> fix this
+                    my $typeStr  = BackupPC::Attrib::fileType2Text(undef,
+								   $a->{type});
+                    my $modeStr  = sprintf("0%o", $a->{mode} & 07777);
+                    $attrStr .= <$typeStr
+    $modeStr
+    $a->{backupNum}
+    $a->{size}
+    $mtimeStr
+
+EOF
+                } else {
+                    $attrStr .= " \n";
+                }
+		(my $fDisp = "${EscHTML($f)}") =~ s/ / /g;
+                if ( $gotDir ) {
+                    $fileStr .= < $fDisp
+$attrStr
+
+EOF
+                } else {
+                    $fileStr .= < $fDisp
+$attrStr
+
+EOF
+                }
+                $checkBoxCnt++;
+            }
+        }
+	@DirStrPrev = @DirStr;
+        last if ( $relDir eq "" && $share eq "" );
+        # 
+        # Prune the last directory off $relDir, or at the very end
+	# do the top-level directory.
+        #
+	if ( $relDir eq "" || $relDir eq "/" || $relDir !~ /(.*)\/(.*)/ ) {
+	    $currDir = $share;
+	    $share = "";
+	    $relDir = "";
+	} else {
+	    $relDir  = $1;
+	    $currDir = $2;
+	}
+    }
+    $share = $currDir;
+    my $dirDisplay = "$share/$dir";
+    $dirDisplay =~ s{//+}{/}g;
+    $dirDisplay =~ s{/+$}{}g;
+    $dirDisplay = "/" if ( $dirDisplay eq "" );
+    my $filledBackup;
+
+    if ( (my @mergeNums = @{$view->mergeNums}) > 1 ) {
+	shift(@mergeNums);
+	my $numF = join(", #", @mergeNums);
+        $filledBackup = eval("qq{$Lang->{This_display_is_merged_with_backup}}");
+    }
+    Header(eval("qq{$Lang->{Browse_backup__num_for__host}}"));
+
+    foreach my $d ( @DirStrPrev ) {
+	$dirStr .= "{tdArgs}>$d->{link}\n";
+    }
+
+    ### hide checkall button if there are no files
+    my ($topCheckAll, $checkAll, $fileHeader);
+    if ( $fileStr ) {
+    	$fileHeader = eval("qq{$Lang->{fileHeader}}");
+
+	$checkAll = $Lang->{checkAll};
+
+    	# and put a checkall box on top if there are at least 20 files
+	if ( $checkBoxCnt >= 20 ) {
+	    $topCheckAll = $checkAll;
+	    $topCheckAll =~ s{allFiles}{allFilestop}g;
+	}
+    } else {
+	$fileStr = eval("qq{$Lang->{The_directory_is_empty}}");
+    }
+    my @otherDirs;
+    foreach my $i ( $view->backupList($share, $dir) ) {
+        my $path = $dir;
+        my $shareURI = $share;
+        $path =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg;
+        $shareURI =~ s/([^\w.\/-])/uc sprintf("%%%02x", ord($1))/eg;
+        push(@otherDirs, "$i");
+
+    }
+    if ( @otherDirs ) {
+	my $otherDirs  = join(",\n", @otherDirs);
+        $filledBackup .= eval("qq{$Lang->{Visit_this_directory_in_backup}}");
+    }
+    print (eval("qq{$Lang->{Backup_browse_for__host}}"));
+    Trailer();
+}
+
+sub Action_Restore
+{
+    my($str, $reply);
+    my $Privileged = CheckPermission($In{host});
+    if ( !$Privileged ) {
+        ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_restore_backup_files}}"));
+    }
+    my $host  = $In{host};
+    my $num   = $In{num};
+    my $share = $In{share};
+    my(@fileList, $fileListStr, $hiddenStr, $pathHdr, $badFileCnt);
+    my @Backups = $bpc->BackupInfoRead($host);
+
+    ServerConnect();
+    if ( !defined($Hosts->{$host}) ) {
+        ErrorExit(eval("qq{$Lang->{Bad_host_name}}"));
+    }
+    for ( my $i = 0 ; $i < $In{fcbMax} ; $i++ ) {
+        next if ( !defined($In{"fcb$i"}) );
+        (my $name = $In{"fcb$i"}) =~ s/%([0-9A-F]{2})/chr(hex($1))/eg;
+        $badFileCnt++ if ( $name =~ m{(^|/)\.\.(/|$)} );
+	if ( @fileList == 0 ) {
+	    $pathHdr = $name;
+	} else {
+	    while ( substr($name, 0, length($pathHdr)) ne $pathHdr ) {
+		$pathHdr = substr($pathHdr, 0, rindex($pathHdr, "/"));
+	    }
+	}
+        push(@fileList, $name);
+        $hiddenStr .= <
+EOF
+        $fileListStr .= < ${EscHTML($name)}
+EOF
+    }
+    $hiddenStr .= "\n";
+    $hiddenStr .= "\n";
+    $badFileCnt++ if ( $In{pathHdr} =~ m{(^|/)\.\.(/|$)} );
+    $badFileCnt++ if ( $In{num} =~ m{(^|/)\.\.(/|$)} );
+    if ( @fileList == 0 ) {
+        ErrorExit($Lang->{You_haven_t_selected_any_files__please_go_Back_to});
+    }
+    if ( $badFileCnt ) {
+        ErrorExit($Lang->{Nice_try__but_you_can_t_put});
+    }
+    if ( @fileList == 1 ) {
+	$pathHdr =~ s/(.*)\/.*/$1/;
+    }
+    $pathHdr = "/" if ( $pathHdr eq "" );
+    if ( $In{type} != 0 && @fileList == $In{fcbMax} ) {
+	#
+	# All the files in the list were selected, so just restore the
+	# entire parent directory
+	#
+	@fileList = ( $pathHdr );
+    }
+    if ( $In{type} == 0 ) {
+        #
+        # Tell the user what options they have
+        #
+        Header(eval("qq{$Lang->{Restore_Options_for__host}}"));
+	print(eval("qq{$Lang->{Restore_Options_for__host2}}"));
+
+	#
+	# Verify that Archive::Zip is available before showing the
+	# zip restore option
+	#
+	if ( eval { require Archive::Zip } ) {
+	    print (eval("qq{$Lang->{Option_2__Download_Zip_archive}}"));
+	} else {
+	    print (eval("qq{$Lang->{Option_2__Download_Zip_archive2}}"));
+	}
+	print (eval("qq{$Lang->{Option_3__Download_Zip_archive}}"));
+        Trailer();
+    } elsif ( $In{type} == 1 ) {
+        #
+        # Provide the selected files via a tar archive.
+	#
+	my @fileListTrim = @fileList;
+	if ( @fileListTrim > 10 ) {
+	    @fileListTrim = (@fileListTrim[0..9], '...');
+	}
+	$bpc->ServerMesg("log User $User downloaded tar archive for $host,"
+		       . " backup $num; files were: "
+		       . join(", ", @fileListTrim));
+
+        my @pathOpts;
+        if ( $In{relative} ) {
+            @pathOpts = ("-r", $pathHdr, "-p", "");
+        }
+	print(STDOUT <cmdSystemOrEval(["$BinDir/BackupPC_tarCreate",
+		 "-h", $host,
+		 "-n", $num,
+		 "-s", $share,
+		 @pathOpts,
+		 @fileList
+	    ],
+	    sub { print(@_); }
+	);
+    } elsif ( $In{type} == 2 ) {
+        #
+        # Provide the selected files via a zip archive.
+	#
+	my @fileListTrim = @fileList;
+	if ( @fileListTrim > 10 ) {
+	    @fileListTrim = (@fileListTrim[0..9], '...');
+	}
+	$bpc->ServerMesg("log User $User downloaded zip archive for $host,"
+		       . " backup $num; files were: "
+		       . join(", ", @fileListTrim));
+
+        my @pathOpts;
+        if ( $In{relative} ) {
+            @pathOpts = ("-r", $pathHdr, "-p", "");
+        }
+	print(STDOUT <cmdSystemOrEval(["$BinDir/BackupPC_zipCreate",
+		 "-h", $host,
+		 "-n", $num,
+		 "-c", $In{compressLevel},
+		 "-s", $share,
+		 @pathOpts,
+		 @fileList
+	    ],
+	    sub { print(@_); }
+	);
+    } elsif ( $In{type} == 3 ) {
+        #
+        # Do restore directly onto host
+        #
+	if ( !defined($Hosts->{$In{hostDest}}) ) {
+	    ErrorExit(eval("qq{$Lang->{Host__doesn_t_exist}}"));
+	}
+	if ( !CheckPermission($In{hostDest}) ) {
+	    ErrorExit(eval("qq{$Lang->{You_don_t_have_permission_to_restore_onto_host}}"));
+	}
+        $fileListStr = "";
+        foreach my $f ( @fileList ) {
+            my $targetFile = $f;
+	    (my $strippedShare = $share) =~ s/^\///;
+	    (my $strippedShareDest = $In{shareDest}) =~ s/^\///;
+            substr($targetFile, 0, length($pathHdr)) = $In{pathHdr};
+            $fileListStr .= <$host:/$strippedShare$f$In{hostDest}:/$strippedShareDest$targetFile
+EOF
+        }
+        Header(eval("qq{$Lang->{Restore_Confirm_on__host}}"));
+	print(eval("qq{$Lang->{Are_you_sure}}"));
+        Trailer();
+    } elsif ( $In{type} == 4 ) {
+	if ( !defined($Hosts->{$In{hostDest}}) ) {
+	    ErrorExit(eval("qq{$Lang->{Host__doesn_t_exist}}"));
+	}
+	if ( !CheckPermission($In{hostDest}) ) {
+	    ErrorExit(eval("qq{$Lang->{You_don_t_have_permission_to_restore_onto_host}}"));
+	}
+	my $hostDest = $1 if ( $In{hostDest} =~ /(.+)/ );
+	my $ipAddr = ConfirmIPAddress($hostDest);
+        #
+        # Prepare and send the restore request.  We write the request
+        # information using Data::Dumper to a unique file,
+        # $TopDir/pc/$hostDest/restoreReq.$$.n.  We use a file
+        # in case the list of files to restore is very long.
+        #
+        my $reqFileName;
+        for ( my $i = 0 ; ; $i++ ) {
+            $reqFileName = "restoreReq.$$.$i";
+            last if ( !-f "$TopDir/pc/$hostDest/$reqFileName" );
+        }
+        my %restoreReq = (
+	    # source of restore is hostSrc, #num, path shareSrc/pathHdrSrc
+            num         => $In{num},
+            hostSrc     => $host,
+            shareSrc    => $share,
+            pathHdrSrc  => $pathHdr,
+
+	    # destination of restore is hostDest:shareDest/pathHdrDest
+            hostDest    => $hostDest,
+            shareDest   => $In{shareDest},
+            pathHdrDest => $In{pathHdr},
+
+	    # list of files to restore
+            fileList    => \@fileList,
+
+	    # other info
+            user        => $User,
+            reqTime     => time,
+        );
+        my($dump) = Data::Dumper->new(
+                         [  \%restoreReq],
+                         [qw(*RestoreReq)]);
+        $dump->Indent(1);
+        if ( open(REQ, ">$TopDir/pc/$hostDest/$reqFileName") ) {
+	    binmode(REQ);
+            print(REQ $dump->Dump);
+            close(REQ);
+        } else {
+            ErrorExit(eval("qq{$Lang->{Can_t_open_create}}"));
+        }
+	$reply = $bpc->ServerMesg("restore ${EscURI($ipAddr)}"
+			. " ${EscURI($hostDest)} $User $reqFileName");
+	$str = eval("qq{$Lang->{Restore_requested_to_host__hostDest__backup___num}}");
+        Header(eval("qq{$Lang->{Restore_Requested_on__hostDest}}"));
+	print (eval("qq{$Lang->{Reply_from_server_was___reply}}"));
+        Trailer();
+    }
+}
+
+sub Action_RestoreFile
+{
+    restoreFile($In{host}, $In{num}, $In{share}, $In{dir});
+}
+
+sub restoreFile
+{
+    my($host, $num, $share, $dir, $skipHardLink, $origName) = @_;
+    my($Privileged) = CheckPermission($host);
+
+    #
+    # Some common content (media) types from www.iana.org (via MIME::Types).
+    #
+    my $Ext2ContentType = {
+	'asc'  => 'text/plain',
+	'avi'  => 'video/x-msvideo',
+	'bmp'  => 'image/bmp',
+	'book' => 'application/x-maker',
+	'cc'   => 'text/plain',
+	'cpp'  => 'text/plain',
+	'csh'  => 'application/x-csh',
+	'csv'  => 'text/comma-separated-values',
+	'c'    => 'text/plain',
+	'deb'  => 'application/x-debian-package',
+	'doc'  => 'application/msword',
+	'dot'  => 'application/msword',
+	'dtd'  => 'text/xml',
+	'dvi'  => 'application/x-dvi',
+	'eps'  => 'application/postscript',
+	'fb'   => 'application/x-maker',
+	'fbdoc'=> 'application/x-maker',
+	'fm'   => 'application/x-maker',
+	'frame'=> 'application/x-maker',
+	'frm'  => 'application/x-maker',
+	'gif'  => 'image/gif',
+	'gtar' => 'application/x-gtar',
+	'gz'   => 'application/x-gzip',
+	'hh'   => 'text/plain',
+	'hpp'  => 'text/plain',
+	'h'    => 'text/plain',
+	'html' => 'text/html',
+	'htmlx'=> 'text/html',
+	'htm'  => 'text/html',
+	'iges' => 'model/iges',
+	'igs'  => 'model/iges',
+	'jpeg' => 'image/jpeg',
+	'jpe'  => 'image/jpeg',
+	'jpg'  => 'image/jpeg',
+	'js'   => 'application/x-javascript',
+	'latex'=> 'application/x-latex',
+	'maker'=> 'application/x-maker',
+	'mid'  => 'audio/midi',
+	'midi' => 'audio/midi',
+	'movie'=> 'video/x-sgi-movie',
+	'mov'  => 'video/quicktime',
+	'mp2'  => 'audio/mpeg',
+	'mp3'  => 'audio/mpeg',
+	'mpeg' => 'video/mpeg',
+	'mpg'  => 'video/mpeg',
+	'mpp'  => 'application/vnd.ms-project',
+	'pdf'  => 'application/pdf',
+	'pgp'  => 'application/pgp-signature',
+	'php'  => 'application/x-httpd-php',
+	'pht'  => 'application/x-httpd-php',
+	'phtml'=> 'application/x-httpd-php',
+	'png'  => 'image/png',
+	'ppm'  => 'image/x-portable-pixmap',
+	'ppt'  => 'application/powerpoint',
+	'ppt'  => 'application/vnd.ms-powerpoint',
+	'ps'   => 'application/postscript',
+	'qt'   => 'video/quicktime',
+	'rgb'  => 'image/x-rgb',
+	'rtf'  => 'application/rtf',
+	'rtf'  => 'text/rtf',
+	'shar' => 'application/x-shar',
+	'shtml'=> 'text/html',
+	'swf'  => 'application/x-shockwave-flash',
+	'tex'  => 'application/x-tex',
+	'texi' => 'application/x-texinfo',
+	'texinfo'=> 'application/x-texinfo',
+	'tgz'  => 'application/x-gtar',
+	'tiff' => 'image/tiff',
+	'tif'  => 'image/tiff',
+	'txt'  => 'text/plain',
+	'vcf'  => 'text/x-vCard',
+	'vrml' => 'model/vrml',
+	'wav'  => 'audio/x-wav',
+	'wmls' => 'text/vnd.wap.wmlscript',
+	'wml'  => 'text/vnd.wap.wml',
+	'wrl'  => 'model/vrml',
+	'xls'  => 'application/vnd.ms-excel',
+	'xml'  => 'text/xml',
+	'xwd'  => 'image/x-xwindowdump',
+	'z'    => 'application/x-compress',
+	'zip'  => 'application/zip',
+        %{$Conf{CgiExt2ContentType}},       # add site-specific values
+    };
+    if ( !$Privileged ) {
+        ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_restore_backup_files2}}"));
+    }
+    ServerConnect();
+    ErrorExit($Lang->{Empty_host_name}) if ( $host eq "" );
+
+    $dir = "/" if ( $dir eq "" );
+    my @Backups = $bpc->BackupInfoRead($host);
+    my $view = BackupPC::View->new($bpc, $host, \@Backups);
+    my $a = $view->fileAttrib($num, $share, $dir);
+    if ( $dir =~ m{(^|/)\.\.(/|$)} || !defined($a) ) {
+        ErrorExit("Can't restore bad file ${EscHTML($dir)}");
+    }
+    my $f = BackupPC::FileZIO->open($a->{fullPath}, 0, $a->{compress});
+    my $data;
+    if ( !$skipHardLink && $a->{type} == BPC_FTYPE_HARDLINK ) {
+	#
+	# hardlinks should look like the file they point to
+	#
+	my $linkName;
+        while ( $f->read(\$data, 65536) > 0 ) {
+            $linkName .= $data;
+        }
+	$f->close;
+	$linkName =~ s/^\.\///;
+	my $share = $1 if ( $dir =~ /^\/?(.*?)\// );
+	restoreFile($host, $num, $share, $linkName, 1, $dir);
+	return;
+    }
+    $bpc->ServerMesg("log User $User recovered file $host/$num:$share/$dir ($a->{fullPath})");
+    $dir = $origName if ( defined($origName) );
+    my $ext = $1 if ( $dir =~ /\.([^\/\.]+)$/ );
+    my $contentType = $Ext2ContentType->{lc($ext)}
+				    || "application/octet-stream";
+    my $fileName = $1 if ( $dir =~ /.*\/(.*)/ );
+    $fileName =~ s/"/\\"/g;
+    print "Content-Type: $contentType\n";
+    print "Content-Transfer-Encoding: binary\n";
+    print "Content-Disposition: attachment; filename=\"$fileName\"\n\n";
+    while ( $f->read(\$data, 1024 * 1024) > 0 ) {
+        print STDOUT $data;
+    }
+    $f->close;
+}
+
+sub Action_HostInfo
+{
+    my $host = $1 if ( $In{host} =~ /(.*)/ );
+    my($statusStr, $startIncrStr);
+
+    $host =~ s/^\s+//;
+    $host =~ s/\s+$//;
+    return Action_GeneralInfo() if ( $host eq "" );
+    $host = lc($host)
+                if ( !-d "$TopDir/pc/$host" && -d "$TopDir/pc/" . lc($host) );
+    if ( $host =~ /\.\./ || !-d "$TopDir/pc/$host" ) {
+        #
+        # try to lookup by user name
+        #
+        if ( !defined($Hosts->{$host}) ) {
+            foreach my $h ( keys(%$Hosts) ) {
+                if ( $Hosts->{$h}{user} eq $host
+                        || lc($Hosts->{$h}{user}) eq lc($host) ) {
+                    $host = $h;
+                    last;
+                }
+            }
+            CheckPermission();
+            ErrorExit(eval("qq{$Lang->{Unknown_host_or_user}}"))
+                                if ( !defined($Hosts->{$host}) );
+        }
+        $In{host} = $host;
+    }
+    GetStatusInfo("host(${EscURI($host)})");
+    $bpc->ConfigRead($host);
+    %Conf = $bpc->Conf();
+    my $Privileged = CheckPermission($host);
+    if ( !$Privileged ) {
+        ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_view_information_about}}"));
+    }
+    ReadUserEmailInfo();
+
+    my @Backups = $bpc->BackupInfoRead($host);
+    my($str, $sizeStr, $compStr, $errStr, $warnStr);
+    for ( my $i = 0 ; $i < @Backups ; $i++ ) {
+        my $startTime = timeStamp2($Backups[$i]{startTime});
+        my $dur       = $Backups[$i]{endTime} - $Backups[$i]{startTime};
+        $dur          = 1 if ( $dur <= 0 );
+        my $duration  = sprintf("%.1f", $dur / 60);
+        my $MB        = sprintf("%.1f", $Backups[$i]{size} / (1024*1024));
+        my $MBperSec  = sprintf("%.2f", $Backups[$i]{size} / (1024*1024*$dur));
+        my $MBExist   = sprintf("%.1f", $Backups[$i]{sizeExist} / (1024*1024));
+        my $MBNew     = sprintf("%.1f", $Backups[$i]{sizeNew} / (1024*1024));
+        my($MBExistComp, $ExistComp, $MBNewComp, $NewComp);
+        if ( $Backups[$i]{sizeExist} && $Backups[$i]{sizeExistComp} ) {
+            $MBExistComp = sprintf("%.1f", $Backups[$i]{sizeExistComp}
+                                                / (1024 * 1024));
+            $ExistComp = sprintf("%.1f%%", 100 *
+                  (1 - $Backups[$i]{sizeExistComp} / $Backups[$i]{sizeExist}));
+        }
+        if ( $Backups[$i]{sizeNew} && $Backups[$i]{sizeNewComp} ) {
+            $MBNewComp = sprintf("%.1f", $Backups[$i]{sizeNewComp}
+                                                / (1024 * 1024));
+            $NewComp = sprintf("%.1f%%", 100 *
+                  (1 - $Backups[$i]{sizeNewComp} / $Backups[$i]{sizeNew}));
+        }
+        my $age = sprintf("%.1f", (time - $Backups[$i]{startTime}) / (24*3600));
+        my $browseURL = "$MyURL?action=browse&host=${EscURI($host)}&num=$Backups[$i]{num}";
+        my $filled = $Backups[$i]{noFill} ? $Lang->{No} : $Lang->{Yes};
+        $filled .= " ($Backups[$i]{fillFromNum}) "
+                            if ( $Backups[$i]{fillFromNum} ne "" );
+	my $ltype;
+	if ($Backups[$i]{type} eq "full") { $ltype = $Lang->{full}; }
+	else { $ltype = $Lang->{incremental}; }
+        $str .= < $Backups[$i]{num} 
+     $ltype 
+     $filled 
+      $startTime 
+      $duration 
+      $age 
+       $TopDir/pc/$host/$Backups[$i]{num} 
+EOF
+        $sizeStr .= < $Backups[$i]{num} 
+     $ltype 
+      $Backups[$i]{nFiles} 
+      $MB 
+      $MBperSec 
+      $Backups[$i]{nFilesExist} 
+      $MBExist 
+      $Backups[$i]{nFilesNew} 
+      $MBNew 
+
+EOF
+	my $is_compress = $Backups[$i]{compress} || $Lang->{off};
+	if (! $ExistComp) { $ExistComp = " "; }
+	if (! $MBExistComp) { $MBExistComp = " "; }
+        $compStr .= < $Backups[$i]{num} 
+     $ltype 
+     $is_compress  
+      $MBExist 
+      $MBExistComp  
+      $ExistComp    
+      $MBNew 
+      $MBNewComp 
+      $NewComp 
+
+EOF
+        $errStr .= < $Backups[$i]{num} 
+     $ltype 
+     $Lang->{XferLOG},
+                      $Lang->{Errors} 
+      $Backups[$i]{xferErrs} 
+      $Backups[$i]{xferBadFile} 
+      $Backups[$i]{xferBadShare} 
+      $Backups[$i]{tarErrs} 
+EOF
+    }
+
+    my @Restores = $bpc->RestoreInfoRead($host);
+    my $restoreStr;
+
+    for ( my $i = 0 ; $i < @Restores ; $i++ ) {
+        my $startTime = timeStamp2($Restores[$i]{startTime});
+        my $dur       = $Restores[$i]{endTime} - $Restores[$i]{startTime};
+        $dur          = 1 if ( $dur <= 0 );
+        my $duration  = sprintf("%.1f", $dur / 60);
+        my $MB        = sprintf("%.1f", $Restores[$i]{size} / (1024*1024));
+        my $MBperSec  = sprintf("%.2f", $Restores[$i]{size} / (1024*1024*$dur));
+	my $Restores_Result = $Lang->{failed};
+	if ($Restores[$i]{result} ne "failed") { $Restores_Result = $Lang->{success}; }
+	$restoreStr  .= <$Restores[$i]{num} 
+     $Restores_Result 
+     $startTime 
+     $duration 
+     $Restores[$i]{nFiles} 
+     $MB 
+     $Restores[$i]{tarCreateErrs} 
+     $Restores[$i]{xferErrs} 
+
+EOF
+    }
+    if ( $restoreStr ne "" ) {
+	$restoreStr = eval("qq{$Lang->{Restore_Summary}}");
+    }
+    if ( @Backups == 0 ) {
+        $warnStr = $Lang->{This_PC_has_never_been_backed_up};
+    }
+    if ( defined($Hosts->{$host}) ) {
+        my $user = $Hosts->{$host}{user};
+	my @moreUsers = sort(keys(%{$Hosts->{$host}{moreUsers}}));
+	my $moreUserStr;
+	foreach my $u ( sort(keys(%{$Hosts->{$host}{moreUsers}})) ) {
+	    $moreUserStr .= ", " if ( $moreUserStr ne "" );
+	    $moreUserStr .= "${UserLink($u)}";
+	}
+	if ( $moreUserStr ne "" ) {
+	    $moreUserStr = " ($Lang->{and} $moreUserStr).\n";
+	} else {
+	    $moreUserStr = ".\n";
+	}
+        if ( $user ne "" ) {
+            $statusStr .= eval("qq{$Lang->{This_PC_is_used_by}$moreUserStr}");
+        }
+        if ( defined($UserEmailInfo{$user})
+                && $UserEmailInfo{$user}{lastHost} eq $host ) {
+            my $mailTime = timeStamp2($UserEmailInfo{$user}{lastTime});
+            my $subj     = $UserEmailInfo{$user}{lastSubj};
+            $statusStr  .= eval("qq{$Lang->{Last_email_sent_to__was_at___subject}}");
+        }
+    }
+    if ( defined($Jobs{$host}) ) {
+        my $startTime = timeStamp2($Jobs{$host}{startTime});
+        (my $cmd = $Jobs{$host}{cmd}) =~ s/$BinDir\///g;
+        $statusStr .= eval("qq{$Lang->{The_command_cmd_is_currently_running_for_started}}");
+    }
+    if ( $StatusHost{BgQueueOn} ) {
+        $statusStr .= eval("qq{$Lang->{Host_host_is_queued_on_the_background_queue_will_be_backed_up_soon}}");
+    }
+    if ( $StatusHost{UserQueueOn} ) {
+        $statusStr .= eval("qq{$Lang->{Host_host_is_queued_on_the_user_queue__will_be_backed_up_soon}}");
+    }
+    if ( $StatusHost{CmdQueueOn} ) {
+        $statusStr .= eval("qq{$Lang->{A_command_for_host_is_on_the_command_queue_will_run_soon}}");
+    }
+    my $startTime = timeStamp2($StatusHost{endTime} == 0 ?
+                $StatusHost{startTime} : $StatusHost{endTime});
+    my $reason = "";
+    if ( $StatusHost{reason} ne "" ) {
+        $reason = " ($Lang->{$StatusHost{reason}})";
+    }
+    $statusStr .= eval("qq{$Lang->{Last_status_is_state_StatusHost_state_reason_as_of_startTime}}");
+
+    if ( $StatusHost{state} ne "Status_backup_in_progress"
+	    && $StatusHost{state} ne "Status_restore_in_progress"
+	    && $StatusHost{error} ne "" ) {
+        $statusStr .= eval("qq{$Lang->{Last_error_is____EscHTML_StatusHost_error}}");
+    }
+    my $priorStr = "Pings";
+    if ( $StatusHost{deadCnt} > 0 ) {
+        $statusStr .= eval("qq{$Lang->{Pings_to_host_have_failed_StatusHost_deadCnt__consecutive_times}}");
+        $priorStr = $Lang->{Prior_to_that__pings};
+    }
+    if ( $StatusHost{aliveCnt} > 0 ) {
+        $statusStr .= eval("qq{$Lang->{priorStr_to_host_have_succeeded_StatusHostaliveCnt_consecutive_times}}");
+
+        if ( $StatusHost{aliveCnt} >= $Conf{BlackoutGoodCnt}
+		&& $Conf{BlackoutGoodCnt} >= 0 && $Conf{BlackoutHourBegin} >= 0
+		&& $Conf{BlackoutHourEnd} >= 0 ) {
+            my(@days) = qw(Sun Mon Tue Wed Thu Fri Sat);
+            my($days) = join(", ", @days[@{$Conf{BlackoutWeekDays}}]);
+            my($t0) = sprintf("%d:%02d", $Conf{BlackoutHourBegin},
+                            60 * ($Conf{BlackoutHourBegin}
+                                     - int($Conf{BlackoutHourBegin})));
+            my($t1) = sprintf("%d:%02d", $Conf{BlackoutHourEnd},
+                            60 * ($Conf{BlackoutHourEnd}
+                                     - int($Conf{BlackoutHourEnd})));
+            $statusStr .= eval("qq{$Lang->{Because__host_has_been_on_the_network_at_least__Conf_BlackoutGoodCnt_consecutive_times___}}");
+        }
+    }
+    if ( $StatusHost{backoffTime} > time ) {
+        my $hours = sprintf("%.1f", ($StatusHost{backoffTime} - time) / 3600);
+        $statusStr .= eval("qq{$Lang->{Backups_are_deferred_for_hours_hours_change_this_number}}");
+
+    }
+    if ( @Backups ) {
+        # only allow incremental if there are already some backups
+        $startIncrStr = <
+EOF
+    }
+
+    $startIncrStr = eval ("qq{$startIncrStr}");
+
+    Header(eval("qq{$Lang->{Host__host_Backup_Summary}}"));
+    print(eval("qq{$Lang->{Host__host_Backup_Summary2}}"));
+    Trailer();
+}
+
+sub Action_GeneralInfo
+{
+    GetStatusInfo("info jobs hosts queueLen");
+    my $Privileged = CheckPermission();
+
+    my($jobStr, $statusStr);
+    foreach my $host ( sort(keys(%Jobs)) ) {
+        my $startTime = timeStamp2($Jobs{$host}{startTime});
+        next if ( $host eq $bpc->trashJob
+                    && $Jobs{$host}{processState} ne "running" );
+        $Jobs{$host}{type} = $Status{$host}{type}
+                    if ( $Jobs{$host}{type} eq "" && defined($Status{$host}));
+        (my $cmd = $Jobs{$host}{cmd}) =~ s/$BinDir\///g;
+        (my $xferPid = $Jobs{$host}{xferPid}) =~ s/,/, /g;
+        $jobStr .= < ${HostLink($host)} 
+     $Jobs{$host}{type} 
+     ${UserLink(defined($Hosts->{$host})
+					? $Hosts->{$host}{user} : "")} 
+     $startTime 
+     $cmd 
+     $Jobs{$host}{pid} 
+     $xferPid 
+EOF
+        $jobStr .= "\n";
+    }
+    foreach my $host ( sort(keys(%Status)) ) {
+        next if ( $Status{$host}{reason} ne "Reason_backup_failed"
+		    && $Status{$host}{reason} ne "Reason_restore_failed"
+		    && (!$Status{$host}{userReq}
+			|| $Status{$host}{reason} ne "Reason_no_ping") );
+        my $startTime = timeStamp2($Status{$host}{startTime});
+        my($errorTime, $XferViewStr);
+        if ( $Status{$host}{errorTime} > 0 ) {
+            $errorTime = timeStamp2($Status{$host}{errorTime});
+        }
+        if ( -f "$TopDir/pc/$host/SmbLOG.bad"
+                || -f "$TopDir/pc/$host/SmbLOG.bad.z"
+                || -f "$TopDir/pc/$host/XferLOG.bad"
+                || -f "$TopDir/pc/$host/XferLOG.bad.z"
+                ) {
+            $XferViewStr = <$Lang->{XferLOG},
+$Lang->{Errors}
+EOF
+        } else {
+            $XferViewStr = "";
+        }
+        (my $shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../;   
+        $statusStr .= < ${HostLink($host)} 
+     $Status{$host}{type} 
+     ${UserLink(defined($Hosts->{$host})
+					? $Hosts->{$host}{user} : "")} 
+     $startTime 
+     $XferViewStr 
+     $errorTime 
+     ${EscHTML($shortErr)} 
+EOF
+    }
+    my $now          = timeStamp2(time);
+    my $nextWakeupTime = timeStamp2($Info{nextWakeup});
+    my $DUlastTime   = timeStamp2($Info{DUlastValueTime});
+    my $DUmaxTime    = timeStamp2($Info{DUDailyMaxTime});
+    my $numBgQueue   = $QueueLen{BgQueue};
+    my $numUserQueue = $QueueLen{UserQueue};
+    my $numCmdQueue  = $QueueLen{CmdQueue};
+    my $serverStartTime = timeStamp2($Info{startTime});
+    my $poolInfo     = genPoolInfo("pool", \%Info);
+    my $cpoolInfo    = genPoolInfo("cpool", \%Info);
+    if ( $Info{poolFileCnt} > 0 && $Info{cpoolFileCnt} > 0 ) {
+        $poolInfo = <Uncompressed pool:
+
    +$poolInfo +
+
  • Compressed pool: +
      +$cpoolInfo +
    +EOF + } elsif ( $Info{cpoolFileCnt} > 0 ) { + $poolInfo = $cpoolInfo; + } + + Header($Lang->{H_BackupPC_Server_Status}); + print (eval ("qq{$Lang->{BackupPC_Server_Status}}")); + Trailer(); +} + +sub Action_RestoreInfo +{ + my $Privileged = CheckPermission($In{host}); + my $host = $1 if ( $In{host} =~ /(.*)/ ); + my $num = $In{num}; + my $i; + + if ( !$Privileged ) { + ErrorExit($Lang->{Only_privileged_users_can_view_restore_information}); + } + # + # Find the requested restore + # + my @Restores = $bpc->RestoreInfoRead($host); + for ( $i = 0 ; $i < @Restores ; $i++ ) { + last if ( $Restores[$i]{num} == $num ); + } + if ( $i >= @Restores ) { + ErrorExit(eval("qq{$Lang->{Restore_number__num_for_host__does_not_exist}}")); + } + + %RestoreReq = (); + do "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" + if ( -f "$TopDir/pc/$host/RestoreInfo.$Restores[$i]{num}" ); + + my $startTime = timeStamp2($Restores[$i]{startTime}); + my $reqTime = timeStamp2($RestoreReq{reqTime}); + my $dur = $Restores[$i]{endTime} - $Restores[$i]{startTime}; + $dur = 1 if ( $dur <= 0 ); + my $duration = sprintf("%.1f", $dur / 60); + my $MB = sprintf("%.1f", $Restores[$i]{size} / (1024*1024)); + my $MBperSec = sprintf("%.2f", $Restores[$i]{size} / (1024*1024*$dur)); + + my $fileListStr = ""; + foreach my $f ( @{$RestoreReq{fileList}} ) { + my $targetFile = $f; + (my $strippedShareSrc = $RestoreReq{shareSrc}) =~ s/^\///; + (my $strippedShareDest = $RestoreReq{shareDest}) =~ s/^\///; + substr($targetFile, 0, length($RestoreReq{pathHdrSrc})) + = $RestoreReq{pathHdrDest}; + $fileListStr .= <$RestoreReq{hostSrc}:/$strippedShareSrc$f$RestoreReq{hostDest}:/$strippedShareDest$targetFile +EOF + } + + Header(eval("qq{$Lang->{Restore___num_details_for__host}}")); + print(eval("qq{$Lang->{Restore___num_details_for__host2 }}")); + Trailer(); +} + +########################################################################### +# Miscellaneous subroutines +########################################################################### + +sub timeStamp2 +{ + my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) + = localtime($_[0] == 0 ? time : $_[0] ); + $year += 1900; + $mon++; + if ( $Conf{CgiDateFormatMMDD} ) { + return sprintf("$mon/$mday %02d:%02d", $hour, $min); + } else { + return sprintf("$mday/$mon %02d:%02d", $hour, $min); + } +} + +sub HostLink +{ + my($host) = @_; + my($s); + if ( defined($Hosts->{$host}) || defined($Status{$host}) ) { + $s = "$host"; + } else { + $s = $host; + } + return \$s; +} + +sub UserLink +{ + my($user) = @_; + my($s); + + return \$user if ( $user eq "" + || $Conf{CgiUserUrlCreate} eq "" ); + if ( $Conf{CgiUserHomePageCheck} eq "" + || -f sprintf($Conf{CgiUserHomePageCheck}, $user, $user, $user) ) { + $s = "$user"; + } else { + $s = $user; + } + return \$s; +} + +sub EscHTML +{ + my($s) = @_; + $s =~ s/&/&/g; + $s =~ s/\"/"/g; + $s =~ s/>/>/g; + $s =~ s/\n

    ", @mesg); + $Conf{CgiHeaderFontType} ||= "arial"; + $Conf{CgiHeaderFontSize} ||= "3"; + $Conf{CgiNavBarBgColor} ||= "#ddeeee"; + $Conf{CgiHeaderBgColor} ||= "#99cc33"; + + if ( !defined($ENV{REMOTE_USER}) ) { + $mesg .= < +Note: \$ENV{REMOTE_USER} is not set, which could mean there is an +installation problem. BackupPC_Admin expects Apache to authenticate +the user and pass their user name into this script as the REMOTE_USER +environment variable. See the documentation. +EOF + } + + $bpc->ServerMesg("log User $User (host=$In{host}) got CGI error: $head") + if ( defined($bpc) ); + if ( !defined($Lang->{Error}) ) { + Header("BackupPC: Error"); + $mesg = <$mesg

    +EOF + Trailer(); + } else { + Header(eval("qq{$Lang->{Error}}")); + print (eval("qq{$Lang->{Error____head}}")); + Trailer(); + } + exit(1); +} + +sub ServerConnect +{ + # + # Verify that the server connection is ok + # + return if ( $bpc->ServerOK() ); + $bpc->ServerDisconnect(); + if ( my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}) ) { + ErrorExit(eval("qq{$Lang->{Unable_to_connect_to_BackupPC_server}}")); + } +} + +sub GetStatusInfo +{ + my($status) = @_; + ServerConnect(); + my $reply = $bpc->ServerMesg("status $status"); + $reply = $1 if ( $reply =~ /(.*)/s ); + eval($reply); + # ignore status related to admin and trashClean jobs + if ( $status =~ /\bhosts\b/ ) { + delete($Status{$bpc->adminJob}); + delete($Status{$bpc->trashJob}); + } +} + +sub ReadUserEmailInfo +{ + if ( (stat("$TopDir/log/UserEmailInfo.pl"))[9] != $UserEmailInfoMTime ) { + do "$TopDir/log/UserEmailInfo.pl"; + $UserEmailInfoMTime = (stat("$TopDir/log/UserEmailInfo.pl"))[9]; + } +} + +# +# Check if the user is privileged. A privileged user can access +# any information (backup files, logs, status pages etc). +# +# A user is privileged if they belong to the group +# $Conf{CgiAdminUserGroup}, or they are in $Conf{CgiAdminUsers} +# or they are the user assigned to a host in the host file. +# +sub CheckPermission +{ + my($host) = @_; + my $Privileged = 0; + + return 0 if ( $User eq "" && $Conf{CgiAdminUsers} ne "*" + || $host ne "" && !defined($Hosts->{$host}) ); + if ( $Conf{CgiAdminUserGroup} ne "" ) { + my($n,$p,$gid,$mem) = getgrnam($Conf{CgiAdminUserGroup}); + $Privileged ||= ($mem =~ /\b$User\b/); + } + if ( $Conf{CgiAdminUsers} ne "" ) { + $Privileged ||= ($Conf{CgiAdminUsers} =~ /\b$User\b/); + $Privileged ||= $Conf{CgiAdminUsers} eq "*"; + } + $PrivAdmin = $Privileged; + $Privileged ||= $User eq $Hosts->{$host}{user}; + $Privileged ||= defined($Hosts->{$host}{moreUsers}{$User}); + + return $Privileged; +} + +# +# Returns the list of hosts that should appear in the navigation bar +# for this user. If $Conf{CgiNavBarAdminAllHosts} is set, the admin +# gets all the hosts. Otherwise, regular users get hosts for which +# they are the user or are listed in the moreUsers column in the +# hosts file. +# +sub GetUserHosts +{ + if ( $Conf{CgiNavBarAdminAllHosts} && CheckPermission() ) { + return sort keys %$Hosts; + } + + return sort grep { $Hosts->{$_}{user} eq $User || + defined($Hosts->{$_}{moreUsers}{$User}) } keys(%$Hosts); +} + +# +# Given a host name tries to find the IP address. For non-dhcp hosts +# we just return the host name. For dhcp hosts we check the address +# the user is using ($ENV{REMOTE_ADDR}) and also the last-known IP +# address for $host. (Later we should replace this with a broadcast +# nmblookup.) +# +sub ConfirmIPAddress +{ + my($host) = @_; + my $ipAddr = $host; + + if ( defined($Hosts->{$host}) && $Hosts->{$host}{dhcp} + && $ENV{REMOTE_ADDR} =~ /^(\d+[\.\d]*)$/ ) { + $ipAddr = $1; + my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($ipAddr); + if ( $netBiosHost ne $host ) { + my($tryIP); + GetStatusInfo("host(${EscURI($host)})"); + if ( defined($StatusHost{dhcpHostIP}) + && $StatusHost{dhcpHostIP} ne $ipAddr ) { + $tryIP = eval("qq{$Lang->{tryIP}}"); + ($netBiosHost, $netBiosUser) + = $bpc->NetBiosInfoGet($StatusHost{dhcpHostIP}); + } + if ( $netBiosHost ne $host ) { + ErrorExit(eval("qq{$Lang->{Can_t_find_IP_address_for}}"), + eval("qq{$Lang->{host_is_a_DHCP_host}}")); + } + $ipAddr = $StatusHost{dhcpHostIP}; + } + } + return $ipAddr; +} + +sub genPoolInfo +{ + my($name, $info) = @_; + my $poolSize = sprintf("%.2f", $info->{"${name}Kb"} / (1000 * 1024)); + my $poolRmSize = sprintf("%.2f", $info->{"${name}KbRm"} / (1000 * 1024)); + my $poolTime = timeStamp2($info->{"${name}Time"}); + $info->{"${name}FileCntRm"} = $info->{"${name}FileCntRm"} + 0; + return eval("qq{$Lang->{Pool_Stat}}"); +} + +########################################################################### +# HTML layout subroutines +########################################################################### + +sub Header +{ + my($title) = @_; + my @adminLinks = ( + { link => "", name => $Lang->{Status}, + priv => 1}, + { link => "?action=summary", name => $Lang->{PC_Summary} }, + { link => "?action=view&type=LOG", name => $Lang->{LOG_file} }, + { link => "?action=LOGlist", name => $Lang->{Old_LOGs} }, + { link => "?action=emailSummary", name => $Lang->{Email_summary} }, + { link => "?action=view&type=config", name => $Lang->{Config_file} }, + { link => "?action=view&type=hosts", name => $Lang->{Hosts_file} }, + { link => "?action=queue", name => $Lang->{Current_queues} }, + { link => "?action=view&type=docs", name => $Lang->{Documentation}, + priv => 1}, + { link => "http://backuppc.sourceforge.net/faq", name => "FAQ", + priv => 1}, + { link => "http://backuppc.sourceforge.net", name => "SourceForge", + priv => 1}, + ); + print $Cgi->header(); + print < + +$title +$Conf{CgiHeaders} + + + + +
    +EOF + NavSectionTitle("BackupPC"); + print " \n"; + if ( defined($In{host}) && defined($Hosts->{$In{host}}) ) { + my $host = $In{host}; + NavSectionTitle( eval("qq{$Lang->{Host_Inhost}}") ); + NavSectionStart(); + NavLink("?host=${EscURI($host)}", $Lang->{Home}); + NavLink("?action=view&type=LOG&host=${EscURI($host)}", $Lang->{LOG_file}); + NavLink("?action=LOGlist&host=${EscURI($host)}", $Lang->{Old_LOGs}); + if ( -f "$TopDir/pc/$host/SmbLOG.bad" + || -f "$TopDir/pc/$host/SmbLOG.bad.z" + || -f "$TopDir/pc/$host/XferLOG.bad" + || -f "$TopDir/pc/$host/XferLOG.bad.z" ) { + NavLink("?action=view&type=XferLOGbad&host=${EscURI($host)}", + $Lang->{Last_bad_XferLOG}); + NavLink("?action=view&type=XferErrbad&host=${EscURI($host)}", + $Lang->{Last_bad_XferLOG_errors_only}); + } + if ( -f "$TopDir/pc/$host/config.pl" ) { + NavLink("?action=view&type=config&host=${EscURI($host)}", $Lang->{Config_file}); + } + NavSectionEnd(); + } + NavSectionTitle($Lang->{Hosts}); + if ( defined($Hosts) && %$Hosts > 0 ) { + NavSectionStart(1); + foreach my $host ( GetUserHosts() ) { + NavLink("?host=${EscURI($host)}", $host); + } + NavSectionEnd(); + } + print < +
    $Lang->{Host_or_User_name}
    + + +
    +EOF + NavSectionTitle($Lang->{NavSectionTitle_}); + NavSectionStart(); + foreach my $l ( @adminLinks ) { + if ( $PrivAdmin || $l->{priv} ) { + NavLink($l->{link}, $l->{name}); + } else { + NavLink(undef, $l->{name}); + } + } + NavSectionEnd(); + print <   + +EOF +} + +sub Trailer +{ + print < + +EOF +} + + +sub NavSectionTitle +{ + my($head) = @_; + print < +$head + + +EOF +} + +sub NavSectionStart +{ + my($padding) = @_; + + $padding = 1 if ( !defined($padding) ); + print < +EOF +} + +sub NavSectionEnd +{ + print "\n"; +} + +sub NavLink +{ + my($link, $text) = @_; + print "·"; + if ( defined($link) ) { + $link = "$MyURL$link" if ( $link eq "" || $link =~ /^\?/ ); + print <$text +EOF + } else { + print <$text +EOF + } +} + +sub h1 +{ + my($str) = @_; + return \< + + $str + + +EOF +} + +sub h2 +{ + my($str) = @_; + return \< + + $str + + +EOF +} diff --git a/conf/config.pl b/conf/config.pl index 4bf78d3..6f2ad8c 100644 --- a/conf/config.pl +++ b/conf/config.pl @@ -530,6 +530,14 @@ $Conf{BlackoutHourBegin} = 7.0; $Conf{BlackoutHourEnd} = 19.5; $Conf{BlackoutWeekDays} = [1, 2, 3, 4, 5]; +# +# A backup of a share that has zero files is considered fatal. This is +# used to catch miscellaneous Xfer errors that result in no files being +# backed up. If you have shares that might be empty (and therefore an +# empty backup is valid) you should set this flag to 0. +# +$Conf{BackupZeroFilesIsFatal} = 1; + ########################################################################### # General per-PC configuration settings # (can be overridden in the per-PC config.pl) diff --git a/doc-src/BackupPC.pod b/doc-src/BackupPC.pod index 122ee2a..e8e8c0a 100644 --- a/doc-src/BackupPC.pod +++ b/doc-src/BackupPC.pod @@ -446,12 +446,13 @@ As of June 2003 the latest version is 1.13.25. =item * If you are using rsync to backup linux/unix machines you should have -version 2.5.5 on each client machine. See L. -Use "rsync --version" to check your version. +version 2.5.5 or higher on each client machine. See +L. Use "rsync --version" to check your +version. For BackupPC to use Rsync you will also need to install the perl File::RsyncP module, which is available from -L. Version 0.41 or later is required. +L. Version 0.44 or later is required. =item * @@ -531,7 +532,7 @@ You can run "perldoc Archive::Zip" to see if this module is installed. To use rsync and rsyncd with BackupPC you will need to install File::RsyncP. You can run "perldoc File::RsyncP" to see if this module is installed. File::RsyncP is available from L. -Version 0.41 or later is required. +Version 0.44 or later is required. =back @@ -754,9 +755,9 @@ Here's a simple example of a hosts file: =head2 Step 5: Client Setup -Two methods for getting backup data from a client are -supported: smb and tar. Smb is the preferred method for WinXX clients -and tar is preferred method for linux/unix clients. +Two methods for getting backup data from a client are supported: smb and +tar. Smb is the preferred method for WinXX clients and tar is preferred +method for linux/unix clients. The transfer method is set using the $Conf{XferMethod} configuration setting. If you have a mixed environment (ie: you will use smb for some @@ -779,11 +780,19 @@ The preferred setup for WinXX clients is to set $Conf{XferMethod} to "smb". prepared to run rsync/cygwin on your WinXX client. More information about this will be provided via the FAQ.) -You need to create shares for the data you want to backup. -Open "My Computer", right click on the drive (eg: C), and -select "Sharing..." (or select "Properties" and select the -"Sharing" tab). In this dialog box you can enable sharing, -select the share name and permissions. +If you want to use rsyncd for WinXX clients you can find a pre-packaged +zip file on L. The package is called +cygwin-rsync. It contains rsync.exe, template setup files and the +minimal set of cygwin libraries for everything to run. The README file +contains instructions for running rsync as a service, so it starts +automatically everytime you boot your machine. + +Otherwise, to use SMB, you need to create shares for the data you want +to backup. Open "My Computer", right click on the drive (eg: C), and +select "Sharing..." (or select "Properties" and select the "Sharing" +tab). In this dialog box you can enable sharing, select the share name +and permissions. Many machines will be configured by default to share +the entire C drive as C$ using the administrator password. If this machine uses DHCP you will also need to make sure the NetBios name is set. Go to Control Panel|System|Network Identification diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index 5e1a5de..e3748ad 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001 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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -58,7 +58,7 @@ sub new TopDir => $topDir || '/data/BackupPC', BinDir => $installDir || '/usr/local/BackupPC', LibDir => $installDir || '/usr/local/BackupPC', - Version => '2.1.0_CVS', + Version => '2.0.0', BackupFields => [qw( num type startTime endTime nFiles size nFilesExist sizeExist nFilesNew sizeNew @@ -731,8 +731,8 @@ sub CheckHostAlive # Return success if the ping cmd is undefined or empty. # if ( $bpc->{Conf}{PingCmd} eq "" ) { - print("CheckHostAlive: return ok because \$Conf{PingCmd} is empty\n") - if ( $bpc->{verbose} ); + print(STDERR "CheckHostAlive: return ok because \$Conf{PingCmd}" + . " is empty\n") if ( $bpc->{verbose} ); return 0; } @@ -747,7 +747,7 @@ sub CheckHostAlive # $s = $bpc->cmdSystemOrEval($pingCmd, undef, $args); if ( $? ) { - print("CheckHostAlive: first ping failed ($?, $!)\n") + print(STDERR "CheckHostAlive: first ping failed ($?, $!)\n") if ( $bpc->{verbose} ); return -1; } @@ -757,7 +757,7 @@ sub CheckHostAlive # $s = $bpc->cmdSystemOrEval($pingCmd, undef, $args); if ( $? ) { - print("CheckHostAlive: second ping failed ($?, $!)\n") + print(STDERR "CheckHostAlive: second ping failed ($?, $!)\n") if ( $bpc->{verbose} ); return -1; } @@ -766,11 +766,11 @@ sub CheckHostAlive } elsif ( $s =~ /time=([\d\.]+)\s*usec/i ) { $ret = $1/1000; } else { - print("CheckHostAlive: can't extract round-trip time (not fatal)\n") - if ( $bpc->{verbose} ); + print(STDERR "CheckHostAlive: can't extract round-trip time" + . " (not fatal)\n") if ( $bpc->{verbose} ); $ret = 0; } - print("CheckHostAlive: returning $ret\n") if ( $bpc->{verbose} ); + print(STDERR "CheckHostAlive: returning $ret\n") if ( $bpc->{verbose} ); return $ret; } @@ -805,9 +805,8 @@ sub NetBiosInfoGet # Skip NetBios check if NmbLookupCmd is emtpy # if ( $bpc->{Conf}{NmbLookupCmd} eq "" ) { - print("NetBiosInfoGet: return $host because \$Conf{NmbLookupCmd}" - . " is empty\n") - if ( $bpc->{verbose} ); + print(STDERR "NetBiosInfoGet: return $host because \$Conf{NmbLookupCmd}" + . " is empty\n") if ( $bpc->{verbose} ); return ($host, undef); } @@ -822,15 +821,14 @@ sub NetBiosInfoGet $netBiosUserName = $1 if ( $2 eq "03" ); # user is last 03 } if ( !defined($netBiosHostName) ) { - print("NetBiosInfoGet: failed: can't parse return string\n") + print(STDERR "NetBiosInfoGet: failed: can't parse return string\n") if ( $bpc->{verbose} ); return; } $netBiosHostName = lc($netBiosHostName); $netBiosUserName = lc($netBiosUserName); - print("NetBiosInfoGet: success, returning host $netBiosHostName," - . " user $netBiosUserName\n") - if ( $bpc->{verbose} ); + print(STDERR "NetBiosInfoGet: success, returning host $netBiosHostName," + . " user $netBiosUserName\n") if ( $bpc->{verbose} ); return ($netBiosHostName, $netBiosUserName); } @@ -851,9 +849,9 @@ sub NetBiosHostIPFind # Skip NetBios lookup if NmbLookupFindHostCmd is emtpy # if ( $bpc->{Conf}{NmbLookupFindHostCmd} eq "" ) { - print("NetBiosHostIPFind: return $host because" - . " \$Conf{NmbLookupFindHostCmd} is empty\n") - if ( $bpc->{verbose} ); + print(STDERR "NetBiosHostIPFind: return $host because" + . " \$Conf{NmbLookupFindHostCmd} is empty\n") + if ( $bpc->{verbose} ); return $host; } @@ -875,12 +873,12 @@ sub NetBiosHostIPFind } $ipAddr = $firstIpAddr if ( !defined($ipAddr) ); if ( defined($ipAddr) ) { - print("NetBiosHostIPFind: found IP address $ipAddr for host $host\n") - if ( $bpc->{verbose} ); + print(STDERR "NetBiosHostIPFind: found IP address $ipAddr for" + . " host $host\n") if ( $bpc->{verbose} ); return $ipAddr; } else { - print("NetBiosHostIPFind: couldn't find IP address for host $host\n") - if ( $bpc->{verbose} ); + print(STDERR "NetBiosHostIPFind: couldn't find IP address for" + . " host $host\n") if ( $bpc->{verbose} ); return; } } @@ -1044,16 +1042,16 @@ sub cmdExecOrEval if ( (ref($cmd) eq "ARRAY" ? $cmd->[0] : $cmd) =~ /^\&/ ) { $cmd = join(" ", $cmd) if ( ref($cmd) eq "ARRAY" ); - print("cmdExecOrEval: about to eval perl code $cmd\n") + print(STDERR "cmdExecOrEval: about to eval perl code $cmd\n") if ( $bpc->{verbose} ); eval($cmd); print(STDERR "Perl code fragment for exec shouldn't return!!\n"); exit(1); } else { $cmd = [split(/\s+/, $cmd)] if ( ref($cmd) ne "ARRAY" ); - print("cmdExecOrEval: about to exec ", - $bpc->execCmd2ShellCmd(@$cmd), "\n") - if ( $bpc->{verbose} ); + print(STDERR "cmdExecOrEval: about to exec ", + $bpc->execCmd2ShellCmd(@$cmd), "\n") + if ( $bpc->{verbose} ); exec(map { m/(.*)/ } @$cmd); # untaint print(STDERR "Exec failed for @$cmd\n"); exit(1); @@ -1080,19 +1078,19 @@ sub cmdSystemOrEval if ( (ref($cmd) eq "ARRAY" ? $cmd->[0] : $cmd) =~ /^\&/ ) { $cmd = join(" ", $cmd) if ( ref($cmd) eq "ARRAY" ); - print("cmdSystemOrEval: about to eval perl code $cmd\n") + print(STDERR "cmdSystemOrEval: about to eval perl code $cmd\n") if ( $bpc->{verbose} ); $out = eval($cmd); $$stdoutCB .= $out if ( ref($stdoutCB) eq 'SCALAR' ); &$stdoutCB($out) if ( ref($stdoutCB) eq 'CODE' ); - print("cmdSystemOrEval: finished: got output $out\n") + print(STDERR "cmdSystemOrEval: finished: got output $out\n") if ( $bpc->{verbose} ); return $out if ( !defined($stdoutCB) ); return; } else { $cmd = [split(/\s+/, $cmd)] if ( ref($cmd) ne "ARRAY" ); - print("cmdSystemOrEval: about to system ", - $bpc->execCmd2ShellCmd(@$cmd), "\n") + print(STDERR "cmdSystemOrEval: about to system ", + $bpc->execCmd2ShellCmd(@$cmd), "\n") if ( $bpc->{verbose} ); if ( !defined($pid = open(CHILD, "-|")) ) { my $err = "Can't fork to run @$cmd\n"; @@ -1125,7 +1123,7 @@ sub cmdSystemOrEval $? = 0; close(CHILD); } - print("cmdSystemOrEval: finished: got output $allOut\n") + print(STDERR "cmdSystemOrEval: finished: got output $allOut\n") if ( $bpc->{verbose} ); return $out; } diff --git a/lib/BackupPC/Xfer/Rsync.pm b/lib/BackupPC/Xfer/Rsync.pm index 8f8093b..31feb8c 100644 --- a/lib/BackupPC/Xfer/Rsync.pm +++ b/lib/BackupPC/Xfer/Rsync.pm @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2002-2003 Craig Barratt +# Copyright (C) 2002 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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -52,9 +52,9 @@ BEGIN { $RsyncLibOK = 0; $RsyncLibErr = "File::RsyncP module doesn't exist"; } else { - if ( $File::RsyncP::VERSION < 0.41 ) { + if ( $File::RsyncP::VERSION < 0.44 ) { $RsyncLibOK = 0; - $RsyncLibErr = "File::RsyncP module version too old: need 0.41"; + $RsyncLibErr = "File::RsyncP module version too old: need 0.44"; } else { $RsyncLibOK = 1; } @@ -176,8 +176,17 @@ sub start # To make this easier we do all the includes first and all # of the excludes at the end (hopefully they commute). # + $file =~ s{/$}{}; $file = "/$file"; $file =~ s{//+}{/}g; + if ( $file eq "/" ) { + # + # This is a special case: if the user specifies + # "/" then just include it and don't exclude "/*". + # + push(@inc, $file) if ( !$incDone{$file} ); + next; + } my $f = ""; while ( $file =~ m{^/([^/]*)(.*)} ) { my $elt = $1; diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm index 5e1df82..08d9c6a 100644 --- a/lib/BackupPC/Xfer/Smb.pm +++ b/lib/BackupPC/Xfer/Smb.pm @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001 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 @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.0.0, released 14 Jun 2003. # # See http://backuppc.sourceforge.net. # @@ -121,9 +121,11 @@ sub start }; } } + $t->{fileIncludeHash} = {}; if ( defined($conf->{BackupFilesOnly}{$t->{shareName}}) ) { foreach my $file ( @{$conf->{BackupFilesOnly}{$t->{shareName}}} ) { push(@fileList, $file); + $t->{fileIncludeHash}{$file} = 1; } } elsif ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) { foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} ) @@ -257,8 +259,24 @@ sub readOutput || /^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/ ) { - $t->{hostError} ||= $_; + 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 (.*)/ ) { + my $badDir = $1; + $badDir =~ s{\\}{/}g; + $badDir =~ s{/+}{/}g; + $badDir =~ s{/\*$}{}; + if ( $t->{hostError} eq "" + && ($badDir eq "" || $t->{fileIncludeHash}{$badDir}) ) { + $t->{XferLOG}->write(\"This backup will fail because: $_\n"); + $t->{hostError} ||= $_; + } } elsif ( /smb: \\>/ || /^added interface/i || /^tarmode is now/i @@ -297,7 +315,10 @@ sub readOutput my $badFile = $1; $badFile =~ s{\\}{/}g; $badFile =~ s{^/}{}; - push(@{$t->{badFiles}}, "$t->{shareName}/$badFile"); + push(@{$t->{badFiles}}, { + share => $t->{shareName}, + file => $badFile + }); } } } diff --git a/makeDist b/makeDist index 712ca05..eff0fc4 100755 --- a/makeDist +++ b/makeDist @@ -41,8 +41,8 @@ use File::Copy; umask(0022); -my $Version = "2.1.0_CVS"; -my $ReleaseDate = "3 Jul 2003"; +my $Version = "2.0.1beta0"; +my $ReleaseDate = "26 Jul 2003"; my $DistDir = "dist/BackupPC-$Version"; my @PerlSrc = qw( @@ -62,26 +62,12 @@ my @PerlSrc = qw( lib/BackupPC/Attrib.pm lib/BackupPC/FileZIO.pm lib/BackupPC/Lib.pm - lib/BackupPC/PoolWrite.pm - lib/BackupPC/View.pm - lib/BackupPC/CGI/Browse.pm - lib/BackupPC/CGI/DirHistory.pm - lib/BackupPC/CGI/EmailSummary.pm - lib/BackupPC/CGI/GeneralInfo.pm - lib/BackupPC/CGI/HostInfo.pm - lib/BackupPC/CGI/Lib.pm - lib/BackupPC/CGI/LOGlist.pm - lib/BackupPC/CGI/Queue.pm - lib/BackupPC/CGI/RestoreFile.pm - lib/BackupPC/CGI/RestoreInfo.pm - lib/BackupPC/CGI/Restore.pm - lib/BackupPC/CGI/StartStopBackup.pm - lib/BackupPC/CGI/Summary.pm - lib/BackupPC/CGI/View.pm lib/BackupPC/Lang/de.pm lib/BackupPC/Lang/en.pm lib/BackupPC/Lang/es.pm lib/BackupPC/Lang/fr.pm + lib/BackupPC/PoolWrite.pm + lib/BackupPC/View.pm lib/BackupPC/Xfer/Smb.pm lib/BackupPC/Xfer/Tar.pm lib/BackupPC/Xfer/Rsync.pm @@ -117,12 +103,8 @@ exit(1) if ( $errCnt ); rmtree($DistDir, 0, 0); mkpath($DistDir, 0, 0777); -foreach my $dir ( qw(bin doc conf images init.d/src cgi-bin - lib/BackupPC/CGI - lib/BackupPC/Lang - lib/BackupPC/Xfer - lib/BackupPC/Zip - ) ) { +foreach my $dir ( qw(bin lib/BackupPC/Xfer lib/BackupPC/Zip lib/BackupPC/Lang + doc conf images init.d/src cgi-bin) ) { mkpath("$DistDir/$dir", 0, 0777); } @@ -324,10 +306,7 @@ sub CheckLangUsage my $errors; my $vars = {}; - foreach my $file ( ( - qw(cgi-bin/BackupPC_Admin bin/BackupPC_sendEmail), - - ) ) { + foreach my $file ( qw(cgi-bin/BackupPC_Admin bin/BackupPC_sendEmail) ) { open(F, $file) || die("can't open $file"); binmode(F); while ( ) {