From a2be0181a81adfca6f8fdf7c9b6190244c7146e2 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Thu, 10 Jul 2008 13:37:49 -0700 Subject: Revert "fix for bug 3441. Removed def from listOutputNodes(), which allowed other code that filters out def file to be removed." Need to spend more time with this fix--'def' is used in locations to suppress non-user specified default values. will reapply revised fix after a bit more vetting. This reverts commit 42d6c942800e2273b77ea92371ffdcb3f183163f. --- scripts/VyattaConfig.pm | 4 +--- scripts/VyattaConfigLoad.pm | 3 +++ scripts/VyattaConfigOutput.pm | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm index 1c0eaf3..3c4b51f 100755 --- a/scripts/VyattaConfig.pm +++ b/scripts/VyattaConfig.pm @@ -130,9 +130,7 @@ sub listOrigNodes { $tmp =~ s/\n//g; $tmp =~ s/%2F/\//g; #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n"; - if ($tmp ne 'def') { - push @nodes_modified, $tmp; - } + push @nodes_modified, $tmp; } return @nodes_modified; diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index c8563bb..1a7f26e 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -297,6 +297,9 @@ sub findDeletedNodes { $active_cfg->setLevel(join ' ', @active_path); my @active_nodes = $active_cfg->listOrigNodes(); foreach (@active_nodes) { + if ($_ eq 'def') { + next; + } if ($_ eq 'node.val') { findDeletedValues($new_ref, \@active_path); next; diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index ab7068f..5358c21 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -138,7 +138,7 @@ sub displayValues { my @cnames = sort keys %cnodes; if (defined($simple_show)) { - if ($show_all) { + if (!$cnodes{'def'} || $show_all) { if ($is_password && $hide_password) { $oval = $HIDE_PASSWORD; } @@ -159,7 +159,7 @@ sub displayValues { $diff = '>'; } } - if ($show_all) { + if (!$cnodes{'def'} || $show_all) { if ($is_password && $hide_password) { $value = $HIDE_PASSWORD; } @@ -194,6 +194,8 @@ sub displayDeletedOrigChildren { if ($cnames[0] eq 'node.val') { displayValues([ @cur_path, $child ], $prefix, $child, $dont_show_as_deleted); + } elsif ($cnames[0] eq 'def') { + #ignore } elsif (scalar($#cnames) >= 0) { if ($is_tag) { @cnames = sort versioncmp @cnames; -- cgit v1.2.3 From 3f41fcca673762ff27328192036719eace6b6495 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Fri, 11 Jul 2008 13:36:02 -0700 Subject: fix for bug 3441. Selective stripping of the 'def' only needs to occur in one location. hease enter the commit message for your changes. --- scripts/VyattaConfig.pm | 37 +++++++++++++++++++++++++++++++++++++ scripts/VyattaConfigOutput.pm | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm index 3c4b51f..941bb63 100755 --- a/scripts/VyattaConfig.pm +++ b/scripts/VyattaConfig.pm @@ -136,6 +136,43 @@ sub listOrigNodes { return @nodes_modified; } +## listOrigNodes("level") +# return array of all original nodes (i.e., before any current change; i.e., +# in "working") at "level" +# level is relative +sub listOrigNodesNoDef { + my ($self, $path) = @_; + my @nodes = (); + + if (defined $path) { + $path =~ s/\//%2F/g; + $path =~ s/\s+/\//g; + $path = $self->{_active_dir_base} . $self->{_current_dir_level} . "/" + . $path; + } + else { + $path = $self->{_active_dir_base} . $self->{_current_dir_level}; + } + + #print "DEBUG VyattaConfig->listNodes(): path = $path\n"; + opendir DIR, "$path" or return (); + @nodes = grep !/^\./, readdir DIR; + closedir DIR; + + my @nodes_modified = (); + while (@nodes) { + my $tmp = pop (@nodes); + $tmp =~ s/\n//g; + $tmp =~ s/%2F/\//g; + #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n"; + if ($tmp ne 'def') { + push @nodes_modified, $tmp; + } + } + + return @nodes_modified; +} + ## returnParent("level") # return the name of parent node relative to the current hierarchy # in this case "level" is set to the parent dir ".. .." diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index 5358c21..1933d22 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -189,7 +189,7 @@ sub displayDeletedOrigChildren { } my $is_tag = $config->isTagNode([ @cur_path, $child ]); $config->setLevel(join ' ', (@cur_path, $child)); - my @cnames = sort $config->listOrigNodes(); + my @cnames = sort $config->listOrigNodesNoDef(); if ($cnames[0] eq 'node.val') { displayValues([ @cur_path, $child ], $prefix, $child, -- cgit v1.2.3