[pmg-devel] applied: [PATCH pmg-api] pmgsh: fix calling the api paths directly

Stoiko Ivanov s.ivanov at proxmox.com
Mon Jul 3 11:15:48 CEST 2023


Thanks for the fix!
Applied with bug-reference and Fixes trailer added!


On Mon,  3 Jul 2023 10:28:19 +0200
Dominik Csapak <d.csapak at proxmox.com> wrote:

> if we get a command directly, we don't initialize the $rpcenv
> variable anymore.
> 
> To fix it, make it a local variable of the pmg_command function.
> We now make one extra '->get()' call per command (as opposed to
> once per program), but that shouldn't cost us anything really.
> 
> Reported in the forum: https://forum.proxmox.com/threads/pmgsh-failing.130008/
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/bin/pmgsh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/bin/pmgsh b/src/bin/pmgsh
> index f9816cd..7499c42 100755
> --- a/src/bin/pmgsh
> +++ b/src/bin/pmgsh
> @@ -78,7 +78,6 @@ if (scalar (@ARGV) != 0) {
>  
>  # only set up once actually required allows calling verifyapi in restriced clean sbuild env
>  PMG::RESTEnvironment->setup_default_cli_env();
> -my $rpcenv = PMG::RESTEnvironment->get();
>  initlog($ENV{PVE_LOG_ID} || 'pmgsh');
>  
>  print "entering PMG shell - type 'help' for help\n";
> @@ -451,6 +450,7 @@ sub list_dir {
>  sub pmg_command {
>      my ($args, $nooutput) = @_;
>  
> +    my $rpcenv = PMG::RESTEnvironment->get();
>      $rpcenv->init_request();
>  
>      my $ticket = PMG::Ticket::assemble_ticket('root at pam');





More information about the pmg-devel mailing list