X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FLib.pm;h=cb66a106ff6900381a961c9ac486a30c3f8fb0ae;hp=7e63431063c33abe90d6c95068bf312d614f7185;hb=ca593f66fd6c35764bd8997c6338b781330f019c;hpb=3d15da9b2c6de8018c02677549678d6d769234b5 diff --git a/lib/BackupPC/Lib.pm b/lib/BackupPC/Lib.pm index 7e63431..cb66a10 100644 --- a/lib/BackupPC/Lib.pm +++ b/lib/BackupPC/Lib.pm @@ -11,7 +11,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2007 Craig Barratt +# Copyright (C) 2001-2009 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 3.2.0, released 31 Dec 2008. +# Version 3.2.0beta0, released 5 April 2009. # # See http://backuppc.sourceforge.net. # @@ -130,7 +130,7 @@ sub new my $bpc = bless { %$paths, - Version => '3.2.0', + Version => '3.2.0beta0', }, $class; $bpc->{storage} = BackupPC::Storage->new($paths); @@ -364,9 +364,9 @@ sub ConfigRead # 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) ); - $bpc->{Conf} = { %{$bpc->{Conf}}, %$config }; + $bpc->{Conf} = $config; } # @@ -1046,6 +1046,10 @@ sub NetBiosInfoGet }; $nmbCmd = $bpc->cmdVarSubstitute($bpc->{Conf}{NmbLookupCmd}, $args); foreach ( split(/[\n\r]+/, $bpc->cmdSystemOrEval($nmbCmd, undef, $args)) ) { + # + # skip and other non entries + # + next if ( /<\w{2}> - /i ); next if ( !/^\s*([\w\s-]+?)\s*<(\w{2})\> - .*/i ); $netBiosHostName ||= $1 if ( $2 eq "00" ); # host is first 00 $netBiosUserName = $1 if ( $2 eq "03" ); # user is last 03 @@ -1232,19 +1236,24 @@ sub cmdVarSubstitute # Merge variables into @cmd # 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 # - $arg =~ s{\$(\w+)(\+?)}{ + $arg =~ s[\${(\w+)}(\+?)]{ 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. # - 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;