[pve-devel] [PATCH] Use enums for smbvers to prevent incorrect input

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jun 6 15:51:02 CEST 2018


On 6/6/18 1:23 PM, Wolfgang Link wrote:
> ---
>  PVE/Storage/CIFSPlugin.pm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm
> index cb7c844..2124c87 100644
> --- a/PVE/Storage/CIFSPlugin.pm
> +++ b/PVE/Storage/CIFSPlugin.pm
> @@ -104,8 +104,9 @@ sub properties {
>  	    maxLength => 256,
>  	},
>  	smbversion => {
> -	    description => "",
> +	    description => "SMB protokoll version",

s/protokoll/protocol/

>  	    type => 'string',
> +	    enum => ['2.0', '2.1', '3.0'],

We use the following code to tell smbclient about what version to use with
the -m option.

my $cmd = ['/usr/bin/smbclient', $servicename, '-d', '0', '-m'];
push @$cmd, $scfg->{smbversion} ? "smb".int($scfg->{smbversion}) : 'smb3';

Thus an user could (validly) used '2', '3', '3.0.2', '3.1.1' for this and
it'd have worked, but after this patch the user gets an verification error.
While maybe to to probable it's still not ideal...
Should we just hope nobody did that?


>  	    optional => 1,
>  	},
>      };
> 




More information about the pve-devel mailing list