[PATCH] findsmb

Alexander Bokovoy a.bokovoy at sam-solutions.net
Fri Jan 10 14:36:00 GMT 2003


Greetings!

I propose to make an optional argument '-r' for findsmb utility to pass
'-r' option to nmblookup optionally and default to omit it. The reason is
to have findsmb working more user-friendly in contemporary office
environments where Windows 95/98 boxes are rare and also to allow usage of
the utility under non-priviledged accounts when Windows95/98 boxes are in
minority or even absent in network neighbourhood.

An attached patch provides this change for HEAD together with
documentation changes.

-- 
/ Alexander Bokovoy
---
Don't get to bragging.
-------------- next part --------------
Index: docs/docbook/manpages/findsmb.1.sgml
===================================================================
RCS file: /cvsroot/samba/docs/docbook/manpages/findsmb.1.sgml,v
retrieving revision 1.4
diff -u -r1.4 findsmb.1.sgml
--- docs/docbook/manpages/findsmb.1.sgml	18 Oct 2002 22:16:08 -0000	1.4
+++ docs/docbook/manpages/findsmb.1.sgml	10 Jan 2003 14:21:00 -0000
@@ -40,6 +40,15 @@
 
 	<variablelist>
 		<varlistentry>
+		<term>-r</term>
+		<listitem><para>Controls whether <command>findsmb</command> takes
+		bugs in Windows95 into account when trying to find a Netbios name
+		registered of the remote machine. This option is disabled by default
+		because it is specific to Windows 95 and Windows 95 machines only. 
+		If set, <ulink url="nmblookup.1.html"><command>nmblookup</command></ulink>
+		will be called with <constant>-B<constant> option.</para></listitem>
+		</varlistentry>
+		<varlistentry>
 		<term>subnet broadcast address</term>
 		<listitem><para>Without this option, <command>findsmb
 		</command> will probe the subnet of the machine where 
@@ -66,15 +75,17 @@
 	not show any information about the operating system or server 
 	version.</para>
 
-	<para>The command must be run on a system without <ulink
+	<para>The command with <constant>-r</constant> option
+	must be run on a system without <ulink
 	url="nmbd.8.html"><command>nmbd</command></ulink> running. 
 	If <command>nmbd</command> is running on the system, you will 
 	only  get the IP address and the DNS name of the machine. To 
 	get proper responses  from Windows 95 and Windows 98 machines, 
-	the command must be run as root. </para>
+	the command must be run as root and with <constant>-r</constant>
+	option on a machine without <command>nmbd</command> running.</para>
 
-	<para>For example, running <command>findsmb</command> on a machine 
-	without <command>nmbd</command> running would yield output similar
+	<para>For example, running <command>findsmb</command> without 
+	<constant>-r</constant> option set would yield output similar
 	to the following</para>
 
 	<screen><computeroutput>
Index: source/script/findsmb.in
===================================================================
RCS file: /cvsroot/samba/source/script/findsmb.in,v
retrieving revision 1.2
diff -u -r1.2 findsmb.in
--- source/script/findsmb.in	9 May 2002 13:52:06 -0000	1.2
+++ source/script/findsmb.in	10 Jan 2003 14:21:05 -0000
@@ -5,7 +5,7 @@
 # run as root to get correct info from WIN95 clients.
 #
 # syntax:
-#    findsmb [subnet broadcast address]
+#    findsmb [-d|-D] [-r] [subnet broadcast address]
 #
 # with no agrument it will list machines on the current subnet
 #
@@ -13,21 +13,28 @@
 # local master browsers for that workgroup. There will be an "*" in front
 # of the workgroup name for machines that are the domain master browser for
 # that workgroup.
+# 
+# Options:
+#
+# -d|-D		enable debug
+# -r		add -r option to nmblookup when finding netbios name
 #
 
 $SAMBABIN = "@prefix@/bin";
 
-for ($i = 0; $i < 2; $i++) {	# test for -d option and broadcast address
+for ($i = 0; $i < 2; $i++) {	# test for -d and -r options
   $_ = shift;
   if (m/-d|-D/) {
     $DEBUG = 1;
-  } else  {
-    if ($_) {
-      $BCAST = "-B $_";
-    }
+  } else (m/-r/) {
+    $R_OPTION = "-r";
   }
 }
 
+if ($_) {			# set broadcast address if it was specified
+      $BCAST = "-B $_";
+}
+
 sub ipsort			# do numeric sort on last field of IP address
 {
   @t1 = split(/\./,$a);
@@ -56,7 +63,7 @@
 
 # find the netbios names registered by each machine
 
-  open(NMBLOOKUP,"$SAMBABIN/nmblookup -r -A $ip|") || 
+  open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip|") || 
 	die("Can't get nmb name list.\n");
   @nmblookup = <NMBLOOKUP>;
   close NMBLOOKUP;


More information about the samba-technical mailing list