[pve-devel] [PATCH manager 1/4] api: backup: refactor backup permission check

Fiona Ebner f.ebner at proxmox.com
Wed Jun 14 11:49:09 CEST 2023


Am 13.06.23 um 15:42 schrieb Alexander Zeidler:
> Unify style before adding another parameter check
> 
> Signed-off-by: Alexander Zeidler <a.zeidler at proxmox.com>
> ---
>  PVE/API2/Backup.pm | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
> index 45eb47e2..cae889f4 100644
> --- a/PVE/API2/Backup.pm
> +++ b/PVE/API2/Backup.pm
> @@ -49,8 +49,11 @@ sub assert_param_permission_common {
>  	raise_param_exc({ $key => "Only root may set this option."}) if exists $param->{$key};
>      }
>  
> -    if (defined($param->{bwlimit}) || defined($param->{ionice}) || defined($param->{performance})) {
> -	$rpcenv->check($user, "/", [ 'Sys.Modify' ]);
> +    for my $key (qw(bwlimit ionice performance)) {
> +	if (defined($param->{$key})) {
> +	    $rpcenv->check($user, "/", [ 'Sys.Modify' ]);
> +	    last;
> +	}

Style nit: using something like
if ( grep { defined($_); } qw(...) ) {
would keep the line count low ;)

>      }
>  }
>  





More information about the pve-devel mailing list