[pmg-devel] [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning

Fabian Ebner f.ebner at proxmox.com
Tue Jun 15 15:27:52 CEST 2021


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 <f.ebner at proxmox.com>
---
 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 at pam') if $param->{cmd} eq 'upgrade' && $user ne 'root at pam';
+	if (defined($param->{cmd}) && $param->{cmd} eq 'upgrade' && $user ne 'root at pam') {
+	    raise_perm_exc('user != root at pam');
+	}
 
 	my $ticket = PMG::Ticket::assemble_vnc_ticket($user, $authpath);
 
-- 
2.30.2





More information about the pmg-devel mailing list