]> git.proxmox.com Git - pve-access-control.git/commitdiff
make read_password a CLIHandler class method
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 2 Oct 2015 08:45:58 +0000 (10:45 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 2 Oct 2015 08:45:58 +0000 (10:45 +0200)
And use new run_cli_handler() method.

PVE/CLI/pveum.pm
pveum

index 772ba2949685b1c4f6eff4e532ee9009eb161217..b12a0bda29bcbbf495a4569676854cd5566a45ff 100755 (executable)
@@ -21,6 +21,18 @@ use PVE::CLIHandler;
 
 use base qw(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;
+}
+
 our $cmddef = {
     ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
                sub {
 our $cmddef = {
     ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
                sub {
diff --git a/pveum b/pveum
index 4ab2e0c4c4b9672d68fa987103ed4bdba7b29f44..196fb3a614d5f71c1b4057498d8ac641a80d3529 100755 (executable)
--- a/pveum
+++ b/pveum
@@ -5,22 +5,9 @@ use warnings;
 
 use PVE::CLI::pveum;
 
 
 use PVE::CLI::pveum;
 
-my $read_password = sub {
-
-    # 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 $prepare = sub {
     # autmatically generate the private key if it does not already exists
     PVE::Cluster::gen_auth_key();
 };
 
 my $prepare = sub {
     # autmatically generate the private key if it does not already exists
     PVE::Cluster::gen_auth_key();
 };
 
-PVE::CLI::pveum->run_cli($read_password, undef, $prepare);
+PVE::CLI::pveum->run_cli_handler(prepare => $prepare);