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/CLIHandler.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm index e2a81a0..580040e 100644 --- a/src/PVE/CLIHandler.pm +++ b/src/PVE/CLIHandler.pm @@ -8,6 +8,7 @@ use PVE::SafeSyslog; use PVE::Exception qw(raise raise_param_exc); use PVE::RESTHandler; use PVE::INotify; +use Term::ReadLine; use base qw(PVE::RESTHandler); @@ -48,6 +49,30 @@ my $complete_command_names = sub { return $res; }; +sub read_password_impl{ + my ($command, $set_pass, $undo_shadow) = @_; + + my $term = new Term::ReadLine($command); + my $attribs = $term->Attribs; + my $redisplay = $attribs->{redisplay_function}; + $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; + + my $remove_hist = $term->Features->{autohistory} ? 1 : 0; + + my $input = undef; + $input = $term->readline('Enter password: '); + $term->remove_history($term->where_history()) if $remove_hist; + + my $conf = $term->readline('Retype password: ') if $set_pass; + $term->remove_history($term->where_history()) if $remove_hist; + + $attribs->{redisplay_function} = $redisplay if $undo_shadow; + die "Passwords do not match.\n" if ($set_pass && ($input ne $conf)); + + return $input; + +} + __PACKAGE__->register_method ({ name => 'help', path => 'help', -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel