mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-08-07 12:28:05 +00:00
make read_password a CLIHandler class method
And use new run_cli_handler() method.
This commit is contained in:
parent
90399ca489
commit
98007830ee
@ -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 = {
|
our $cmddef = {
|
||||||
ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
|
ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
|
||||||
sub {
|
sub {
|
||||||
|
15
pveum
15
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 {
|
my $prepare = sub {
|
||||||
# autmatically generate the private key if it does not already exists
|
# autmatically generate the private key if it does not already exists
|
||||||
PVE::Cluster::gen_auth_key();
|
PVE::Cluster::gen_auth_key();
|
||||||
};
|
};
|
||||||
|
|
||||||
PVE::CLI::pveum->run_cli($read_password, undef, $prepare);
|
PVE::CLI::pveum->run_cli_handler(prepare => $prepare);
|
||||||
|
Loading…
Reference in New Issue
Block a user