summaryrefslogtreecommitdiff
path: root/scripts/VyattaConfigOutput.pm
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-01-08 11:46:46 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-01-08 11:46:46 -0800
commit8d083d34cc2f6dc592f71f81e60edfdd8582d845 (patch)
treed2c190b0bee969af97618f6907e6f3271219a9df /scripts/VyattaConfigOutput.pm
parentfabea89d2586a33fb14c8e8fc489dd5fccab803d (diff)
downloadvyatta-cfg-8d083d34cc2f6dc592f71f81e60edfdd8582d845.tar.gz
vyatta-cfg-8d083d34cc2f6dc592f71f81e60edfdd8582d845.zip
hide "password" values in output of "show configuration".
Diffstat (limited to 'scripts/VyattaConfigOutput.pm')
-rwxr-xr-xscripts/VyattaConfigOutput.pm24
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";
}
}