Cross-Subnet-Browsing

Jürgen Appel jappel at linux01.gwdg.de
Sun Apr 14 15:32:01 GMT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Here at Göttingen University we networked all dormitories and build up
a large samba-network.

Our WINs server is a linux machine running samba. Also in each dormitoriy
 (=each subnet) there is a SAMBA machine running as DMB 
(and most time also as LMB).

Two issues came up be solved, which needed modification of samba code:

a)
First we encountered the problem of never disappering ghost-workgroups
described in man smb.conf which was solved by the introducion of the new
"enhanced browsing" option. This option disables transfering the list of 
workgroups from one DMB to another (without ever making them invalid 
by e.g. a TTL counter).

But setting enhanced browsing = True  also made the DMBs stop looking 
for other workgroups by resolving *#1b via the WINS server. So what was
needed was the possibility to partly disable enhanced browsing so that
only the call to "sync_all_dmbs" would be avoided.

The appended patch does this for us by making it possible to set 
enhanced browsing= Partly

This patch is necessary for each DMB. 

b)
Also we noticed that it is very comfortable to browse the "Network 
Neighborhood" by linux programs like the (KDE-) konqueror which 
make use of libsmb.

But when looking up a master browser for a workgroup WORKGROUP 
to get the names of all computers within that workgroup libsmb only 
searches for WORKGROUP#1d  (the LMB-group-tag) and only in its own 
subnet, because there are no WORKGROUP#1d-entries in the WINS-database.

