]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/CIFSPlugin.pm
postinst: move cifs credential files into subdirectory upon update
[pve-storage.git] / PVE / Storage / CIFSPlugin.pm
index a64de8319e413a5ec3757d2b3e9b5c607aa11c7f..9d69b01f16b12697a810ba4eb8c1d1c098d74954 100644 (file)
@@ -30,7 +30,7 @@ sub cifs_is_mounted {
 
 sub cifs_cred_file_name {
     my ($storeid) = @_;
-    return "/etc/pve/priv/storage/${storeid}.cred";
+    return "/etc/pve/priv/storage/${storeid}.pw";
 }
 
 sub cifs_delete_credentials {
@@ -59,9 +59,6 @@ sub get_cred_file {
 
     if (-e $cred_file) {
        return $cred_file;
-    } elsif ("/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;
 }
@@ -107,7 +104,7 @@ sub properties {
            type => 'string',
        },
        password => {
-           description => "Password for CIFS share.",
+           description => "Password for accessing the share/datastore.",
            type => 'string',
            maxLength => 256,
        },
@@ -134,6 +131,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 },
@@ -161,9 +159,14 @@ sub on_add_hook {
 
     if (defined($param{password})) {
        cifs_set_credentials($param{password}, $storeid);
+       if (!exists($scfg->{username})) {
+           warn "ignoring password parameter\n";
+       }
     } else {
        cifs_delete_credentials($storeid);
     }
+
+    return;
 }
 
 sub on_update_hook {
@@ -173,15 +176,22 @@ sub on_update_hook {
 
     if (defined($param{password})) {
        cifs_set_credentials($param{password}, $storeid);
+       if (!exists($scfg->{username})) {
+           warn "ignoring password parameter\n";
+       }
     } else {
        cifs_delete_credentials($storeid);
     }
+
+    return;
 }
 
 sub on_delete_hook {
     my ($class, $storeid, $scfg) = @_;
 
     cifs_delete_credentials($storeid);
+
+    return;
 }
 
 sub status {
@@ -255,14 +265,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) &&
@@ -273,4 +281,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;