]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #4815: pmgsh: fix calling the api paths directly
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 3 Jul 2023 08:28:19 +0000 (10:28 +0200)
committerStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 3 Jul 2023 09:08:12 +0000 (11:08 +0200)
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/.130008/

Fixes: 1583283 ("pmgsh: initialize RPC/REST environment late")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [S.I: add bugreference, fixes trailer and shorten forum link]
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/bin/pmgsh

index f9816cd7e177ada7dcaf0a73305dd2e00207e134..7499c425072076da46aa15013de4fdab433da84f 100755 (executable)
@@ -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@pam');