diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2008-01-08 11:46:46 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2008-01-08 11:46:46 -0800 |
commit | 8d083d34cc2f6dc592f71f81e60edfdd8582d845 (patch) | |
tree | d2c190b0bee969af97618f6907e6f3271219a9df /scripts/VyattaConfigOutput.pm | |
parent | fabea89d2586a33fb14c8e8fc489dd5fccab803d (diff) | |
download | vyatta-cfg-8d083d34cc2f6dc592f71f81e60edfdd8582d845.tar.gz vyatta-cfg-8d083d34cc2f6dc592f71f81e60edfdd8582d845.zip |
hide "password" values in output of "show configuration".
Diffstat (limited to 'scripts/VyattaConfigOutput.pm')
-rwxr-xr-x | scripts/VyattaConfigOutput.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index a1e999b..861316a 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -21,6 +21,13 @@ sub set_show_all { } } +my $hide_password = 0; +sub set_hide_password { + if (shift) { + $hide_password = 1; + } +} + my $config = undef; # $0: array ref for path @@ -34,6 +41,8 @@ sub displayValues { my $name = $_[2]; my $simple_show = $_[3]; my ($is_multi, $is_text, $default) = $config->parseTmpl(\@cur_path); + my $is_password = ($name =~ /^.*password$/); + my $HIDE_PASSWORD = '****************'; $config->setLevel(join ' ', @cur_path); if ($is_multi) { my @ovals = $config->returnOrigValues(''); @@ -50,12 +59,18 @@ sub displayValues { @ovals; if (defined($simple_show)) { foreach my $oval (@ovals) { + if ($is_password && $hide_password) { + $oval = $HIDE_PASSWORD; + } print "$prefix$name $oval\n"; } return; } foreach my $del (@dlist) { if (defined($del)) { + if ($is_password && $hide_password) { + $del = $HIDE_PASSWORD; + } print "-$prefix$name $del\n"; } } @@ -68,6 +83,9 @@ sub displayValues { $diff = ' '; } } + if ($is_password && $hide_password) { + $nval = $HIDE_PASSWORD; + } print "$diff$prefix$name $nval\n"; } } else { @@ -83,6 +101,9 @@ sub displayValues { } if (defined($simple_show)) { if (!defined($default) || $default ne $oval || $show_all) { + if ($is_password && $hide_password) { + $oval = $HIDE_PASSWORD; + } print "$prefix$name: $oval\n"; } return; @@ -101,6 +122,9 @@ sub displayValues { } } if (!defined($default) || $default ne $value || $show_all) { + if ($is_password && $hide_password) { + $value = $HIDE_PASSWORD; + } print "$diff$prefix$name: $value\n"; } } |