From e4bf7ab080e172b74b3d64c196a72d0ff5d315c5 Mon Sep 17 00:00:00 2001 From: cbarratt Date: Mon, 22 Jan 2007 07:46:56 +0000 Subject: [PATCH] * BackupPC_Admin now uses $Conf{UmaskMode}, so config.pl files written by the editor have more restrictive permissions. Reported by Tim Massey. * Host summary now shows active backups on disabled hosts, from Jono Woodhouse. * Fixed host LOG link and LOG list order, reported by Tim Massey. * Moved Encode.pm version check to start of configure.pl so it produces a useful error message if Encode.pm is too old. * Fixed hrefs to configuration documentation to handle changes in the way perl generates the anchors. Reported by Philip Gleghorn. * Host name links in LOG files now allow "." in the host name. Reported by Jean-Michel Beuken. * Fixes to lib/BackupPC/Xfer/Tar.pm for tar 1.16: allow 1 (ie: 256) as a successful exit status and match "Total bytes read" message for restores. First reported by Torsten Sadowski and debugged by Ralf Gross and Holger Parplies. --- ChangeLog | 29 +++++++++++++++++++++++++++++ conf/config.pl | 6 ++++-- configure.pl | 20 +++++++++++--------- doc-src/BackupPC.pod | 2 +- lib/BackupPC/CGI/Browse.pm | 4 ++-- lib/BackupPC/CGI/EditConfig.pm | 4 ++-- lib/BackupPC/CGI/Lib.pm | 4 +++- lib/BackupPC/CGI/Summary.pm | 14 ++++++++++---- lib/BackupPC/CGI/View.pm | 7 ++++--- lib/BackupPC/Config/Meta.pm | 2 ++ lib/BackupPC/Lib.pm | 11 +++++++---- lib/BackupPC/Xfer/Tar.pm | 11 ++++++++--- makeDist | 25 +++++++------------------ 13 files changed, 90 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09c29ef..584231d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,35 @@ # Version __VERSION__, __RELEASEDATE__ #------------------------------------------------------------------------ +* BackupPC_Admin now uses $Conf{UmaskMode}, so config.pl files + written by the editor have more restrictive permissions. + Reported by Tim Massey. + +* Host summary now shows active backups on disabled hosts, + from Jono Woodhouse. + +* Fixed host LOG link and LOG list order, reported by Tim Massey. + +* Moved Encode.pm version check to start of configure.pl so it + produces a useful error message if Encode.pm is too old. + +* Fixed hrefs to configuration documentation to handle changes + in the way perl generates the anchors. Reported by Philip + Gleghorn. + +* Host name links in LOG files now allow "." in the host name. + Reported by Jean-Michel Beuken. + +* Fixes to lib/BackupPC/Xfer/Tar.pm for tar 1.16: allow 1 + (ie: 256) as a successful exit status and match "Total + bytes read" message for restores. First reported by + Torsten Sadowski and debugged by Ralf Gross and Holger + Parplies. + +#------------------------------------------------------------------------ +# Version 3.0.0beta3, 3 Dec 2006 +#------------------------------------------------------------------------ + * Removed default paths from conf/config.pl so configure.pl will determine the correct ones at install time. Avoids problem of the config editor complaining about bad executable paths the diff --git a/conf/config.pl b/conf/config.pl index 9d0c276..9310157 100644 --- a/conf/config.pl +++ b/conf/config.pl @@ -647,7 +647,7 @@ $Conf{ArchiveInfoKeepCnt} = 10; # the setting is assumed to apply all shares. # # If a hash is used, a special key "*" means it applies to all -# shares. +# shares that don't have a specific entry. # # Examples: # $Conf{BackupFilesOnly} = '/myFiles'; @@ -697,7 +697,7 @@ $Conf{BackupFilesOnly} = undef; # followed by "/*", eg: "/proc/*", instead of just "/proc". # # If a hash is used, a special key "*" means it applies to all -# shares. +# shares that don't have a specific entry. # # Examples: # $Conf{BackupFilesExclude} = '/temp'; @@ -2048,6 +2048,7 @@ $Conf{CgiUserConfigEdit} = { TarIncrArgs => 1, TarClientCmd => 0, TarClientRestoreCmd => 0, + TarClientPath => 0, RsyncShareName => 1, RsyncdClientPort => 1, RsyncdPasswd => 1, @@ -2057,6 +2058,7 @@ $Conf{CgiUserConfigEdit} = { RsyncRestoreArgs => 1, RsyncClientCmd => 0, RsyncClientRestoreCmd => 0, + RsyncClientPath => 0, ArchiveDest => 1, ArchiveComp => 1, ArchivePar => 1, diff --git a/configure.pl b/configure.pl index 03317be..e92963a 100755 --- a/configure.pl +++ b/configure.pl @@ -47,9 +47,18 @@ use strict; no utf8; use vars qw(%Conf %OrigConf); use lib "./lib"; +use Encode; + +my $EncodeVersion = eval($Encode::VERSION); +if ( $EncodeVersion < 1.99 ) { + print("Error: you need to upgrade perl's Encode package.\n" + . "I found $EncodeVersion and BackupPC needs >= 1.99\n" + . "Please go to www.cpan.org or use the cpan command.\n"); + exit(1); +} my @Packages = qw(File::Path File::Spec File::Copy DirHandle Digest::MD5 - Data::Dumper Getopt::Std Getopt::Long Encode Pod::Usage + Data::Dumper Getopt::Std Getopt::Long Pod::Usage BackupPC::Lib BackupPC::FileZIO); foreach my $pkg ( @Packages ) { @@ -78,13 +87,6 @@ before installing BackupPC. EOF } -my $EncodeVersion = eval($Encode::VERSION); -if ( $EncodeVersion < 1.99 ) { - print("\nError: you need to upgrade the Encode package;" - . " I found $EncodeVersion and BackupPC needs >= 1.99\n\n"); - exit(1); -} - my %opts; $opts{"set-perms"} = 1; if ( !GetOptions( @@ -1180,7 +1182,7 @@ final locations. Use locations specified by the Filesystem Hierarchy Standard for installing BackupPC. This is enabled by default for new -installatios. To use the pre-3.0 installation locations, +installations. To use the pre-3.0 installation locations, specify --no-fhs. =item B<--help|?> diff --git a/doc-src/BackupPC.pod b/doc-src/BackupPC.pod index 741596d..849bfaf 100644 --- a/doc-src/BackupPC.pod +++ b/doc-src/BackupPC.pod @@ -406,7 +406,7 @@ 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.70 or later is required. +Version 0.68 or later is required. =item * diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm index d9f4b8a..f02386c 100644 --- a/lib/BackupPC/CGI/Browse.pm +++ b/lib/BackupPC/CGI/Browse.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -65,7 +65,7 @@ sub action # # default to the newest backup # - if ( !defined($In{num}) && defined(@Backups) ) { + if ( !defined($In{num}) && defined(@Backups) && @Backups > 0 ) { $i = @Backups - 1; $num = $Backups[$i]{num}; } diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index 351f429..964374c 100644 --- a/lib/BackupPC/CGI/EditConfig.pm +++ b/lib/BackupPC/CGI/EditConfig.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 18 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -986,7 +986,7 @@ sub fieldEditBuild if ( $level == 0 ) { my $lcVarName = lc($varName); $content .= <$varName +$varName EOF if ( defined($overrideVar) ) { my $override_checked = ""; diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index fe0aabe..b56fa63 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -102,11 +102,13 @@ sub NewRequest %Conf = $bpc->Conf(); $Lang = $bpc->Lang(); $ConfigMTime = $bpc->ConfigMTime(); + umask($Conf{UmaskMode}); } elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { $bpc->ConfigRead(); %Conf = $bpc->Conf(); $Lang = $bpc->Lang(); $ConfigMTime = $bpc->ConfigMTime(); + umask($Conf{UmaskMode}); } # diff --git a/lib/BackupPC/CGI/Summary.pm b/lib/BackupPC/CGI/Summary.pm index 725e850..436cadf 100644 --- a/lib/BackupPC/CGI/Summary.pm +++ b/lib/BackupPC/CGI/Summary.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -109,9 +109,15 @@ sub action $reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}} || $Conf{CgiStatusHilightColor}{$Status{$host}{state}}; if ( $Conf{BackupsDisable} == 1 ) { - $reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_OnlyManualBackups}; - $tempState = "Disabled_OnlyManualBackups"; - $tempReason = ""; + if ( $Status{$host}{state} ne "Status_backup_in_progress" + && $Status{$host}{state} ne "Status_restore_in_progress" ) { + $reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_OnlyManualBackups}; + $tempState = "Disabled_OnlyManualBackups"; + $tempReason = ""; + } else { + $tempState = $Status{$host}{state}; + $tempReason = $Status{$host}{reason}; + } } elsif ($Conf{BackupsDisable} == 2 ) { $reasonHilite = $Conf{CgiStatusHilightColor}{Disabled_AllBackupsDisabled}; $tempState = "Disabled_AllBackupsDisabled"; diff --git a/lib/BackupPC/CGI/View.pm b/lib/BackupPC/CGI/View.pm index 335fde4..2ce291e 100644 --- a/lib/BackupPC/CGI/View.pm +++ b/lib/BackupPC/CGI/View.pm @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -91,6 +91,7 @@ sub action if ( !defined($In{num}) ) { # get the latest LOG file $file = ($bpc->sortedPCLogFiles($host))[0]; + $file =~ s/\.z$//; } else { $file = "$TopDir/pc/$host/LOG$ext"; } @@ -173,7 +174,7 @@ sub action last if ( $s eq "" ); $s =~ s/[\n\r]+//g; $s = ${EscHTML($s)}; - $s =~ s/\b([\w-]+)\b/defined($Hosts->{$1}) + $s =~ s/\b([\w-.]+)\b/defined($Hosts->{$1}) ? ${HostLink($1)} : $1/eg; $c .= $s . "\n"; } @@ -199,7 +200,7 @@ sub action $s =~ s[(\$Conf\{.*?\})][ my $c = $1; my $s = lc($c); - $s =~ s{(\W)}{sprintf("%%%02x", ord($1) )}gxe; + $s =~ s{(\W)}{_}g; "$c" ]eg; $c .= $s . "\n"; diff --git a/lib/BackupPC/Config/Meta.pm b/lib/BackupPC/Config/Meta.pm index c33a443..e005d0e 100644 --- a/lib/BackupPC/Config/Meta.pm +++ b/lib/BackupPC/Config/Meta.pm @@ -392,6 +392,7 @@ use vars qw(%ConfigMeta); TarFullArgs => "boolean", TarIncrArgs => "boolean", TarClientCmd => "boolean", + TarClientPath => "boolean", TarClientRestoreCmd => "boolean", RsyncShareName => "boolean", RsyncdClientPort => "boolean", @@ -401,6 +402,7 @@ use vars qw(%ConfigMeta); RsyncArgs => "boolean", RsyncRestoreArgs => "boolean", RsyncClientCmd => "boolean", + RsyncClientPath => "boolean", RsyncClientRestoreCmd => "boolean", ArchiveDest => "boolean", ArchiveComp => "boolean", diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index 86a3b3f..faa66b1 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -94,7 +94,7 @@ sub new my $bpc = bless { %$paths, - Version => '3.0.0beta2', + Version => '3.0.0beta3', }, $class; $bpc->{storage} = BackupPC::Storage->new($paths); @@ -1237,9 +1237,12 @@ sub compareLOGName if ( length($na) >= 5 && length($nb) >= 5 ) { # - # Both new style. Bigger numbers are more recent. + # Both new style: format is MMYYYY. Bigger dates are + # more recent. # - return $nb - $na; + my $ma = $2 * 12 + $1 if ( $na =~ /(\d+)(\d{4})/ ); + my $mb = $2 * 12 + $1 if ( $nb =~ /(\d+)(\d{4})/ ); + return $mb - $ma; } elsif ( length($na) >= 5 && length($nb) < 5 ) { return -1; } elsif ( length($na) < 5 && length($nb) >= 5 ) { diff --git a/lib/BackupPC/Xfer/Tar.pm b/lib/BackupPC/Xfer/Tar.pm index 856d1b7..8cc2c0f 100644 --- a/lib/BackupPC/Xfer/Tar.pm +++ b/lib/BackupPC/Xfer/Tar.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.0.0beta3, released 3 Dec 2006. # # See http://backuppc.sourceforge.net. # @@ -210,7 +210,12 @@ sub readOutput my $mesg; if ( sysread($t->{pipeTar}, $mesg, 8192) <= 0 ) { vec($$FDreadRef, fileno($t->{pipeTar}), 1) = 0; - if ( !close($t->{pipeTar}) ) { + if ( !close($t->{pipeTar}) && $? != 256 ) { + # + # Tar 1.16 uses exit status 1 (256) when some files + # changed during archive creation. We allow this + # as a benign error and consider the archive ok + # $t->{tarOut} .= "Tar exited with error $? ($!) status\n"; $t->{xferOK} = 0 if ( !$t->{tarBadExitOk} ); } @@ -229,7 +234,7 @@ sub readOutput # alarm($conf->{ClientTimeout}) if ( !$t->{abort} ); $t->{lastOutputLine} = $_ if ( !/^$/ ); - if ( /^Total bytes written: / ) { + if ( /^Total bytes (written|read): / ) { $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 ); $t->{xferOK} = 1; } elsif ( /^\./ ) { diff --git a/makeDist b/makeDist index b8f4361..ec18f44 100755 --- a/makeDist +++ b/makeDist @@ -53,8 +53,8 @@ die("BackupPC::Lib->new failed\n") umask(0022); -my $Version = "3.0.0beta3"; -my $ReleaseDate = "3 Dec 2006"; +my $Version = "3.0.0"; +my $ReleaseDate = "21 Jan 2007"; my $DistDir = "dist/BackupPC-$Version"; my @PerlSrc = qw( @@ -270,24 +270,15 @@ sub InstallFile s/__RELEASEDATE__/$ReleaseDate/g; if ( $file =~ /BackupPC\.html$/ ) { # - # fixup for perl 5.6.x + # fixup for conf links # - if ( !/A NAME="item_(%|_)24Conf/i ) { + if ( !/A NAME="item_(%|_)conf/i ) { s/\$Conf{([^}]*)}/ defined($ConfName{$1}) - ? "\L\E\$Conf{$1}<\/A>" + ? "\L\E\$Conf{$1}<\/A>" : "\$Conf{$1}"/eg; } - s/<(A NAME="item_(%|_)24Conf(%|_)7B(.*?)(%|_)7D).*?">/\L/ig; s/^
/

/; - # - # Fixup for perl 5.8.x first one no longer needed after - # fix in CSS) - # -# if ( /^<\/dt>/ ) { -# $_ .= ; -# s/^(<\/dt>\n

)/$1

/s; -# } s/^

  • <\/li>/
  • /; } if ( /__CONFIGPOD__/ ) { @@ -356,10 +347,8 @@ sub config2pod s/([^;])\s*$/$1 .../; } push(@conf, $_); - my $text = "\$Conf{$var}"; - $text =~ s/\s+/_/sg; - $text =~ s{(\W)}{sprintf("%%%02X", ord($1) )}gxe; - $text = substr($text, 0, 50); + my $text = "_conf_${var}_"; + $text =~ s{[\W\s]}{_}g; $ConfName{$var} = "item_$text"; } elsif ( /^$/ ) { if ( $str ne "" && @conf ) { -- 2.20.1