[pve-devel] [pve-access-control PATCH V2] Refactoring read_password.

Wolfgang Link w.link at proxmox.com
Fri Jan 13 13:36:43 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.
---
 PVE/CLI/pveum.pm | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
index 8a8edc5..512fea1 100755
--- a/PVE/CLI/pveum.pm
+++ b/PVE/CLI/pveum.pm
@@ -8,7 +8,6 @@ use PVE::Cluster;
 use PVE::SafeSyslog;
 use PVE::AccessControl;
 use File::Path qw(make_path remove_tree);
-use Term::ReadLine;
 use PVE::INotify;
 use PVE::RPCEnvironment;
 use PVE::API2::User;
@@ -22,15 +21,7 @@ use PVE::CLIHandler;
 use base qw(PVE::CLIHandler);
 
 sub read_password {
-    # return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
-
-    my $term = new Term::ReadLine ('pveum');
-    my $attribs = $term->Attribs;
-    $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
-    my $input = $term->readline('Enter new password: ');
-    my $conf = $term->readline('Retype new password: ');
-    die "Passwords do not match.\n" if ($input ne $conf);
-    return $input;
+    return PVE::CLIHandler::read_password_impl('pveum', 1);
 }
 
 our $cmddef = {
-- 
2.1.4





More information about the pve-devel mailing list