*** check_disk_smb 2005-06-08 11:09:01.720711352 -0500 --- check_disk_smb.ultra 2005-06-08 11:05:52.927412296 -0500 *************** *** 15,22 **** # allow setting of limits in MBytes or GBytes. Percentage settings for large # drives is a pain in the butt # 2-May-2002 - SGhosh fix for embedded perl # ! # $Id: check_disk_smb.pl,v 1.8.2.1 2003/07/02 15:52:23 tonvoon Exp $ # require 5.004; --- 15,24 ---- # allow setting of limits in MBytes or GBytes. Percentage settings for large # drives is a pain in the butt # 2-May-2002 - SGhosh fix for embedded perl + # 8-Jun-2005 - Andrey Warkentin + # Fixed the way smbclient gets called. The share path was malformed. # ! # $Id: check_disk_smb.pl,v 1.8.2.1 2005/06/08 10:44:21 root Exp $ # require 5.004; *************** *** 60,67 **** my $smbclient= "$utils::PATH_TO_SMBCLIENT " ; my $smbclientoptions=""; ! # Options checking ! ($opt_H) || ($opt_H = shift) || usage("Host name not specified\n"); my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/); ($host) || usage("Invalid host: $opt_H\n"); --- 62,68 ---- my $smbclient= "$utils::PATH_TO_SMBCLIENT " ; my $smbclientoptions=""; ! # Options checking. ($opt_H) || ($opt_H = shift) || usage("Host name not specified\n"); my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/); ($host) || usage("Invalid host: $opt_H\n"); *************** *** 105,111 **** # end of options checking - my $state = "OK"; my $answer = undef; my $res = undef; --- 106,111 ---- *************** *** 118,130 **** }; alarm($TIMEOUT); # Execute an "ls" on the share using smbclient program # get the results into $res if (defined($workgroup)) { ! $res = qx/$smbclient \/\/$host\/$share $pass -W $workgroup -U $user $smbclientoptions -c ls/; } else { ! print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose); ! $res = qx/$smbclient \/\/$host\/$share $pass -U $user $smbclientoptions -c ls/; } #Turn off alarm alarm(0); --- 118,149 ---- }; alarm($TIMEOUT); + # Check Samba version. Version 3 changed the way we pass the server path. + my $samba_ver = qx/$smbclient --version 2>&1/; + if($samba_ver =~ /Version (\d)/) + { + $samba_ver = $1; + } + + # Version 3 broke it all. + my $smbclient_part_cmd; + if($samba_ver == 3) + { + $smbclient_part_cmd = "$smbclient \\\\\\\\$host\\\\$share"; + } + else + { + $smbclient_part_cmd = "$smbclient \/\/$host\/$share"; + } + # Execute an "ls" on the share using smbclient program # get the results into $res if (defined($workgroup)) { ! print $smbclient_part_cmd . " $pass -W $workgroup -U $user $smbclientoptions -c ls\n" if ($verbose); ! $res = qx/$smbclient_part_cmd $pass -W $workgroup -U $user $smbclientoptions -c ls/; } else { ! print $smbclient_part_cmd . " $pass -U $user $smbclientoptions -c ls\n" if ($verbose); ! $res = qx/$smbclient_part_cmd $pass -U $user $smbclientoptions -c ls/; } #Turn off alarm alarm(0);