[pmg-devel] applied: [PATCH pmg-api] api: nodes: add definedness check to avoid perl warning
Stoiko Ivanov
s.ivanov at proxmox.com
Tue Jun 15 17:23:53 CEST 2021
On Tue, 15 Jun 2021 15:27:52 +0200
Fabian Ebner <f.ebner at 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 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);
>
Huge Thanks for catching this - gave it a quick spin on my testsetup and
applied the patch!
More information about the pmg-devel
mailing list