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>
# 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";
sub pmg_command {
my ($args, $nooutput) = @_;
+ my $rpcenv = PMG::RESTEnvironment->get();
$rpcenv->init_request();
my $ticket = PMG::Ticket::assemble_ticket('root@pam');