mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
fix some problems with the findsmb script due to changes in smbclient & nmblookup
(This used to be commit 50bb063f3ba0ce0f336bd9f1af3090839ee7b118)
This commit is contained in:
parent
f0441479f4
commit
605caa4172
@ -44,7 +44,7 @@ sub ipsort # do numeric sort on last field of IP address
|
||||
|
||||
# look for all machines that respond to a name lookup
|
||||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*'|") ||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*' --debuglevel=0|") ||
|
||||
die("Can't run nmblookup '*'.\n");
|
||||
|
||||
# get rid of all lines that are not a response IP address,
|
||||
@ -63,7 +63,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found
|
||||
|
||||
# find the netbios names registered by each machine
|
||||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip|") ||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip --debuglevel=0|") ||
|
||||
die("Can't get nmb name list.\n");
|
||||
@nmblookup = <NMBLOOKUP>;
|
||||
close NMBLOOKUP;
|
||||
@ -89,35 +89,37 @@ foreach $ip (@ipaddrs) # loop through each IP address found
|
||||
|
||||
# do an smbclient command on the netbios name.
|
||||
|
||||
open(SMB,"$SAMBABIN/smbclient -N -L $name -I $ip -U% |") ||
|
||||
die("Can't do smbclient command.\n");
|
||||
@smb = <SMB>;
|
||||
close SMB;
|
||||
if ( "$name" ) {
|
||||
open(SMB,"$SAMBABIN/smbclient -L $name -I $ip -N --debuglevel=1 2>&1 |") ||
|
||||
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;
|
||||
print @smb;
|
||||
}
|
||||
if ($DEBUG) { # if -d flag print results of nmblookup and smbclient
|
||||
print "===============================================================\n";
|
||||
#print @nmblookup;
|
||||
print @smb;
|
||||
}
|
||||
|
||||
# look for the OS= string
|
||||
# look for the OS= string
|
||||
|
||||
@info = grep(/OS=/,@smb);
|
||||
$_ = @info[0];
|
||||
if ($_) { # we found response
|
||||
s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
|
||||
@info = grep(/OS=/,@smb);
|
||||
$_ = @info[0];
|
||||
if ($_) { # we found response
|
||||
s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
|
||||
|
||||
} else { # no OS= string in response (WIN95 client)
|
||||
} else { # no OS= string in response (WIN95 client)
|
||||
|
||||
# for WIN95 clients get workgroup name from nmblookup response
|
||||
@name = grep(/<00> - <GROUP>/,@nmblookup);
|
||||
$_ = @name[0];
|
||||
if ($_) {
|
||||
# Same as before for space and characters
|
||||
/(.{1,15})\s+<00>\s+/;
|
||||
$_ = "[$1]";
|
||||
} else {
|
||||
$_ = "Unknown Workgroup";
|
||||
# for WIN95 clients get workgroup name from nmblookup response
|
||||
@name = grep(/<00> - <GROUP>/,@nmblookup);
|
||||
$_ = @name[0];
|
||||
if ($_) {
|
||||
# Same as before for space and characters
|
||||
/(.{1,15})\s+<00>\s+/;
|
||||
$_ = "[$1]";
|
||||
} else {
|
||||
$_ = "Unknown Workgroup";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user