From 66d662b5a21271649aad1562bd931beab0c0deb3 Mon Sep 17 00:00:00 2001 From: cbarratt Date: Sun, 4 Jun 2006 17:10:17 +0000 Subject: [PATCH] - added utf8 to output filter and added encoding of file names so they are rendered correctly. - added Wander Winkelhorst's nl.pm patch - added BackupPCd config variables to Meta.pm and EditConfig.pm - added checking of Meta.pm and EditConfig.pm config variable list to makeDist - couple of minor language tweaks --- ChangeLog | 9 ++++- configure.pl | 2 +- lib/BackupPC/CGI/Browse.pm | 4 ++ lib/BackupPC/CGI/EditConfig.pm | 13 +++++++ lib/BackupPC/CGI/Lib.pm | 1 + lib/BackupPC/CGI/Restore.pm | 6 +++ lib/BackupPC/CGI/RestoreInfo.pm | 5 +++ lib/BackupPC/CGI/View.pm | 2 + lib/BackupPC/Config/Meta.pm | 6 +++ lib/BackupPC/FileZIO.pm | 16 +++++++- lib/BackupPC/Lang/de.pm | 1 + lib/BackupPC/Lang/en.pm | 1 + lib/BackupPC/Lang/es.pm | 1 + lib/BackupPC/Lang/fr.pm | 5 ++- lib/BackupPC/Lang/it.pm | 1 + lib/BackupPC/Lang/nl.pm | 9 +++-- lib/BackupPC/Lang/pt_br.pm | 1 + makeDist | 66 +++++++++++++++++++++++++++++++++ makePatch | 4 +- 19 files changed, 141 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index da111fc..f8725f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,11 +21,12 @@ # Version __VERSION__, __RELEASEDATE__ #------------------------------------------------------------------------ -* Added config file editing. +* Added config and host CGI editor. * Added rsync hardlink support. -* Added Portuguese Brazillian pt_br.pm from Reginaldo Ferreira. +* Server file names are now in utf8 and optional conversion + to/from client name charsets is done. * Added Slackware init.d script from Tony Nelson. @@ -37,10 +38,14 @@ * Apply patch from Pete Wenzel to add smbClientPath => $Conf{SmbClientPath} to DumpPreUserCmd etc. +* Added Portuguese Brazillian pt_br.pm from Reginaldo Ferreira. + * Jean-Michel Beuken reported several bugs in CVS 3.0.0. * Applied Lorenzo Cappelletti's it.pm patch. +* Applied Wander Winkelhorst's nl.pm patch. + * Applied patch to bin/BackupPC_sendEmail from Marc Prewitt that ignores any file starting with "." in the pc directory when it is generating warnings about old/unused files/directories. diff --git a/configure.pl b/configure.pl index d592b8f..784f944 100755 --- a/configure.pl +++ b/configure.pl @@ -1195,7 +1195,7 @@ Craig Barratt =head1 COPYRIGHT -Copyright (C) 2001-2004 Craig Barratt. +Copyright (C) 2001-2006 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 diff --git a/lib/BackupPC/CGI/Browse.pm b/lib/BackupPC/CGI/Browse.pm index 7f89270..c16307a 100644 --- a/lib/BackupPC/CGI/Browse.pm +++ b/lib/BackupPC/CGI/Browse.pm @@ -37,6 +37,7 @@ package BackupPC::CGI::Browse; use strict; +use Encode; use BackupPC::CGI::Lib qw(:all); use BackupPC::View; use BackupPC::Attrib qw(:all); @@ -156,6 +157,7 @@ sub action } my $dirName = $f; $dirName =~ s/ / /g; + $dirName = decode_utf8($dirName); push(@DirStr, {needTick => 1, tdArgs => " class=\"$tdStyle\"", link => < \n"; } (my $fDisp = "${EscHTML($f)}") =~ s/ / /g; + $fDisp = decode_utf8($fDisp); if ( $gotDir ) { $fileStr .= < @@ -255,6 +258,7 @@ EOF $dirDisplay =~ s{//+}{/}g; $dirDisplay =~ s{/+$}{}g; $dirDisplay = "/" if ( $dirDisplay eq "" ); + $dirDisplay = decode_utf8($dirDisplay); my $filledBackup; if ( (my @mergeNums = @{$view->mergeNums}) > 1 ) { diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index 11ac989..c0c327d 100644 --- a/lib/BackupPC/CGI/EditConfig.pm +++ b/lib/BackupPC/CGI/EditConfig.pm @@ -181,6 +181,8 @@ our %ConfigMenu = ( visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } }, {name => "RsyncShareName", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, + {name => "RsyncdUserName", + visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } }, {name => "RsyncdPasswd", visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } }, {name => "RsyncdAuthRequired", @@ -188,6 +190,17 @@ our %ConfigMenu = ( {name => "RsyncCsumCacheVerifyProb", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, + {text => "CfgEdit_Title_BackupPCd_Settings", + visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + {name => "BackupPCdShareName", + visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + {name => "BackupPCdPath", + visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + {name => "BackupPCdCmd", + visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + {name => "BackupPCdRestoreCmd", + visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + {text => "CfgEdit_Title_Archive_Settings", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveDest", diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index 3c7c9bd..d6dc53f 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -431,6 +431,7 @@ sub Header ); my $host = $In{host}; + binmode(STDOUT, ":utf8"); print $Cgi->header(-charset => "utf-8"); print < diff --git a/lib/BackupPC/CGI/Restore.pm b/lib/BackupPC/CGI/Restore.pm index e494ace..9c6a66b 100644 --- a/lib/BackupPC/CGI/Restore.pm +++ b/lib/BackupPC/CGI/Restore.pm @@ -40,6 +40,7 @@ use strict; use BackupPC::CGI::Lib qw(:all); use Data::Dumper; use File::Path; +use Encode; sub action { @@ -73,6 +74,7 @@ sub action $hiddenStr .= < EOF + $name = decode_utf8($name); $fileListStr .= < ${EscHTML($name)} EOF @@ -261,6 +263,10 @@ EOF (my $strippedShareDest = $In{shareDest}) =~ s/^\///; substr($targetFile, 0, length($pathHdr)) = "/$In{pathHdr}/"; $targetFile =~ s{//+}{/}g; + $strippedShareDest = decode_utf8($strippedShareDest); + $targetFile = decode_utf8($targetFile); + $strippedShare = decode_utf8($strippedShare); + $f = decode_utf8($f); $fileListStr .= <$host:/$strippedShare$f$In{hostDest}:/$strippedShareDest$targetFile EOF diff --git a/lib/BackupPC/CGI/RestoreInfo.pm b/lib/BackupPC/CGI/RestoreInfo.pm index d190750..587cf4e 100644 --- a/lib/BackupPC/CGI/RestoreInfo.pm +++ b/lib/BackupPC/CGI/RestoreInfo.pm @@ -38,6 +38,7 @@ package BackupPC::CGI::RestoreInfo; use strict; use BackupPC::CGI::Lib qw(:all); +use Encode; sub action { @@ -80,6 +81,10 @@ sub action substr($targetFile, 0, length($RestoreReq{pathHdrSrc})) = $RestoreReq{pathHdrDest}; $targetFile =~ s{//+}{/}g; + $strippedShareDest = decode_utf8($strippedShareDest); + $targetFile = decode_utf8($targetFile); + $strippedShareSrc = decode_utf8($strippedShareSrc); + $f = decode_utf8($f); $fileListStr .= <$RestoreReq{hostSrc}:/$strippedShareSrc$f$RestoreReq{hostDest}:/$strippedShareDest$targetFile EOF diff --git a/lib/BackupPC/CGI/View.pm b/lib/BackupPC/CGI/View.pm index 5efa6a2..ae03ba4 100644 --- a/lib/BackupPC/CGI/View.pm +++ b/lib/BackupPC/CGI/View.pm @@ -107,6 +107,8 @@ sub action my($contentPre, $contentSub, $contentPost); $contentPre .= eval("qq{$Lang->{Log_File__file__comment}}"); if ( defined($fh = BackupPC::FileZIO->open($file, 0, $compress)) ) { + + $fh->utf8(1); my $mtimeStr = $bpc->timeStamp((stat($file))[9], 1); $contentPre .= eval("qq{$Lang->{Contents_of_log_file}}"); diff --git a/lib/BackupPC/Config/Meta.pm b/lib/BackupPC/Config/Meta.pm index 280b67e..c7258f1 100644 --- a/lib/BackupPC/Config/Meta.pm +++ b/lib/BackupPC/Config/Meta.pm @@ -225,6 +225,7 @@ use vars qw(%ConfigMeta); RsyncClientRestoreCmd => "string", RsyncdClientPort => "integer", + RsyncdUserName => "string", RsyncdPasswd => "string", RsyncdAuthRequired => "boolean", @@ -240,6 +241,11 @@ use vars qw(%ConfigMeta); child => "string", }, + BackupPCdCmd => "string", + BackupPCdPath => "string", + BackupPCdShareName => "string", + BackupPCdRestoreCmd => "string", + ArchiveDest => "string", ArchiveComp => { type => "select", diff --git a/lib/BackupPC/FileZIO.pm b/lib/BackupPC/FileZIO.pm index 0b23873..d920675 100644 --- a/lib/BackupPC/FileZIO.pm +++ b/lib/BackupPC/FileZIO.pm @@ -43,6 +43,7 @@ use vars qw( $CompZlibOK ); use Carp; use File::Path; use File::Copy; +use Encode; # # For compressed files we have a to careful about running out of memory @@ -126,6 +127,16 @@ sub compOk return $CompZlibOK; } +# +# Request utf8 strings with readLine interface +# +sub utf8 +{ + my($self, $mode) = @_; + + $self->{utf8} = $mode; +} + sub myDeflateInit { my $self = shift; @@ -226,6 +237,7 @@ sub readLine if ( $str eq "" ) { $str = $self->{readLineFrag}; $self->{readLineFrag} = ""; + $str = decode_utf8($str) if ( $self->{utf8} ); return $str; } @{$self->{readLineBuf}} = split(/\n/, $self->{readLineFrag} . $str); @@ -235,7 +247,9 @@ sub readLine $self->{readLineFrag} = ""; } } - return shift(@{$self->{readLineBuf}}) . "\n"; + $str = shift(@{$self->{readLineBuf}}) . "\n"; + $str = decode_utf8($str) if ( $self->{utf8} ); + return $str; } sub rewind diff --git a/lib/BackupPC/Lang/de.pm b/lib/BackupPC/Lang/de.pm index c7ff0cd..f65da0b 100644 --- a/lib/BackupPC/Lang/de.pm +++ b/lib/BackupPC/Lang/de.pm @@ -1344,6 +1344,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/en.pm b/lib/BackupPC/Lang/en.pm index 8d6d123..359dcb1 100644 --- a/lib/BackupPC/Lang/en.pm +++ b/lib/BackupPC/Lang/en.pm @@ -1335,6 +1335,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/es.pm b/lib/BackupPC/Lang/es.pm index 4d53312..a7b0c2b 100644 --- a/lib/BackupPC/Lang/es.pm +++ b/lib/BackupPC/Lang/es.pm @@ -1340,6 +1340,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/fr.pm b/lib/BackupPC/Lang/fr.pm index 5f0c6c2..25b338e 100644 --- a/lib/BackupPC/Lang/fr.pm +++ b/lib/BackupPC/Lang/fr.pm @@ -664,7 +664,7 @@ Les fichiers existants sont ceux qui sont d Les nouveaux fichiers sont ceux qui ont été ajoutés au serveur. Les fichiers vides et les erreurs de SMB ne sont pas comptabilisés dans les fichiers nouveaux ou réutilisés.

