[pve-devel] [PATCH v2 2/3] make path and perm optional parameters

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 11 11:34:59 CET 2017


On 12/11/2017 11:28 AM, Dominik Csapak wrote:
> and only pass perm to the api call if it is not empty
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PVE/CLI/termproxy.pm | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/src/PVE/CLI/termproxy.pm b/src/PVE/CLI/termproxy.pm
> index 382270d..7378821 100644
> --- a/src/PVE/CLI/termproxy.pm
> +++ b/src/PVE/CLI/termproxy.pm
> @@ -21,11 +21,15 @@ sub verify_ticket {
>  
>      my $ua = LWP::UserAgent->new();
>  
> -    my $res = $ua->post ('http://localhost:85/api2/json/access/ticket', Content => {
> -			 username => $user,
> -			 password => $ticket,
> -			 path => $path,
> -			 privs => $perm, });
> +    my $params = {
> +	username => $user,
> +	password => $ticket,
> +	path => $path,
> +    };
> +
> +    $params->{privs} = $perm if $perm;

but $perm is, as $path, always defined to the default value (DEFAULT_PERM)
by this methods callers caller (exec). Or will it get used in another
context in the future?

> +
> +    my $res = $ua->post ('http://localhost:85/api2/json/access/ticket', Content => $params);
>  
>      if (!$res->is_success) {
>  	die "Authentication failed: '$res->status_line'\n";
> @@ -209,11 +213,13 @@ __PACKAGE__->register_method ({
>  		type => 'string',
>  		description => "The Authentication path. (default: '".DEFAULT_PATH."')",
>  		default => DEFAULT_PATH,
> +		optional => 1,
>  	    },
>  	    perm => {
>  		type => 'string',
>  		description => "The Authentication Permission. (default: '".DEFAULT_PERM."')",
>  		default => DEFAULT_PERM,
> +		optional => 1,
>  	    },
>  	    'extra-args' => get_standard_option('extra-args'),
>  	},
> 





More information about the pve-devel mailing list