projects
/
BackupPC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added dvd_nr to archive_backup_parts
[BackupPC.git]
/
lib
/
BackupPC
/
Lib.pm
diff --git
a/lib/BackupPC/Lib.pm
b/lib/BackupPC/Lib.pm
index
8665c29
..
6e1fe8f
100644
(file)
--- a/
lib/BackupPC/Lib.pm
+++ b/
lib/BackupPC/Lib.pm
@@
-11,7
+11,7
@@
# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001-200
7
Craig Barratt
+# Copyright (C) 2001-200
9
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
#
# 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 3.2.0, released 31
Dec 2008
.
+# Version 3.2.0, released 31
Jul 2010
.
#
# See http://backuppc.sourceforge.net.
#
#
# See http://backuppc.sourceforge.net.
#
@@
-96,7
+96,7
@@
sub new
# Whether to use filesystem hierarchy standard for file layout.
# If set, text config files are below /etc/BackupPC.
#
# Whether to use filesystem hierarchy standard for file layout.
# If set, text config files are below /etc/BackupPC.
#
- my $useFHS =
0
;
+ my $useFHS =
1
;
my $paths;
#
my $paths;
#
@@
-105,6
+105,8
@@
sub new
$topDir = '/data/BackupPC' if ( $topDir eq "" );
$installDir = '/usr/local/BackupPC' if ( $installDir eq "" );
$topDir = '/data/BackupPC' if ( $topDir eq "" );
$installDir = '/usr/local/BackupPC' if ( $installDir eq "" );
+ $confDir = '/etc/BackupPC'; # FIXME remove this! XXX
+
#
# Pick some initial defaults. For FHS the only critical
# path is the ConfDir, since we get everything else out
#
# Pick some initial defaults. For FHS the only critical
# path is the ConfDir, since we get everything else out
@@
-364,9
+366,9
@@
sub ConfigRead
# Read host config file
#
if ( $host ne "" ) {
# Read host config file
#
if ( $host ne "" ) {
- ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host);
+ ($mesg, $config) = $bpc->{storage}->ConfigDataRead($host
, $config
);
return $mesg if ( defined($mesg) );
return $mesg if ( defined($mesg) );
- $bpc->{Conf} =
{ %{$bpc->{Conf}}, %$config }
;
+ $bpc->{Conf} =
$config
;
}
#
}
#
@@
-624,7
+626,15
@@
sub RmTreeDefer
my($i, $f);
return if ( !-e $file );
my($i, $f);
return if ( !-e $file );
- mkpath($trashDir, 0, 0777) if ( !-d $trashDir );
+ if ( !-d $trashDir ) {
+ eval { mkpath($trashDir, 0, 0777) };
+ if ( $@ ) {
+ #
+ # There's no good place to send this error - use stderr
+ #
+ print(STDERR "RmTreeDefer: can't create directory $trashDir");
+ }
+ }
for ( $i = 0 ; $i < 1000 ; $i++ ) {
$f = sprintf("%s/%d_%d_%d", $trashDir, time, $$, $i);
next if ( -e $f );
for ( $i = 0 ; $i < 1000 ; $i++ ) {
$f = sprintf("%s/%d_%d_%d", $trashDir, time, $$, $i);
next if ( -e $f );
@@
-903,7
+913,10
@@
sub MakeFileLink
} elsif ( $newFile && -f $name && (stat($name))[3] == 1 ) {
my($newDir);
($newDir = $rawFile) =~ s{(.*)/.*}{$1};
} elsif ( $newFile && -f $name && (stat($name))[3] == 1 ) {
my($newDir);
($newDir = $rawFile) =~ s{(.*)/.*}{$1};
- mkpath($newDir, 0, 0777) if ( !-d $newDir );
+ if ( !-d $newDir ) {
+ eval { mkpath($newDir, 0, 0777) };
+ return -5 if ( $@ );
+ }
return -4 if ( !link($name, $rawFile) );
return 2;
} else {
return -4 if ( !link($name, $rawFile) );
return 2;
} else {
@@
-1035,6
+1048,10
@@
sub NetBiosInfoGet
};
$nmbCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{NmbLookupCmd}, $args);
foreach ( split(/[\n\r]+/, $bpc->cmdSystemOrEval($nmbCmd, undef, $args)) ) {
};
$nmbCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{NmbLookupCmd}, $args);
foreach ( split(/[\n\r]+/, $bpc->cmdSystemOrEval($nmbCmd, undef, $args)) ) {
+ #
+ # skip <GROUP> and other non <ACTIVE> entries
+ #
+ next if ( /<\w{2}> - <GROUP>/i );
next if ( !/^\s*([\w\s-]+?)\s*<(\w{2})\> - .*<ACTIVE>/i );
$netBiosHostName ||= $1 if ( $2 eq "00" ); # host is first 00
$netBiosUserName = $1 if ( $2 eq "03" ); # user is last 03
next if ( !/^\s*([\w\s-]+?)\s*<(\w{2})\> - .*<ACTIVE>/i );
$netBiosHostName ||= $1 if ( $2 eq "00" ); # host is first 00
$netBiosUserName = $1 if ( $2 eq "03" ); # user is last 03
@@
-1218,22
+1235,27
@@
sub cmdVarSubstitute
}
}
#
}
}
#
- # Merge variables into @
tarClientC
md
+ # Merge variables into @
c
md
#
foreach my $arg ( @$template ) {
#
foreach my $arg ( @$template ) {
+ #
+ # Replace $VAR with ${VAR} so that both types of variable
+ # substitution are supported
+ #
+ $arg =~ s[\$(\w+)]{\${$1}}g;
#
# Replace scalar variables first
#
#
# Replace scalar variables first
#
- $arg =~ s
{\$(\w+)(\+?)}
{
+ $arg =~ s
[\${(\w+)}(\+?)]
{
exists($vars->{$1}) && ref($vars->{$1}) ne "ARRAY"
? ($2 eq "+" ? $bpc->shellEscape($vars->{$1}) : $vars->{$1})
exists($vars->{$1}) && ref($vars->{$1}) ne "ARRAY"
? ($2 eq "+" ? $bpc->shellEscape($vars->{$1}) : $vars->{$1})
- : "\$
$1
$2"
+ : "\$
{$1}
$2"
}eg;
#
# Now replicate any array arguments; this just works for just one
# array var in each argument.
#
}eg;
#
# Now replicate any array arguments; this just works for just one
# array var in each argument.
#
- if ( $arg =~ m
{(.*)\$(\w+)(\+?)(.*)}
&& ref($vars->{$2}) eq "ARRAY" ) {
+ if ( $arg =~ m
[(.*)\${(\w+)}(\+?)(.*)]
&& ref($vars->{$2}) eq "ARRAY" ) {
my $pre = $1;
my $var = $2;
my $esc = $3;
my $pre = $1;
my $var = $2;
my $esc = $3;