summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-06-16 14:42:29 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-06-16 14:42:29 -0700
commit6a1f49717eb8f5a3817362d75c0c9ac359dfa659 (patch)
tree33fcf83c5b047ec81d9613fd03a8188172c0bf3c /lib
parentba659edb4e8f7d8508def53e5fa43d292da90974 (diff)
downloadvyatta-cfg-6a1f49717eb8f5a3817362d75c0c9ac359dfa659.tar.gz
vyatta-cfg-6a1f49717eb8f5a3817362d75c0c9ac359dfa659.zip
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.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/Config.pm36
1 files changed, 20 insertions, 16 deletions
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') {