]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/CIFSPlugin.pm
zfspool: add zfs_get_sorted_snapshot_list helper
[pve-storage.git] / PVE / Storage / CIFSPlugin.pm
index 72ec757b0beb7885e43f9ff5623947c3ccc474ab..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,
        },
     };
@@ -134,6 +133,7 @@ sub options {
        nodes => { optional => 1 },
        disable => { optional => 1 },
        maxfiles => { optional => 1 },
+       'prune-backups' => { optional => 1 },
        content => { optional => 1 },
        format => { optional => 1 },
        username => { optional => 1 },
@@ -142,6 +142,7 @@ sub options {
        smbversion => { optional => 1},
        mkdir => { optional => 1 },
        bwlimit => { optional => 1 },
+       preallocation => { optional => 1 },
     };
 }
 
@@ -157,37 +158,43 @@ 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);
     }
+
+    return;
 }
 
 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);
     }
+
+    return;
 }
 
 sub on_delete_hook {
     my ($class, $storeid, $scfg) = @_;
 
     cifs_delete_credentials($storeid);
+
+    return;
 }
 
 sub status {
@@ -251,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;
@@ -261,14 +271,12 @@ sub check_connection {
     } else {
        push @$cmd, '-U', 'Guest','-N';
     }
-
     push @$cmd, '-c', 'echo 1 0';
 
     my $out_str;
-    eval {
-       run_command($cmd, timeout => 2, outfunc => sub {$out_str .= shift;},
-                   errfunc => sub {});
-    };
+    my $out = sub { $out_str .= shift };
+
+    eval { run_command($cmd, timeout => 10, outfunc => $out, errfunc => sub {}) };
 
     if (my $err = $@) {
        die "$out_str\n" if defined($out_str) &&
@@ -279,4 +287,13 @@ sub check_connection {
     return 1;
 }
 
+sub get_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::get_volume_notes($class, @_);
+}
+sub update_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::update_volume_notes($class, @_);
+}
+
 1;