summaryrefslogtreecommitdiff
path: root/source3/smbd/sesssetup.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-11-25 12:31:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:34 -0500
commit1bfb5b734b0d5e1bc093bb43513729ed458fe372 (patch)
treee6315c8309c3ee1330813a9a1530050df1825b9a /source3/smbd/sesssetup.c
parented6936598ef73f1fc46801fd5dc7765d65032fa1 (diff)
downloadsamba-1bfb5b734b0d5e1bc093bb43513729ed458fe372.tar.gz
samba-1bfb5b734b0d5e1bc093bb43513729ed458fe372.tar.bz2
samba-1bfb5b734b0d5e1bc093bb43513729ed458fe372.zip
r11909: 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 (This used to be commit 5629ca16235f0aa21fea3afd9e414309e4e1374e)
Diffstat (limited to 'source3/smbd/sesssetup.c')
-rw-r--r--source3/smbd/sesssetup.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 8aa046b85a..a22a575c76 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -744,6 +744,29 @@ static int reply_sesssetup_and_X_spnego(connection_struct *conn, char *inbuf,
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 @@ static void setup_new_vc_session(void)
conn_close_all();
invalidate_all_vuids();
#endif
+ if (lp_reset_on_zero_vc()) {
+ session_traverse(shutdown_other_smbds, client_addr());
+ }
}
/****************************************************************************