CIFSPlugin.pm: fix crediential handling using new on_update_hook
This commit is contained in:
committed by
Thomas Lamprecht
parent
0ff4cfead1
commit
e2fc55b413
@ -34,6 +34,15 @@ sub cifs_cred_file_name {
|
|||||||
return "/etc/pve/priv/${storeid}.cred";
|
return "/etc/pve/priv/${storeid}.cred";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub cifs_delete_credentials {
|
||||||
|
my ($storeid) = @_;
|
||||||
|
|
||||||
|
my $cred_file = cifs_cred_file_name($storeid);
|
||||||
|
if (-f $cred_file) {
|
||||||
|
unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub cifs_set_credentials {
|
sub cifs_set_credentials {
|
||||||
my ($password, $storeid) = @_;
|
my ($password, $storeid) = @_;
|
||||||
|
|
||||||
@ -145,18 +154,29 @@ sub check_config {
|
|||||||
sub on_add_hook {
|
sub on_add_hook {
|
||||||
my ($class, $storeid, $scfg, %param) = @_;
|
my ($class, $storeid, $scfg, %param) = @_;
|
||||||
|
|
||||||
if (my $password = $param{password}) {
|
if (defined($param{password})) {
|
||||||
cifs_set_credentials($password, $storeid);
|
cifs_set_credentials($param{password}, $storeid);
|
||||||
|
} else {
|
||||||
|
cifs_delete_credentials($storeid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub on_update_hook {
|
||||||
|
my ($class, $storeid, $scfg, %param) = @_;
|
||||||
|
|
||||||
|
return if !exists($param{password});
|
||||||
|
|
||||||
|
if (defined($param{password})) {
|
||||||
|
cifs_set_credentials($param{password}, $storeid);
|
||||||
|
} else {
|
||||||
|
cifs_delete_credentials($storeid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub on_delete_hook {
|
sub on_delete_hook {
|
||||||
my ($class, $storeid, $scfg) = @_;
|
my ($class, $storeid, $scfg) = @_;
|
||||||
|
|
||||||
my $cred_file = cifs_cred_file_name($storeid);
|
cifs_delete_credentials($storeid);
|
||||||
if (-f $cred_file) {
|
|
||||||
unlink($cred_file) or warn "removing cifs credientials '$cred_file' failed: $!\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub status {
|
sub status {
|
||||||
|
|||||||
Reference in New Issue
Block a user