Make check_connection less costly.

This command will only check the needed share
and do not query the hole server shares.

This reduce the answer time and also has the benefit we check the
credentials on this share and not on the server.
This commit is contained in:
Wolfgang Link
2018-05-16 13:46:42 +02:00
committed by Wolfgang Bumiller
parent 9a75947b49
commit ff6fa67fb6

View File

@ -198,9 +198,9 @@ sub deactivate_storage {
sub check_connection {
my ($class, $storeid, $scfg) = @_;
my $server = $scfg->{server};
my $servicename = '//'.$scfg->{server}.'/'.$scfg->{share};
my $cmd = ['/usr/bin/smbclient', '-L', $server, '-d', '0', '-m'];
my $cmd = ['/usr/bin/smbclient', $servicename, '-d', '0', '-m'];
push @$cmd, $scfg->{smbversion} ? "smb".int($scfg->{smbversion}) : 'smb3';
@ -211,6 +211,8 @@ sub check_connection {
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;},