[pve-devel] [PATCH access-control] replace Term::ReadLine with PVE::PTY

Dominik Csapak d.csapak at proxmox.com
Mon Jun 4 17:32:34 CEST 2018


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/CLI/pveum.pm  | 15 +++++----------
 debian/control    |  1 -
 test/auth-test.pl |  7 ++-----
 3 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
index aef7089..e2ced77 100755
--- a/PVE/CLI/pveum.pm
+++ b/PVE/CLI/pveum.pm
@@ -8,9 +8,9 @@ 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::PTY;
 use PVE::API2::User;
 use PVE::API2::Group;
 use PVE::API2::Role;
@@ -26,15 +26,10 @@ sub setup_environment {
 }
 
 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;
+    my $pw = PVE::PTY::read_password('Enter new password: ');
+    my $pw2 = PVE::PTY::read_password('Repeat password: ');
+    die "passwords do not match\n" if $pw ne $pw2;
+    return $pw;
 }
 
 our $cmddef = {
diff --git a/debian/control b/debian/control
index 07243f7..0f4d49b 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,6 @@ Depends: libauthen-pam-perl,
          libnet-ldap-perl,
          libnet-ssleay-perl,
          libpve-common-perl,
-         libterm-readline-gnu-perl,
          liburi-perl,
          libwww-perl,
          perl (>= 5.6.0-16),
diff --git a/test/auth-test.pl b/test/auth-test.pl
index 50a7f89..49135f5 100644
--- a/test/auth-test.pl
+++ b/test/auth-test.pl
@@ -1,17 +1,14 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Term::ReadLine;
+use PVE::PTY;
 use PVE::AccessControl;
 
 my $username = shift;
 die "Username missing" if !$username;
 sub read_password {
 
-    my $term = new Term::ReadLine ('pveum');
-    my $attribs = $term->Attribs;
-    $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
-    my $input = $term->readline('password: ');
+    my $input = PVE::PTY::read_password('password: ');
     return $input;
 }
 
-- 
2.11.0





More information about the pve-devel mailing list