use PVE::Storage;
use PVE::Storage::Plugin;
use PVE::Storage::LVMPlugin;
+use PVE::Storage::CIFSPlugin;
use HTTP::Status qw(:constants);
use Storable qw(dclone);
use PVE::JSONSchema qw(get_standard_option);
return $scfg;
};
-my $cifs_cred_file_name = sub {
- my ($storeid) = @_;
-
- return "/etc/pve/priv/${storeid}.cred";
-};
-
-my $set_cifs_credentials = sub {
- my ($password, $storeid) = @_;
-
- my $cred_file = $cifs_cred_file_name->($storeid);
-
- PVE::Tools::file_set_contents($cred_file, "password=$password\n");
-
- return $cred_file;
-};
-
__PACKAGE__->register_method ({
name => 'index',
path => '',
}
# create a password file in /etc/pve/priv,
# this file is used as a cert_file at mount time.
- my $cred_file = &$set_cifs_credentials($password, $storeid)
- if defined($password);
+ my $cred_file = PVE::Storage::cifs_set_credentials($password, $storeid)
+ if $type eq 'cifs' && defined($password);
eval {
# try to activate if enabled on local node,
if PVE::Storage::storage_is_used($cfg, $storeid);
if ($scfg->{type} eq 'cifs') {
- my $cred_file = $cifs_cred_file_name->($storeid);
+ my $cred_file = PVE::Storage::cifs_cred_file_name($storeid);
if (-f $cred_file) {
unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
}
return undef;
}
+sub cifs_cred_file_name {
+ my ($storeid) = @_;
+
+ return "/etc/pve/priv/${storeid}.cred";
+}
+
+sub cifs_set_credentials {
+ my ($password, $storeid) = @_;
+
+ my $cred_file = cifs_cred_file_name($storeid);
+
+ PVE::Tools::file_set_contents($cred_file, "password=$password\n");
+
+ return $cred_file;
+}
+
sub get_cred_file {
my ($storeid) = @_;
- my $cred_file = '/etc/pve/priv/'.$storeid.'.cred';
+ my $cred_file = cifs_cred_file_name($storeid);
- if (-e $cred_file) {
- return $cred_file;
- }
- return undef;
+ return -e $cred_file ? $cred_file : undef;
}
sub cifs_mount {