diff options
author | Herb Lewis <herb@samba.org> | 2001-11-19 19:02:56 +0000 |
---|---|---|
committer | Herb Lewis <herb@samba.org> | 2001-11-19 19:02:56 +0000 |
commit | 62b7bf71a92dfc96992d323dba5bee9b42c9b54b (patch) | |
tree | c909710f8df38ff5db1c01001b459243dd8366e4 | |
parent | 0b3a2509d9d58382a78ec7727e0de191163dad9f (diff) | |
download | samba-62b7bf71a92dfc96992d323dba5bee9b42c9b54b.tar.gz samba-62b7bf71a92dfc96992d323dba5bee9b42c9b54b.tar.xz samba-62b7bf71a92dfc96992d323dba5bee9b42c9b54b.zip |
fixes based on patch from lars@segv.dk
1. localhost does not respond to 'nmblookup -r'. Therefore do a nmblookup
with '-r' first and if no response, do it again without '-r' for localhost.
2. NetBIOS names containing '&' makes 'findsmb -d' exit in the smbclient
command. Adding a '' around $name fixes this.
-rwxr-xr-x | packaging/Caldera/OpenLinux/findsmb | 15 | ||||
-rwxr-xr-x | packaging/Caldera/OpenServer/findsmb | 13 | ||||
-rwxr-xr-x | packaging/Caldera/UnixWare/findsmb | 15 | ||||
-rwxr-xr-x | packaging/Mandrake/findsmb | 15 | ||||
-rwxr-xr-x | packaging/PHT/TurboLinux/findsmb | 15 | ||||
-rwxr-xr-x | packaging/RedHat/findsmb | 15 | ||||
-rwxr-xr-x | packaging/SGI/findsmb | 11 |
7 files changed, 81 insertions, 18 deletions
diff --git a/packaging/Caldera/OpenLinux/findsmb b/packaging/Caldera/OpenLinux/findsmb index 986c2481779..fb178f91c1c 100755 --- a/packaging/Caldera/OpenLinux/findsmb +++ b/packaging/Caldera/OpenLinux/findsmb @@ -63,8 +63,17 @@ foreach $ip (@ipaddrs) # loop through each IP address found # get the first <00> name - @name = grep(/<00>/,@nmblookup); + @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/Caldera/OpenServer/findsmb b/packaging/Caldera/OpenServer/findsmb index bb91c784b89..5d399123952 100755 --- a/packaging/Caldera/OpenServer/findsmb +++ b/packaging/Caldera/OpenServer/findsmb @@ -65,6 +65,15 @@ foreach $ip (@ipaddrs) # loop through each IP address found @name = grep(/<00>/,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/Caldera/UnixWare/findsmb b/packaging/Caldera/UnixWare/findsmb index bb91c784b89..4871b24ea4b 100755 --- a/packaging/Caldera/UnixWare/findsmb +++ b/packaging/Caldera/UnixWare/findsmb @@ -63,8 +63,17 @@ foreach $ip (@ipaddrs) # loop through each IP address found # get the first <00> name - @name = grep(/<00>/,@nmblookup); + @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/Mandrake/findsmb b/packaging/Mandrake/findsmb index 986c2481779..fb178f91c1c 100755 --- a/packaging/Mandrake/findsmb +++ b/packaging/Mandrake/findsmb @@ -63,8 +63,17 @@ foreach $ip (@ipaddrs) # loop through each IP address found # get the first <00> name - @name = grep(/<00>/,@nmblookup); + @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/PHT/TurboLinux/findsmb b/packaging/PHT/TurboLinux/findsmb index 986c2481779..fb178f91c1c 100755 --- a/packaging/PHT/TurboLinux/findsmb +++ b/packaging/PHT/TurboLinux/findsmb @@ -63,8 +63,17 @@ foreach $ip (@ipaddrs) # loop through each IP address found # get the first <00> name - @name = grep(/<00>/,@nmblookup); + @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/RedHat/findsmb b/packaging/RedHat/findsmb index 986c2481779..fb178f91c1c 100755 --- a/packaging/RedHat/findsmb +++ b/packaging/RedHat/findsmb @@ -63,8 +63,17 @@ foreach $ip (@ipaddrs) # loop through each IP address found # get the first <00> name - @name = grep(/<00>/,@nmblookup); + @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; @@ -95,7 +104,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found @info = grep(/OS=/,@smb); $_ = @info[0]; if ($_) { # we found response - s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter + s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter } else { # no OS= string in response (WIN95 client) diff --git a/packaging/SGI/findsmb b/packaging/SGI/findsmb index a48ec592e80..7216323c82b 100755 --- a/packaging/SGI/findsmb +++ b/packaging/SGI/findsmb @@ -65,6 +65,15 @@ foreach $ip (@ipaddrs) # loop through each IP address found @name = grep(/<00> - /,@nmblookup); $_ = @name[0]; + if (not $_) { +# try without the -r option + open(NMBLOOKUP,"$SAMBABIN/nmblookup -A $ip|") || + die("Can't get nmb name list.\n"); + @nmblookup = <NMBLOOKUP>; + close NMBLOOKUP; + @name = grep(/<00> - /,@nmblookup); + $_ = @name[0]; + } if ($_) { # we have a netbios name if (/GROUP/) { # is it a group name ($name, $aliases, $type, $length, @addresses) = @@ -79,7 +88,7 @@ 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% |") || + open(SMB,"$SAMBABIN/smbclient -N -L '$name' -I $ip -U% |") || die("Can't do smbclient command.\n"); @smb = <SMB>; close SMB; |