From 6a1f49717eb8f5a3817362d75c0c9ac359dfa659 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Wed, 16 Jun 2010 14:42:29 -0700 Subject: fix for bug 5696. set up relative path correctly in all cases and proper handling of slashes in embedded multis when checking deactivated state via api. --- lib/Vyatta/Config.pm | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'lib/Vyatta/Config.pm') diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 4c149cf..2fb938a 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -74,13 +74,15 @@ sub listNodes { my ($self, $path, $disable) = @_; my @nodes = (); + my $rpath = ""; if ($path) { - $path =~ s/\//%2F/g; - $path =~ s/\s+/\//g; - $path = $self->{_new_config_dir_base} . $self->{_current_dir_level} . "/" . $path; + $path =~ s/\//%2F/g; + $path =~ s/\s+/\//g; + $rpath = $self->{_current_dir_level} . "/" . $path; } else { - $path = $self->{_new_config_dir_base} . $self->{_current_dir_level}; + $rpath = $self->{_current_dir_level}; } + $path = $self->{_new_config_dir_base} . $rpath; #print "DEBUG Vyatta::Config->listNodes(): path = $path\n"; opendir my $dir, $path or return (); @@ -91,9 +93,9 @@ sub listNodes { while (@nodes) { my $tmp = pop (@nodes); $tmp =~ s/\n//g; - $tmp =~ s/%2F/\//g; #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n"; - my $ttmp = $self->{_current_dir_level} . "/" . $tmp; + my $ttmp = $rpath . "/" . $tmp; + $tmp =~ s/%2F/\//g; $ttmp =~ s/\// /g; if (!defined $disable) { my ($status, undef) = $self->getDeactivated($ttmp); @@ -232,15 +234,16 @@ sub listOrigNodes { my ($self, $path, $disable) = @_; my @nodes = (); + my $rpath = ""; if (defined $path) { $path =~ s/\//%2F/g; $path =~ s/\s+/\//g; - $path = $self->{_active_dir_base} . $self->{_current_dir_level} . "/" - . $path; + $rpath = $self->{_current_dir_level} . "/" . $path; } else { - $path = $self->{_active_dir_base} . $self->{_current_dir_level}; + $rpath = $self->{_current_dir_level}; } + $path = $self->{_active_dir_base} . $rpath; #print "DEBUG Vyatta::Config->listNodes(): path = $path\n"; opendir my $dir, "$path" or return (); @@ -251,9 +254,9 @@ sub listOrigNodes { while (@nodes) { my $tmp = pop (@nodes); $tmp =~ s/\n//g; - $tmp =~ s/%2F/\//g; #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n"; - my $ttmp = $self->{_current_dir_level} . "/" . $tmp; + my $ttmp = $rpath . "/" . $tmp; + $tmp =~ s/%2F/\//g; $ttmp =~ s/\// /g; if (!defined $disable) { my ($status, undef) = $self->getDeactivated($ttmp); @@ -277,15 +280,16 @@ sub listOrigNodesNoDef { my ($self, $path, $disable) = @_; my @nodes = (); + my $rpath = ""; if (defined $path) { $path =~ s/\//%2F/g; $path =~ s/\s+/\//g; - $path = $self->{_active_dir_base} . $self->{_current_dir_level} . "/" - . $path; + $rpath = $self->{_current_dir_level} . "/" . $path; } else { - $path = $self->{_active_dir_base} . $self->{_current_dir_level}; + $rpath = $self->{_current_dir_level}; } + $path = $self->{_active_dir_base} . $rpath; #print "DEBUG Vyatta::Config->listNodes(): path = $path\n"; opendir my $dir, $path or return (); @@ -296,11 +300,11 @@ sub listOrigNodesNoDef { while (@nodes) { my $tmp = pop (@nodes); $tmp =~ s/\n//g; + my $ttmp = $rpath . "/" . $tmp; $tmp =~ s/%2F/\//g; + $ttmp =~ s/\// /g; #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n"; if ($tmp ne 'def') { - my $ttmp = $self->{_current_dir_level} . "/" . $tmp; - $ttmp =~ s/\// /g; if (!defined $disable) { my ($status, undef) = $self->getDeactivated($ttmp); if (!defined($status) || $status eq 'active') { -- cgit v1.2.3