summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerb Lewis <herb@samba.org>2002-01-04 22:08:40 +0000
committerHerb Lewis <herb@samba.org>2002-01-04 22:08:40 +0000
commit287d2a3f1f52c5a08e530947f0a610e2b51bbee0 (patch)
treeed996084fa4915f3a54dd21cd35bb588c6ff0596
parentd05966d4cb9a95ef0cf0d47e79ebc5f10459da79 (diff)
downloadsamba-287d2a3f1f52c5a08e530947f0a610e2b51bbee0.tar.gz
samba-287d2a3f1f52c5a08e530947f0a610e2b51bbee0.tar.xz
samba-287d2a3f1f52c5a08e530947f0a610e2b51bbee0.zip
truncate dns name to 15 characters so columns are not messed up.
try smbclient on ip address if we didn't get a netbios name
-rwxr-xr-xpackaging/SGI/findsmb54
1 files changed, 26 insertions, 28 deletions
diff --git a/packaging/SGI/findsmb b/packaging/SGI/findsmb
index 7216323c82b..0546e379d1d 100755
--- a/packaging/SGI/findsmb
+++ b/packaging/SGI/findsmb
@@ -47,7 +47,7 @@ open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*'|") ||
# print header info
-print "\nIP ADDR NETBIOS NAME WORKGROUP/OS/VERSION $BCAST\n";
+print "\nIP ADDR NETBIOS NAME WORKGROUP/OS/VERSION $BCAST\n";
print "---------------------------------------------------------------------\n";
foreach $ip (@ipaddrs) # loop through each IP address found
@@ -61,9 +61,9 @@ foreach $ip (@ipaddrs) # loop through each IP address found
@nmblookup = <NMBLOOKUP>;
close NMBLOOKUP;
-# get the first <00> name
+# get the first non group <00> name
- @name = grep(/<00> - /,@nmblookup);
+ @name = grep(/<00> - /,@nmblookup);
$_ = @name[0];
if (not $_) {
# try without the -r option
@@ -74,17 +74,26 @@ foreach $ip (@ipaddrs) # loop through each IP address found
@name = grep(/<00> - /,@nmblookup);
$_ = @name[0];
}
- if ($_) { # we have a netbios name
- if (/GROUP/) { # is it a group name
- ($name, $aliases, $type, $length, @addresses) =
- gethostbyaddr(pack('C4',split('\.',$ip)),2);
- if (! $name) { # could not get name
- $name = "unknown nis name";
- }
- } else {
- /(\S+)/;
- $name = $1;
+ /(\S+)/;
+ $name = $1;
+
+ if (not $name) { # no netbios name found
+# try getting the host name
+ ($name, $aliases, $type, $length, @addresses) =
+ gethostbyaddr(pack('C4',split('\.',$ip)),2);
+ if (! $name) { # could not get name
+ $name = "unknown name";
}
+ if (length($name) > 15) {
+ $name = substr($name,0,15);
+ }
+# do an smbclient command on the ip address
+
+ open(SMB,"$SAMBABIN/smbclient -N -L '$ip' -I $ip -U% |") ||
+ die("Can't do smbclient command.\n");
+ @smb = <SMB>;
+ close SMB;
+ } else { # netbios name found
# do an smbclient command on the netbios name.
@@ -92,7 +101,8 @@ foreach $ip (@ipaddrs) # loop through each IP address found
die("Can't do smbclient command.\n");
@smb = <SMB>;
close SMB;
-
+ }
+ {
if ($DEBUG) { # if -d flag print results of nmblookup and smbclient
print "===============================================================\n";
print @nmblookup;
@@ -131,20 +141,8 @@ foreach $ip (@ipaddrs) # loop through each IP address found
# line up info in 3 columns
- print "$ip".' 'x(16-length($ip))."$name".' 'x(14-length($name))."$master"."$_\n";
+ print "$ip".' 'x(16-length($ip))."$name".' 'x(16-length($name))."$master"."$_\n";
- } else { # no netbios name found
-# try getting the host name
- ($name, $aliases, $type, $length, @addresses) =
- gethostbyaddr(pack('C4',split('\.',$ip)),2);
- if (! $name) { # could not get name
- $name = "unknown nis name";
- }
- if ($DEBUG) { # if -d flag print results of nmblookup
- print "===============================================================\n";
- print @nmblookup;
- }
- print "$ip".' 'x(16-length($ip))."$name\n";
- }
+ }
}