If, like in our case, there are not LMBs of every workgroup in every subnet, these 
searches will sometimes fail. So I made libsmb first look whether there is a DMB
 for the workgroup in question (lookup WORKGROUP#1B via WINS e.g.). 
If there is, ask this host about its workgroup members, else try the conventional
 way by finding a LMB for WORKGROUP without WINS.

This made it possible to browse even workgroups which don't have a LMB in my subnet.
This change is necessary for everyone who wants to browse the etwork neighborhood comfortably.



Maybe someone finds these changes worthy and enters them to the samba CVS tree.

Jürgen

Here the changes:

diff -uNr samba-2.2.3a_old/source/libsmb/libsmbclient.c samba-2.2.3a/source/libsmb/libsmbclient.c
- --- samba-2.2.3a_old/source/libsmb/libsmbclient.c	Sun Feb  3 01:46:44 2002
+++ samba-2.2.3a/source/libsmb/libsmbclient.c	Sun Apr 14 16:22:17 2002
@@ -79,7 +79,7 @@
  * We accept smb://[[[domain;]user[:password@]]server[/share[/path[/file]]]]
  * 
  * smb://       means show all the workgroups
- - * smb://name/  means, if name<1D> exists, list servers in workgroup,
+ * smb://name/  means, if name<1B> or name<1D> exists, list servers in workgroup,
  *              else, if name<20> exists, list all shares for server ...
  */
 
@@ -1591,12 +1591,13 @@
 
 		/* We have server and share and path empty ... so list the workgroups */
 
- -		if (!resolve_name(lp_workgroup(), &rem_ip, 0x1d)) {
- -      
- -			errno = EINVAL;  /* Something wrong with smb.conf? */
- -			return -1;
- -
- -		}
+		/* first try to get the DMB of our Workgroup */
+		/* if this fails, ask for the LMB */
+		if (! (resolve_name(lp_workgroup(), &rem_ip, 0x1b) || 
+		       resolve_name(lp_workgroup(), &rem_ip, 0x1d)) ) {		    
+		  errno = EINVAL;  /* Something wrong with smb.conf? */
+		  return -1;		    
+		}	       
 
 		smbc_file_table[slot]->dir_type = SMBC_WORKGROUP;
 
@@ -1604,7 +1605,7 @@
 
 		if (!name_status_find("*", 0, 0, rem_ip, server)) {
 
- -			DEBUG(0,("Could not get the name of local master browser for server %s\n", server));
+			DEBUG(0,("Could not get the name of domain/local master browser for server %s\n", server));
 			errno = EINVAL;
 			return -1;
 
@@ -1659,11 +1660,12 @@
 	
 			}
 
- -			/* Check to see if <server><1D> translates, or <server><20> translates */
+			/* Check to see if <server><1B> or <server><1D> translates, or <server><20> translates */
 			/* However, we check to see if <server> is an IP address first */
 
 			if (!is_ipaddress(server) &&  /* Not an IP addr so check next */
- -			    resolve_name(server, &rem_ip, 0x1d)) { /* Found LMB */
+			    (resolve_name(server, &rem_ip, 0x1b) || /* found DMB */
+			     resolve_name(server, &rem_ip, 0x1d) )) { /* Found LMB */
 				pstring buserver;
 
 				smbc_file_table[slot]->dir_type = SMBC_SERVER;
@@ -1675,7 +1677,7 @@
 
 				if (!name_status_find("*", 0, 0, rem_ip, buserver)) {
 
- -					DEBUG(0, ("Could not get name of local master browser for server %s\n", server));
+					DEBUG(0, ("Could not get name of domain/local master browser for server %s\n", server));
 					errno = EPERM;  /* FIXME, is this correct */
 					return -1;
 
diff -uNr samba-2.2.3a_old/source/nmbd/nmbd.c samba-2.2.3a/source/nmbd/nmbd.c
- --- samba-2.2.3a_old/source/nmbd/nmbd.c	Sun Feb  3 01:46:44 2002
+++ samba-2.2.3a/source/nmbd/nmbd.c	Sun Apr 14 15:34:53 2002
@@ -479,7 +479,7 @@
     /*
      * regularly sync with any other DMBs we know about 
      */
- -    if (lp_enhanced_browsing()) {
+    if (lp_enhanced_browsing()==True) {
 	    sync_all_dmbs(t);
     }
 
diff -uNr samba-2.2.3a_old/source/param/loadparm.c samba-2.2.3a/source/param/loadparm.c
- --- samba-2.2.3a_old/source/param/loadparm.c	Sun Feb  3 01:46:46 2002
+++ samba-2.2.3a/source/param/loadparm.c	Sun Apr 14 15:36:51 2002
@@ -637,6 +637,19 @@
 	{-1, NULL}
 };
 
+static struct enum_list enum_bool_partly[] = {
+	{False, "False"},
+	{False, "No"},
+	{False, "0"},
+	{True, "True"},
+	{True, "Yes"},
+	{True, "1"},
+	{3, "Partly"},
+	{-1, NULL}
+};
+
+
+
 /* 
    Do you want session setups at user level security with a invalid
    password to be rejected or allowed in as guest? WinNT rejects them
@@ -951,7 +964,7 @@
 	{"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, 0},
 	{"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, FLAG_BASIC | FLAG_SHARE | FLAG_PRINT},
 	{"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, 0},
- -	{"enhanced browsing", P_BOOL, P_GLOBAL, &Globals.enhanced_browsing, NULL, NULL},
+	{"enhanced browsing", P_ENUM, P_GLOBAL, &Globals.enhanced_browsing, NULL, enum_bool_partly},
 
 	{"WINS Options", P_SEP, P_SEPARATOR},
 	{"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, 0},
@@ -1597,9 +1610,9 @@
 FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth)
 FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
- -FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
 FN_GLOBAL_BOOL(lp_unix_extensions, &Globals.bUnixExtensions)
+FN_GLOBAL_INTEGER(lp_enhanced_browsing, &Globals.enhanced_browsing)
 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)


- -- 
GPG key: 
http://pgpkeys.mit.edu:11371/pks/lookup?op=get&search=jappel%40linux01.gwdg.de

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjy6AxQACgkQ7h8HhBg+h9X3tACgi/dLHPSbhKKLAwXQyLWsAfje
gccAn3R9wPxVqgtHL2Iufz6v1iJUy3ms
=YChO
-----END PGP SIGNATURE-----




More information about the samba-technical mailing list