[pve-devel] [pve-container PATCH] Refactoring read_password.

Wolfgang Link w.link at proxmox.com
Thu Nov 3 09:06:32 CET 2016


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.
---
 src/PVE/CLI/pct.pm | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index cc06926..9e43a82 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -6,7 +6,6 @@ use warnings;
 use POSIX;
 use Fcntl;
 use File::Copy 'copy';
-use Term::ReadLine;
 
 use PVE::SafeSyslog;
 use PVE::Tools qw(extract_param);
@@ -73,13 +72,7 @@ __PACKAGE__->register_method ({
     }});
 
 sub read_password {
-    my $term = new Term::ReadLine ('pct');
-    my $attribs = $term->Attribs;
-    $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
-    my $input = $term->readline('Enter password: ');
-    my $conf = $term->readline('Retype password: ');
-    die "Passwords do not match.\n" if ($input ne $conf);
-    return $input;
+    return PVE::CLIHandler::read_password_impl('pct', 1);
 }
 
 sub string_param_file_mapping {
-- 
2.1.4





More information about the pve-devel mailing list