Ensure we only return NT_STATUS_DELETE_PENDING if the share modes are valid.
authorJeremy Allison <jra@samba.org>
Tue, 22 May 2012 19:28:04 +0000 (12:28 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 25 May 2012 16:19:38 +0000 (09:19 -0700)
Ensure we only return *file_existed = true if there were valid share modes.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/open.c

index 774b5fc93806b06b1836b1d0ff9dd36988256ab6..9042e90a84a82c7ac71ca6ec0f616d9369024bcf 100644 (file)
@@ -984,12 +984,23 @@ static NTSTATUS open_mode_check(connection_struct *conn,
                return NT_STATUS_OK;
        }
 
-       *file_existed = True;
-
        /* A delete on close prohibits everything */
 
        if (is_delete_on_close_set(lck, name_hash)) {
-               return NT_STATUS_DELETE_PENDING;
+               /*
+                * Check the delete on close token
+                * is valid. It could have been left
+                * after a server crash.
+                */
+               for(i = 0; i < lck->data->num_share_modes; i++) {
+                       if (!share_mode_stale_pid(lck->data, i)) {
+
+                               *file_existed = true;
+
+                               return NT_STATUS_DELETE_PENDING;
+                       }
+               }
+               return NT_STATUS_OK;
        }
 
        if (is_stat_open(access_mask)) {
@@ -1029,10 +1040,16 @@ static NTSTATUS open_mode_check(connection_struct *conn,
                                continue;
                        }
 
+                       *file_existed = true;
+
                        return NT_STATUS_SHARING_VIOLATION;
                }
        }
 
+       if (lck->data->num_share_modes != 0) {
+               *file_existed = true;
+       }
+
        return NT_STATUS_OK;
 }