mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-06-05 14:53:15 +00:00
replace read_password with param_mapping
use the get_standar_mapping 'pve-password' then we can get rid of the Term::ReadLine dependency we use this change to only ask for the password once on 'pveum ticket' Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
765305e210
commit
b34d76e726
@ -8,7 +8,6 @@ use PVE::Cluster;
|
|||||||
use PVE::SafeSyslog;
|
use PVE::SafeSyslog;
|
||||||
use PVE::AccessControl;
|
use PVE::AccessControl;
|
||||||
use File::Path qw(make_path remove_tree);
|
use File::Path qw(make_path remove_tree);
|
||||||
use Term::ReadLine;
|
|
||||||
use PVE::INotify;
|
use PVE::INotify;
|
||||||
use PVE::RPCEnvironment;
|
use PVE::RPCEnvironment;
|
||||||
use PVE::API2::User;
|
use PVE::API2::User;
|
||||||
@ -18,6 +17,7 @@ use PVE::API2::ACL;
|
|||||||
use PVE::API2::AccessControl;
|
use PVE::API2::AccessControl;
|
||||||
use PVE::JSONSchema qw(get_standard_option);
|
use PVE::JSONSchema qw(get_standard_option);
|
||||||
use PVE::CLIHandler;
|
use PVE::CLIHandler;
|
||||||
|
use PVE::PTY;
|
||||||
|
|
||||||
use base qw(PVE::CLIHandler);
|
use base qw(PVE::CLIHandler);
|
||||||
|
|
||||||
@ -25,16 +25,24 @@ sub setup_environment {
|
|||||||
PVE::RPCEnvironment->setup_default_cli_env();
|
PVE::RPCEnvironment->setup_default_cli_env();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub read_password {
|
sub param_mapping {
|
||||||
# return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
|
my ($name) = @_;
|
||||||
|
|
||||||
my $term = new Term::ReadLine ('pveum');
|
my $mapping = {
|
||||||
my $attribs = $term->Attribs;
|
'change_password' => [
|
||||||
$attribs->{redisplay_function} = $attribs->{shadow_redisplay};
|
PVE::CLIHandler::get_standard_mapping('pve-password'),
|
||||||
my $input = $term->readline('Enter new password: ');
|
],
|
||||||
my $conf = $term->readline('Retype new password: ');
|
'create_ticket' => [
|
||||||
die "Passwords do not match.\n" if ($input ne $conf);
|
PVE::CLIHandler::get_standard_mapping('pve-password', {
|
||||||
return $input;
|
func => sub {
|
||||||
|
# do not accept values given on cmdline
|
||||||
|
return PVE::PTY::read_password('Enter password: ');
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
return $mapping->{$name};
|
||||||
}
|
}
|
||||||
|
|
||||||
our $cmddef = {
|
our $cmddef = {
|
||||||
|
1
debian/control
vendored
1
debian/control
vendored
@ -22,7 +22,6 @@ Depends: libauthen-pam-perl,
|
|||||||
libnet-ldap-perl,
|
libnet-ldap-perl,
|
||||||
libnet-ssleay-perl,
|
libnet-ssleay-perl,
|
||||||
libpve-common-perl (>= 5.0-27),
|
libpve-common-perl (>= 5.0-27),
|
||||||
libterm-readline-gnu-perl,
|
|
||||||
liburi-perl,
|
liburi-perl,
|
||||||
libwww-perl,
|
libwww-perl,
|
||||||
perl (>= 5.6.0-16),
|
perl (>= 5.6.0-16),
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Term::ReadLine;
|
use PVE::PTY;
|
||||||
use PVE::AccessControl;
|
use PVE::AccessControl;
|
||||||
|
|
||||||
my $username = shift;
|
my $username = shift;
|
||||||
die "Username missing" if !$username;
|
die "Username missing" if !$username;
|
||||||
sub read_password {
|
|
||||||
|
|
||||||
my $term = new Term::ReadLine ('pveum');
|
my $password = PVE::PTY::read_password('password: ');
|
||||||
my $attribs = $term->Attribs;
|
|
||||||
$attribs->{redisplay_function} = $attribs->{shadow_redisplay};
|
|
||||||
my $input = $term->readline('password: ');
|
|
||||||
return $input;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $password = read_password();
|
|
||||||
PVE::AccessControl::authenticate_user($username,$password);
|
PVE::AccessControl::authenticate_user($username,$password);
|
||||||
|
|
||||||
print "Authentication Successful!!\n";
|
print "Authentication Successful!!\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user