[pve-devel] [pve-manager PATCH V2] Refactoring read_password.
Wolfgang Link
w.link at proxmox.com
Fri Jan 13 13:36:42 CET 2017
We use this function in 3 different packets with the same code.
It will moved to the CLIHandler, because we need it only on the command line.
---
bin/pvesh | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/bin/pvesh b/bin/pvesh
index 6f7687e..80eb11e 100755
--- a/bin/pvesh
+++ b/bin/pvesh
@@ -16,6 +16,7 @@ use PVE::Cluster;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::API2;
+use PVE::CLIHandler;
use JSON;
PVE::INotify::inotify_init();
@@ -183,22 +184,7 @@ sub abs_path {
}
my $read_password = sub {
- my $attribs = $term->Attribs;
- my $old = $attribs->{redisplay_function};
- $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
- 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;
+ return PVE::CLIHandler::read_password_impl('pvesh', 1, 1)
};
sub reverse_map_cmd {
--
2.1.4
More information about the pve-devel
mailing list