Implement SMBexit properly. Found by Samba4 tester. You must do a make
authorJeremy Allison <jra@samba.org>
Tue, 19 Aug 2003 01:53:45 +0000 (01:53 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 19 Aug 2003 01:53:45 +0000 (01:53 +0000)
clean proto all; after this commit.
Jeremy.

source/include/smb.h
source/smbd/files.c
source/smbd/open.c
source/smbd/reply.c

index 2cafd1b9b1ef6e4c3c50397282f532158755c89f..61cda9465cd4aae84035e8a535b10db2f4130b13 100644 (file)
@@ -392,6 +392,7 @@ typedef struct files_struct
        SMB_BIG_UINT initial_allocation_size; /* Faked up initial allocation on disk. */
        SMB_BIG_UINT position_information;
        mode_t mode;
+       uint16 file_pid;
        uint16 vuid;
        write_bmpx_struct *wbmpx_ptr;
        write_cache *wcp;
index 186fa96d7d1eaec356160ba68583535b39abddf3..1fe6f250e526b3803429fcc00aede6b07f6feaad 100644 (file)
@@ -142,6 +142,22 @@ void file_close_conn(connection_struct *conn)
        }
 }
 
+/****************************************************************************
+ Close all open files for a pid.
+****************************************************************************/
+
+void file_close_pid(uint16 smbpid)
+{
+       files_struct *fsp, *next;
+       
+       for (fsp=Files;fsp;fsp=next) {
+               next = fsp->next;
+               if (fsp->file_pid == smbpid) {
+                       close_file(fsp,False); 
+               }
+       }
+}
+
 /****************************************************************************
  Initialise file structures.
 ****************************************************************************/
index 06f1ddfcf2dc9713115f6a608cd349f48b484ce4..71af23aaf928b5b99ff85a6dc6b1faa4b3f6469e 100644 (file)
@@ -23,6 +23,7 @@
 
 extern userdom_struct current_user_info;
 extern uint16 global_oplock_port;
+extern uint16 global_smbpid;
 extern BOOL global_client_failed_oplock_break;
 
 /****************************************************************************
@@ -226,6 +227,7 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
        fsp->inode = psbuf->st_ino;
        fsp->dev = psbuf->st_dev;
        fsp->vuid = current_user.vuid;
+       fsp->file_pid = global_smbpid;
        fsp->size = psbuf->st_size;
        fsp->can_lock = True;
        fsp->can_read = ((flags & O_WRONLY)==0);
@@ -1361,6 +1363,7 @@ files_struct *open_directory(connection_struct *conn, char *fname, SMB_STRUCT_ST
        fsp->dev = psbuf->st_dev;
        fsp->size = psbuf->st_size;
        fsp->vuid = current_user.vuid;
+       fsp->file_pid = global_smbpid;
        fsp->can_lock = True;
        fsp->can_read = False;
        fsp->can_write = False;
@@ -1423,6 +1426,7 @@ files_struct *open_file_stat(connection_struct *conn, char *fname, SMB_STRUCT_ST
        fsp->dev = (SMB_DEV_T)0;
        fsp->size = psbuf->st_size;
        fsp->vuid = current_user.vuid;
+       fsp->file_pid = global_smbpid;
        fsp->can_lock = False;
        fsp->can_read = False;
        fsp->can_write = False;
index 9577375475d8074852a636e8310c317362bda633..5f2dd9123272dd25f716e326e9f2cbee14f1d3a1 100644 (file)
@@ -2394,6 +2394,9 @@ int reply_exit(connection_struct *conn,
 {
        int outsize;
        START_PROFILE(SMBexit);
+
+       file_close_pid(SVAL(inbuf,smb_pid));
+
        outsize = set_message(outbuf,0,0,True);
 
        DEBUG(3,("exit\n"));