[pve-devel] [PATCH manager] don't save password and double lines in pvesh history

Dominik Csapak d.csapak at proxmox.com
Wed Aug 3 11:09:45 CEST 2016


we assumed that Term::ReadLine does not put
input into the history automatically, but it does this

so if this feature is enabled, we do not have to add
the inputs manually, and we have to delete the password
from the history

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
i looked for a way to disable this autohistory feature,
but did not find one. the perl module is
Term::ReadLine::Gnu, if someone knows a way to do this,
i would prefer it

 bin/pvesh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/bin/pvesh b/bin/pvesh
index ac70472..c5debe6 100755
--- a/bin/pvesh
+++ b/bin/pvesh
@@ -189,6 +189,14 @@ my $read_password = sub {
     my $input = $term->readline('password: ');
     my $conf = $term->readline('Retype new password: ');
     $attribs->{redisplay_function} = $old;
+
+    # remove password from history
+    if ($term->Features->{autohistory}) {
+	my $historyPosition = $term->where_history();
+	$term->remove_history($historyPosition);
+	$term->remove_history($historyPosition - 1);
+    }
+
     die "Passwords do not match.\n" if ($input ne $conf);
     return $input;
 };
@@ -558,7 +566,11 @@ while (defined ($input = $term->readline("pve:/$cdir> "))) {
 	exit (0);
     }
 
-    $term->addhistory($input);
+    # add input to history if it gets not
+    # automatically added
+    if (!$term->Features->{autohistory}) {
+	$term->addhistory($input);
+    }
 
     eval {
 	my $args = [ shellwords($input) ];
-- 
2.1.4





More information about the pve-devel mailing list