]> git.proxmox.com Git - pve-manager.git/commitdiff
don't save password and double lines in pvesh history
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 3 Aug 2016 09:09:45 +0000 (11:09 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 3 Aug 2016 10:23:01 +0000 (12:23 +0200)
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@proxmox.com>
bin/pvesh

index ac7047211cf556a8a87dd130006f8a0043c6c683..c5debe69eedef273679e0781f1caf02dd5d713d6 100755 (executable)
--- 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) ];