summaryrefslogtreecommitdiffstats
path: root/web/attachments/144080-check_disk_smb.smbclient-args-patch
blob: 8886e0346b79526760fcb74d13f05fc6932d4f62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
*** 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);