r10744: Fix for the second incarnation of bug #3088, pushed by Alex Masterov
authorJeremy Allison <jra@samba.org>
Wed, 5 Oct 2005 22:41:16 +0000 (22:41 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:04:51 +0000 (11:04 -0500)
<alex@infobit.ru>. A fcbopen specific part of the code was erroneously
being called as part of the mainline open. Note, that this patch
superceeds and replaces the fix that Volker added for this bug
(which he added a Samba4 torture test for ) :

"Fix a race condition in Samba 3. If two files are opened simultaneously with
NTCREATEX_DISP_CREATE (create if not exists, else fail) they might end up with
two or more times NT_STATUS_OK as EEXIST is not correctly handled."

Jeremy.
(This used to be commit 5d7ab9a17e793c05409a16675ac2aa2861c4f89e)

source3/smbd/open.c

index 56d31c69409c4971feb9ac23d2b345986efef110..a8fb8ed38f72cf1bf88459f8fcf7725788142105 100644 (file)
@@ -1507,22 +1507,6 @@ files_struct *open_file_ntcreate(connection_struct *conn,
        fsp_open = open_file(fsp,conn,fname,psbuf,flags|flags2,unx_mode,
                             access_mask);
 
-       if (!fsp_open && (flags2 & O_EXCL) && (errno == EEXIST)) {
-               /*
-                * Two smbd's tried to open exclusively, but only one of them
-                * succeeded.
-                */
-               file_free(fsp);
-               return NULL;
-       }
-
-       if (!fsp_open && (flags == O_RDWR) && (errno != ENOENT)) {
-               if((fsp_open = open_file(fsp,conn,fname,psbuf,
-                                        O_RDONLY,unx_mode,access_mask)) == True) {
-                       flags = O_RDONLY;
-               }
-       }
-
        if (!fsp_open) {
                if (lck != NULL) {
                        talloc_free(lck);