svn commit: samba r11909 - branches/SAMBA_3_0/source/param branches/SAMBA_3_0/source/smbd trunk/source/param trunk/source/smbd

vlendec at samba.org vlendec at samba.org
Fri Nov 25 12:31:42 GMT 2005


Author: vlendec
Date: 2005-11-25 12:31:40 +0000 (Fri, 25 Nov 2005)
New Revision: 11909

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11909

Log:
Implement 'reset on zero vc'. This kills other connections when a session
setup comes in with the vc (virtual connection) field set to zero. This is
done by Windows, probably you can tweak that by some registry key.

	This boolean option controls whether an incoming session setup
	should kill other connections coming from the same IP. This matches
        the default Windows 2003 behaviour.

	Setting this parameter to yes becomes necessary when you have a flaky
	network and windows decides to reconnect while the old connection
	still has files with share modes open. These files become inaccessible
	over the new connection.

	The client sends a zero VC on the new connection, and Windows 2003
	kills all other connections coming from the same IP. This way the
	locked files are accessible again.

	Please be aware that enabling this option will kill connections behind
	a masquerading router.


Volker

Modified:
   branches/SAMBA_3_0/source/param/loadparm.c
   branches/SAMBA_3_0/source/smbd/session.c
   branches/SAMBA_3_0/source/smbd/sesssetup.c
   trunk/source/param/loadparm.c
   trunk/source/smbd/session.c
   trunk/source/smbd/sesssetup.c


Changeset:
Modified: branches/SAMBA_3_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_3_0/source/param/loadparm.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ branches/SAMBA_3_0/source/param/loadparm.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -301,6 +301,7 @@
 	int name_cache_timeout;
 	int client_signing;
 	int server_signing;
+	BOOL bResetOnZeroVC;
 	param_opt_struct *param_opt;
 }
 global;
