]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/CIFSPlugin.pm
cephfs: add support for multiple ceph filesystems
[pve-storage.git] / PVE / Storage / CIFSPlugin.pm
index be06cc761e4e7244358ce72379ef50d7e2a93edd..3a7e638c25407f84655a025957dc6791c05d29b1 100644 (file)
@@ -59,9 +59,6 @@ sub get_cred_file {
 
     if (-e $cred_file) {
        return $cred_file;
-    } elsif (-e "/etc/pve/priv/${storeid}.cred") {
-       # FIXME: remove fallback with 7.0 by doing a rename on upgrade from 6.x
-       return "/etc/pve/priv/${storeid}.cred";
     }
     return undef;
 }
@@ -81,7 +78,7 @@ sub cifs_mount {
        push @$cmd, 'guest,username=guest';
     }
 
-    push @$cmd, '-o', defined($smbver) ? "vers=$smbver" : "vers=3.0";
+    push @$cmd, '-o', defined($smbver) ? "vers=$smbver" : "vers=default";
 
     run_command($cmd, errmsg => "mount error");
 }
@@ -118,9 +115,11 @@ sub properties {
            maxLength => 256,
        },
        smbversion => {
-           description => "SMB protocol version",
+           description => "SMB protocol version. 'default' if not set, negotiates the highest SMB2+"
+               ." version supported by both the client and server.",
            type => 'string',
-           enum => ['2.0', '2.1', '3.0'],
+           default => 'default',
+           enum => ['default', '2.0', '2.1', '3', '3.0', '3.11'],
            optional => 1,
        },
     };
@@ -143,6 +142,7 @@ sub options {
        smbversion => { optional => 1},
        mkdir => { optional => 1 },
        bwlimit => { optional => 1 },
+       preallocation => { optional => 1 },
     };
 }
 
@@ -158,12 +158,12 @@ sub check_config {
 # Storage implementation
 
 sub on_add_hook {
-    my ($class, $storeid, $scfg, %param) = @_;
+    my ($class, $storeid, $scfg, %sensitive) = @_;
 
-    if (defined($param{password})) {
-       cifs_set_credentials($param{password}, $storeid);
+    if (defined($sensitive{password})) {
+       cifs_set_credentials($sensitive{password}, $storeid);
        if (!exists($scfg->{username})) {
-           warn "ignoring password parameter\n";
+           warn "storage $storeid: ignoring password parameter, no user set\n";
        }
     } else {
        cifs_delete_credentials($storeid);
@@ -173,14 +173,14 @@ sub on_add_hook {
 }
 
 sub on_update_hook {
-    my ($class, $storeid, $scfg, %param) = @_;
+    my ($class, $storeid, $scfg, %sensitive) = @_;
 
-    return if !exists($param{password});
+    return if !exists($sensitive{password});
 
-    if (defined($param{password})) {
-       cifs_set_credentials($param{password}, $storeid);
+    if (defined($sensitive{password})) {
+       cifs_set_credentials($sensitive{password}, $storeid);
        if (!exists($scfg->{username})) {
-           warn "ignoring password parameter\n";
+           warn "storage $storeid: ignoring password parameter, no user set\n";
        }
     } else {
        cifs_delete_credentials($storeid);
@@ -258,9 +258,12 @@ sub check_connection {
 
     my $servicename = '//'.$scfg->{server}.'/'.$scfg->{share};
 
-    my $cmd = ['/usr/bin/smbclient', $servicename, '-d', '0', '-m'];
+    my $cmd = ['/usr/bin/smbclient', $servicename, '-d', '0'];
 
-    push @$cmd, $scfg->{smbversion} ? "smb".int($scfg->{smbversion}) : 'smb3';
+    if (defined($scfg->{smbversion}) && $scfg->{smbversion} ne 'default') {
+       # max-protocol version, so basically only relevant for smb2 vs smb3
+       push @$cmd, '-m', "smb" . int($scfg->{smbversion});
+    }
 
     if (my $cred_file = get_cred_file($storeid)) {
        push @$cmd, '-U', $scfg->{username}, '-A', $cred_file;