From ff6fa67fb6a688ea8c206f7a2b0e5f3f5bd5e3e9 Mon Sep 17 00:00:00 2001 From: Wolfgang Link Date: Wed, 16 May 2018 13:46:42 +0200 Subject: [PATCH] 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. --- PVE/Storage/CIFSPlugin.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm index 724fb1f..cb7c844 100644 --- a/PVE/Storage/CIFSPlugin.pm +++ b/PVE/Storage/CIFSPlugin.pm @@ -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;},