From 780504cc76cb64e16a563eb59f92919e6d187d6d Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Tue, 15 Jun 2021 15:27:52 +0200 Subject: [PATCH] api: nodes: add definedness check to avoid perl warning also add the missing import for 'raise_perm_exc' to avoid having the error about the undefined subroutine instead of the actual error. Signed-off-by: Fabian Ebner --- src/PMG/API2/Nodes.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm index f9ccfae..e41194b 100644 --- a/src/PMG/API2/Nodes.pm +++ b/src/PMG/API2/Nodes.pm @@ -6,6 +6,7 @@ use Time::Local qw(timegm_nocheck); use Filesys::Df; use Data::Dumper; +use PVE::Exception qw(raise_perm_exc); use PVE::INotify; use PVE::RESTHandler; use PVE::JSONSchema qw(get_standard_option); @@ -428,7 +429,9 @@ __PACKAGE__->register_method ({ my $restenv = PMG::RESTEnvironment->get(); my $user = $restenv->get_user(); - raise_perm_exc('user != root@pam') if $param->{cmd} eq 'upgrade' && $user ne 'root@pam'; + if (defined($param->{cmd}) && $param->{cmd} eq 'upgrade' && $user ne 'root@pam') { + raise_perm_exc('user != root@pam'); + } my $ticket = PMG::Ticket::assemble_vnc_ticket($user, $authpath); -- 2.39.5