@@ -951,6 +952,7 @@
 	{"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_ADVANCED}, 
 	{"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_ADVANCED}, 
 	{"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED}, 
+	{"reset on zero vc", P_BOOL, P_GLOBAL, &Globals.bResetOnZeroVC, NULL, NULL, FLAG_ADVANCED}, 
 
 	{"acl compatibility", P_STRING, P_GLOBAL, &Globals.szAclCompat, handle_acl_compatibility,  NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
 	{"defer sharing violations", P_BOOL, P_GLOBAL, &Globals.bDeferSharingViolations, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
@@ -1522,6 +1524,7 @@
 	Globals.bUseMmap = True;
 #endif
 	Globals.bUnixExtensions = True;
+	Globals.bResetOnZeroVC = False;
 
 	/* hostname lookups can be very expensive and are broken on
 	   a large number of sites (tridge) */
@@ -1809,6 +1812,7 @@
 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
 
 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
+FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)

Modified: branches/SAMBA_3_0/source/smbd/session.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/session.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ branches/SAMBA_3_0/source/smbd/session.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -198,7 +198,8 @@
 	tdb_delete(tdb, key);
 }
 
-static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state)
+BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *),
+		      void *state)
 {
 	if (!session_init()) {
 		DEBUG(3, ("No tdb opened\n"));

Modified: branches/SAMBA_3_0/source/smbd/sesssetup.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/sesssetup.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ branches/SAMBA_3_0/source/smbd/sesssetup.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -744,6 +744,29 @@
  a new session setup with VC==0 is ignored.
 ****************************************************************************/
 
+static int shutdown_other_smbds(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
+				void *p)
+{
+	struct sessionid *sessionid = (struct sessionid *)dbuf.dptr;
+	const char *ip = (const char *)p;
+
+	if (!process_exists(pid_to_procid(sessionid->pid))) {
+		return 0;
+	}
+
+	if (sessionid->pid == sys_getpid()) {
+		return 0;
+	}
+
+	if (strcmp(ip, sessionid->ip_addr) != 0) {
+		return 0;
+	}
+
+	message_send_pid(pid_to_procid(sessionid->pid), MSG_SHUTDOWN,
+			 NULL, 0, True);
+	return 0;
+}
+
 static void setup_new_vc_session(void)
 {
 	DEBUG(2,("setup_new_vc_session: New VC == 0, if NT4.x compatible we would close all old resources.\n"));
@@ -751,6 +774,9 @@
 	conn_close_all();
 	invalidate_all_vuids();
 #endif
+	if (lp_reset_on_zero_vc()) {
+		session_traverse(shutdown_other_smbds, client_addr());
+	}
 }
 
 /****************************************************************************

Modified: trunk/source/param/loadparm.c
===================================================================
--- trunk/source/param/loadparm.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ trunk/source/param/loadparm.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -301,6 +301,7 @@
 	int name_cache_timeout;
 	int client_signing;
 	int server_signing;
+	BOOL bResetOnZeroVC;
 	param_opt_struct *param_opt;
 }
 global;
@@ -951,6 +952,7 @@
 	{"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, FLAG_ADVANCED}, 
 	{"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, FLAG_ADVANCED}, 
 	{"disable netbios", P_BOOL, P_GLOBAL, &Globals.bDisableNetbios, NULL, NULL, FLAG_ADVANCED}, 
+	{"reset on zero vc", P_BOOL, P_GLOBAL, &Globals.bResetOnZeroVC, NULL, NULL, FLAG_ADVANCED}, 
 
 	{"acl compatibility", P_STRING, P_GLOBAL, &Globals.szAclCompat, handle_acl_compatibility,  NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
 	{"defer sharing violations", P_BOOL, P_GLOBAL, &Globals.bDeferSharingViolations, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL},
@@ -1522,6 +1524,7 @@
 	Globals.bUseMmap = True;
 #endif
 	Globals.bUnixExtensions = True;
+	Globals.bResetOnZeroVC = False;
 
 	/* hostname lookups can be very expensive and are broken on
 	   a large number of sites (tridge) */
@@ -1809,6 +1812,7 @@
 FN_GLOBAL_LIST(lp_eventlog_list, &Globals.szEventLogs)
 
 FN_GLOBAL_BOOL(lp_disable_netbios, &Globals.bDisableNetbios)
+FN_GLOBAL_BOOL(lp_reset_on_zero_vc, &Globals.bResetOnZeroVC)
 FN_GLOBAL_BOOL(lp_ms_add_printer_wizard, &Globals.bMsAddPrinterWizard)
 FN_GLOBAL_BOOL(lp_dns_proxy, &Globals.bDNSproxy)
 FN_GLOBAL_BOOL(lp_wins_support, &Globals.bWINSsupport)

Modified: trunk/source/smbd/session.c
===================================================================
--- trunk/source/smbd/session.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ trunk/source/smbd/session.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -198,7 +198,8 @@
 	tdb_delete(tdb, key);
 }
 
-static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state)
+BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *),
+		      void *state)
 {
 	if (!session_init()) {
 		DEBUG(3, ("No tdb opened\n"));

Modified: trunk/source/smbd/sesssetup.c
===================================================================
--- trunk/source/smbd/sesssetup.c	2005-11-25 12:03:40 UTC (rev 11908)
+++ trunk/source/smbd/sesssetup.c	2005-11-25 12:31:40 UTC (rev 11909)
@@ -744,6 +744,29 @@
  a new session setup with VC==0 is ignored.
 ****************************************************************************/
 
+static int shutdown_other_smbds(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
+				void *p)
+{
+	struct sessionid *sessionid = (struct sessionid *)dbuf.dptr;
+	const char *ip = (const char *)p;
+
+	if (!process_exists(pid_to_procid(sessionid->pid))) {
+		return 0;
+	}
+
+	if (sessionid->pid == sys_getpid()) {
+		return 0;
+	}
+
+	if (strcmp(ip, sessionid->ip_addr) != 0) {
+		return 0;
+	}
+
+	message_send_pid(pid_to_procid(sessionid->pid), MSG_SHUTDOWN,
+			 NULL, 0, True);
+	return 0;
+}
+
 static void setup_new_vc_session(void)
 {
 	DEBUG(2,("setup_new_vc_session: New VC == 0, if NT4.x compatible we would close all old resources.\n"));
@@ -751,6 +774,9 @@
 	conn_close_all();
 	invalidate_all_vuids();
 #endif
+	if (lp_reset_on_zero_vc()) {
+		session_traverse(shutdown_other_smbds, client_addr());
+	}
 }
 
 /****************************************************************************



More information about the samba-cvs mailing list