bug in open_file_shared1? (samba-3.0alpha24)

Jeremy Allison jra at samba.org
Mon Jul 7 22:29:25 GMT 2003


On Mon, Jul 07, 2003 at 10:55:20PM +0300, Nadav Danieli wrote:
> At line 1027 in open.c open_mode_check is called with both dev and inode
> set to zero.
> That means, that 2 processes that try to open the same file at the same
> time, might do it even if their share modes conflict.
> The share entry is locked, and set correctly with the fsp, but the modes
> they will read are wrong (probably none ever.)
> 
> Please correct me if I'm wrong.

*VERY* good catch. Here is the patch I've committed.

Thanks,

	Jeremy.
-------------- next part --------------
Index: smbd/open.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/open.c,v
retrieving revision 1.115.2.21
diff -u -r1.115.2.21 open.c
--- smbd/open.c	3 Jul 2003 19:11:31 -0000	1.115.2.21
+++ smbd/open.c	7 Jul 2003 22:25:03 -0000
@@ -1024,6 +1024,16 @@
 
 	if (!file_existed) { 
 
+		/*
+		 * Now the file exists and fsp is successfully opened,
+		 * fsp->dev and fsp->inode are valid and should replace the
+		 * dev=0,inode=0 from a non existent file. Spotted by
+		 * Nadav Danieli <nadavd at exanet.com>. JRA.
+		 */
+
+		dev = fsp->dev;
+		inode = fsp->inode;
+
 		lock_share_entry_fsp(fsp);
 
 		num_share_modes = open_mode_check(conn, fname, dev, inode, 


More information about the samba-technical mailing list