- +
@@ -1009,7 +1009,7 @@ $Lang{LOG_files} = "Fichiers journaux"; $Lang{Old_LOGs} = "Vieux journaux"; $Lang{Email_summary} = "Résumé des courriels"; $Lang{Config_file} = "Fichier de configuration"; -$Lang{Hosts_file} = "Fichiers des hôtes"; +# $Lang{Hosts_file} = "Fichiers des hôtes"; $Lang{Current_queues} = "Files actuelles"; $Lang{Documentation} = "Documentation"; @@ -1336,6 +1336,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/it.pm b/lib/BackupPC/Lang/it.pm index 4d30823..3631c1e 100644 --- a/lib/BackupPC/Lang/it.pm +++ b/lib/BackupPC/Lang/it.pm @@ -1347,6 +1347,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/nl.pm b/lib/BackupPC/Lang/nl.pm index 3c6f30e..0e67842 100644 --- a/lib/BackupPC/Lang/nl.pm +++ b/lib/BackupPC/Lang/nl.pm @@ -1253,8 +1253,8 @@ $headers Beste $userName, Er is reeds gedurende $days dagen geen backup meer gemaakt van uw pc ($host). -Er zijn ondertussen van uw pc $numbackups gemaakt sinds $firstTime. -De laatste backup dateert van $days geleden. +Er zijn ondertussen van uw pc $numBackups backups gemaakt sinds $firstTime dagen geleden. +De laatste backup dateert van $days dagen geleden. PC backups zouden automatisch moeten gebeuren als uw pc verbonden is met het netwerk. @@ -1264,8 +1264,8 @@ contact opnemen van uw systeembeheerder. Vraag hem of haar om uit te zoeken waarom er geen backups meer genomen worden van uw pc. Anderzijds, als deze pc of notebook zich momenteel niet in het netwerk -bevindt dan kan u hieraan weinig doen behalve van belangrijke bestanden -handmatig een copy nemen op een ander medium (CD,diskette, tape,andere pc,...) +bevindt dan kan u hieraan weinig anders doen behalve van belangrijke bestanden +handmatig een kopie te maken op een ander medium (CD, diskette, tape, andere pc,...) U dient te weten dat *geen enkel bestand* dat u aanmaakte of wijzigde in de laatste $days dagen teruggeplaatst zal kunnen worden in geval de harde schijf van uw pc zou crashen. Hierin zijn nieuwe e-mail en bijlagen inbegrepen. @@ -1349,6 +1349,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/lib/BackupPC/Lang/pt_br.pm b/lib/BackupPC/Lang/pt_br.pm index 2fbf854..50b34b9 100644 --- a/lib/BackupPC/Lang/pt_br.pm +++ b/lib/BackupPC/Lang/pt_br.pm @@ -1339,6 +1339,7 @@ $Lang{CfgEdit_Title_Smb_Settings} = "Smb Settings"; $Lang{CfgEdit_Title_Tar_Settings} = "Tar Settings"; $Lang{CfgEdit_Title_Rsync_Settings} = "Rsync Settings"; $Lang{CfgEdit_Title_Rsyncd_Settings} = "Rsyncd Settings"; +$Lang{CfgEdit_Title_BackupPCd_Settings} = "BackupPCd Settings"; $Lang{CfgEdit_Title_Archive_Settings} = "Archive Settings"; $Lang{CfgEdit_Title_Include_Exclude} = "Include/Exclude"; $Lang{CfgEdit_Title_Smb_Paths_Commands} = "Smb Paths/Commands"; diff --git a/makeDist b/makeDist index a0e454f..af1092a 100755 --- a/makeDist +++ b/makeDist @@ -133,6 +133,10 @@ $errCnt += CheckConfigParams("conf/config.pl", $ConfVars, 0); $errCnt += CheckConfigParams("doc-src/BackupPC.pod", $ConfVars, 1); +$errCnt += CheckMetaDataVsConfig($ConfVars, "lib/BackupPC/Config/Meta.pm"); + +$errCnt += CheckEditorVsConfig($ConfVars, "lib/BackupPC/CGI/EditConfig.pm"); + # # These config parameters are not used in the code, so ignore them. # @@ -402,6 +406,68 @@ sub CheckConfigParams return $errors; } +sub CheckMetaDataVsConfig +{ + my($confVars, $file) = @_; + my $done = {}; + my $errors; + + # + # Check that the meta file mentions all the config + # parameters + # + open(F, $file) || die("can't open $file"); + + while ( ) { + next if ( !/^\s{4}(\w+)\s+=>/ ); + if ( $confVars->{$1} ) { + $done->{$1} = 1; + next; + } + next if ( $1 eq "Hosts" ); + print("$file has $1 but missing from conf/config.pl\n"); + $errors++; + } + close(F); + foreach my $v ( keys(%$confVars) ) { + next if ( $done->{$v} ); + print("$file missing $v from conf/config.pl\n"); + $errors++; + } + return $errors; +} + +sub CheckEditorVsConfig +{ + my($confVars, $file) = @_; + my $done = {}; + my $errors; + + # + # Check that the config editor file mentions all the config + # parameters + # + open(F, $file) || die("can't open $file"); + + while ( ) { + next if ( !/name\s*=>\s*"(\w+)"/ ); + if ( $confVars->{$1} ) { + $done->{$1} = 1; + next; + } + next if ( $1 eq "Hosts" ); + print("$file has $1 but missing from conf/config.pl\n"); + $errors++; + } + close(F); + foreach my $v ( keys(%$confVars) ) { + next if ( $done->{$v} ); + print("$file missing $v from conf/config.pl\n"); + $errors++; + } + return $errors; +} + # # Make sure that every lang variable in cgi-bin/BackupPC_Admin matches # the strings in each lib/BackupPC/Lang/*.pm file. This makes sure diff --git a/makePatch b/makePatch index 4743f0a..a7681f5 100755 --- a/makePatch +++ b/makePatch @@ -8,7 +8,7 @@ use strict; use File::Find; use File::Path; -my $BaseVersion = "2.1.0beta2"; +my $BaseVersion = "2.1.2"; my $PatchLevel = "pl1"; my $PatchVersion = "$BaseVersion$PatchLevel"; @@ -74,7 +74,7 @@ sub CopyFile open(OUT, ">", "$TmpDir/$file") || die("Can't open $TmpDir/$file for output\n"); while ( ) { - if ( /^use lib ".*BackupPC\/lib";/ + if ( /^use lib ".*BackupPC[\d.]*\/lib";/ || /^use lib "\/home\/pcbackup\/install\/lib";/ ) { print OUT "use lib \"__INSTALLDIR__/lib\";\n"; } elsif ( $file =~ /Lib.pm/ && /(.*TopDir *=> .*)'.*',/ ) { -- 2.20.1
Totaux Fichiers existants