public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning
@ 2021-06-15 13:27 Fabian Ebner
  2021-06-15 15:23 ` [pmg-devel] applied: " Stoiko Ivanov
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2021-06-15 13:27 UTC (permalink / raw)
  To: pmg-devel

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@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@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.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning
  2021-06-15 13:27 [pmg-devel] [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning Fabian Ebner
@ 2021-06-15 15:23 ` Stoiko Ivanov
  0 siblings, 0 replies; 2+ messages in thread
From: Stoiko Ivanov @ 2021-06-15 15:23 UTC (permalink / raw)
  To: Fabian Ebner; +Cc: pmg-devel

On Tue, 15 Jun 2021 15:27:52 +0200
Fabian Ebner <f.ebner@proxmox.com> wrote:

> 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@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@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);
>  

Huge Thanks for catching this - gave it a quick spin on my testsetup and
applied the patch!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-15 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 13:27 [pmg-devel] [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning Fabian Ebner
2021-06-15 15:23 ` [pmg-devel] applied: " Stoiko Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal