From: Frank Brehm Date: Thu, 20 Sep 2007 16:22:43 +0000 (+0000) Subject: Bugfixing X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=7b2d70d222338312f2a754bf58753d9c92077d5a;p=scripts%2Fsolaris.git Bugfixing --- diff --git a/sicher.pl b/sicher.pl index 2e9d630..578f6b3 100755 --- a/sicher.pl +++ b/sicher.pl @@ -101,6 +101,7 @@ use File::Basename; use File::Spec::Functions; use File::stat; use File::Copy; +use File::Glob ':glob'; use Locale::gettext; use POSIX qw(setlocale LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME); @@ -207,6 +208,7 @@ Verarbeitet rekursiv die uebergebene Datei- und Verzeichnisliste. sub perform_nodes { my $node_list = shift; + my $K = "perform_nodes(): "; my $dir_list = []; my $file_list = []; @@ -236,12 +238,19 @@ sub perform_nodes { sub perform_dirs { my $dir_list = shift; + my $K = "perform_dirs(): "; my ( $sublist, $newlist, $basename ); for my $d ( @$dir_list ) { - _debug( 1, sprintf( $l->get("Backup of directory '%s' ..."), $d ) ); - @$sublist = ( glob( catfile( $d, ".*" ) ), glob( catfile( $d, "*" ) ) ); + _debug( 1, sprintf( $K . $l->get("Backup of directory '%s' ..."), $d ) ); + $d =~ s/\/$// unless $d eq "/"; + my $pattern = catfile( '"' . $d . '"', "{,.}*" ); + $pattern = catfile( $d, "{,.}*" ); + _debug( 2, $K . "Suchpattern: '" . $pattern . "'." ); + #@$sublist = ( glob( $pattern1 ), glob( $pattern2 ) ); + @$sublist = bsd_glob( $pattern, GLOB_TILDE | GLOB_BRACE | GLOB_NOSORT ); + _debug( 2, $K . "Verzeichnisinhalt: " . Dumper($sublist) ); $newlist = []; for ( @$sublist ) { $basename = basename($_); @@ -264,9 +273,10 @@ sub perform_dirs { sub perform_files { my $file_list = shift; + my $K = "perform_files(): "; for my $f ( @$file_list ) { - _debug( 1, sprintf( $l->get("Backup of file '%s' ..."), $f ) ); + _debug( 1, $K . sprintf( $l->get("Backup of file '%s' ..."), $f ) ); return 0 unless backup_file($f); } @@ -283,6 +293,7 @@ sub perform_files { sub backup_file { my $file = shift; + my $K = "backup_file(): "; my $fstat = stat($file) or return 0; my $mtime = [localtime($fstat->mtime)]; @@ -290,7 +301,7 @@ sub backup_file { my $pdir = dirname($file); my $odir = catdir( $pdir, $olddir ); - _debug( 1, sprintf( $l->get("Using Old-Dir '%s'."), $odir ) ); + _debug( 1, sprintf( $K . $l->get("Using Old-Dir '%s'."), $odir ) ); return undef unless create_dir($odir); my $bakfile = catfile( $odir, basename($file) . $datepat ); print " - " . $file . " -> " . $bakfile . "\n"; @@ -300,14 +311,14 @@ sub backup_file { return 0; } - _debug( 2, sprintf( $l->get("Changing timestamp of '%s' ..."), $bakfile ) ); + _debug( 2, sprintf( $K . $l->get("Changing timestamp of '%s' ..."), $bakfile ) ); unless ( utime $fstat->atime, $fstat->mtime, $bakfile ) { _error( undef, sprintf( $l->get("Could not change timestamps of '%s': "), $bakfile ) . $! ); } # wenn root, dann Besitzerschaft der gesicherten Datei uebernehmen unless ( $> ) { - _debug( 2, sprintf( $l->get("Changing ownership of '%s' to '%s:%s' ...\n"), $bakfile, $fstat->uid, $fstat->gid ) ); + _debug( 2, sprintf( $K . $l->get("Changing ownership of '%s' to '%s:%s' ...\n"), $bakfile, $fstat->uid, $fstat->gid ) ); unless ( chown $fstat->uid, $fstat->gid, $bakfile ) { _error( undef, sprintf( $l->get("Could not change owner of '%s' to '%s:%s': "), $bakfile, $fstat->uid, $fstat->gid ) . $! ); }