[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4611-gc39c35f

Tim Prouty tprouty at samba.org
Wed Dec 10 03:56:24 GMT 2008


The branch, v3-3-test has been updated
       via  c39c35f3e67a726c6464c1497e46fe7a2eb3dc77 (commit)
       via  69a2b8ea06bf65109ed8a44df38e62bcbac7c4a9 (commit)
      from  7ef3e752bf56d130a242d6bb6e92fa76cae45fa0 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit c39c35f3e67a726c6464c1497e46fe7a2eb3dc77
Author: Tim Prouty <tprouty at samba.org>
Date:   Sat Dec 6 16:08:35 2008 -0800

    Fix a delete on close divergence from windows [2/2]
    
    This second patch cleans up by removing all of the code that is made
    obsolete by the first patch.  It should cause no functional changes.

commit 69a2b8ea06bf65109ed8a44df38e62bcbac7c4a9
Author: Tim Prouty <tprouty at samba.org>
Date:   Sun Dec 7 10:30:01 2008 -0800

    Fix a delete on close divergence from windows [1/2]
    
    smbtorture4's BASE-DELETE:deltest17 was failing against win2k8,
    win2k3, and winXPsp2 but passing against samba.
    
    deltest17 does the following:
    
    1. open file -> file is created
    2. closes file
    3. open file with DOC -> fnum1
    4. check that DOC is not reported as being set from fnum1
    5. opens file again Read Only -> fnum2
    6. check that DOC is not reported as being set from either file handle
    7. close fnum1 (the file handle that requested DOC to be set)
    8. check if DOC is reported as being set from fnum2
     * This is where windows and samba begin to diverge.  Windows
       reports that the DOC bit is set, while samba reports that it is not set.
    9. close fnum2 (the last remaining open handle for the file)
    10.See if the file has been deleted.
     * On samba the file still exists.  On windows the file was deleted.
    
    The way open_file_ntcreate is written now, if an open has the DOC bit
    set on the wire, DOC (fsp->initial_delete_on_close) is not set unless:
    a. the open creates the file, or b. there is an open file handle with
    a share_entry in the struct lck that has the
    SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE bit set (let's call it
    SM_AIDOC).
    
    My understanding of SM_AIDOC is that it was added to differentiate
    between DOC being set on an open that creates a file vs an open that
    opens an existing.  As described in step 8/10 above, it appears that
    windows does not make this differentiation.
    
    To resolve this issue there are two patches.  This first patch is a
    simple proof of concept change that is sufficient to fix the bug.  It
    removes the differentiation in open_file_ntcreate, and updates
    deltest17 to allow it to pass against win2k3/xp.  This makes
    open_file_ntcreate more closely match the semantics in open_directory
    and rename_internals_fsp.  This change also does not break any other
    tests in BASE-DELETE or "make test".  Specifically test deltest20b
    which verifies the CIFSFS rename DOC semantics still passes :).

-----------------------------------------------------------------------

Summary of changes:
 source/include/proto.h   |    4 +---
 source/include/smb.h     |    1 -
 source/locking/locking.c |   46 +---------------------------------------------
 source/smbd/open.c       |   11 ++++-------
 source/smbd/reply.c      |    2 --
 5 files changed, 6 insertions(+), 58 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/proto.h b/source/include/proto.h
index 4c06863..41624c9 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -5213,7 +5213,7 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e);
 bool is_deferred_open_entry(const struct share_mode_entry *e);
 bool is_unused_share_mode_entry(const struct share_mode_entry *e);
 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
-			uid_t uid, uint16 mid, uint16 op_type, bool initial_delete_on_close_allowed);
+		    uid_t uid, uint16 mid, uint16 op_type);
 void add_deferred_open(struct share_mode_lock *lck, uint16 mid,
 		       struct timeval request_time,
 		       struct file_id id);
@@ -5223,11 +5223,9 @@ bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
 				 uint32 dosmode);
-bool can_set_initial_delete_on_close(const struct share_mode_lock *lck);
 void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok);
 void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, UNIX_USER_TOKEN *tok);
 bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKEN *tok);
-bool set_allow_initial_delete_on_close(struct share_mode_lock *lck, files_struct *fsp, bool delete_on_close);
 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
 bool set_write_time(struct file_id fileid, struct timespec write_time);
 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
diff --git a/source/include/smb.h b/source/include/smb.h
index bcf7de9..7f82f72 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -717,7 +717,6 @@ struct pending_message_list {
 };
 
 #define SHARE_MODE_FLAG_POSIX_OPEN	0x1
-#define SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE      0x2
 
 /* struct returned by get_share_modes */
 struct share_mode_entry {
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 368ab16..c30a105 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -1067,13 +1067,10 @@ static void add_share_mode_entry(struct share_mode_lock *lck,
 }
 
 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
-			uid_t uid, uint16 mid, uint16 op_type, bool initial_delete_on_close_allowed)
+		    uid_t uid, uint16 mid, uint16 op_type)
 {
 	struct share_mode_entry entry;
 	fill_share_mode_entry(&entry, fsp, uid, mid, op_type);
-	if (initial_delete_on_close_allowed) {
-		entry.flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-	}
 	add_share_mode_entry(lck, &entry);
 }
 
@@ -1271,22 +1268,6 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
 	return NT_STATUS_OK;
 }
 
-/****************************************************************************
- Do we have an open file handle that created this entry ?
-****************************************************************************/
-
-bool can_set_initial_delete_on_close(const struct share_mode_lock *lck)
-{
-	int i;
-
-	for (i=0; i<lck->num_share_modes; i++) {
-		if (lck->share_modes[i].flags & SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE) {
-			return True;
-		}
-	}
-	return False;
-}
-
 /*************************************************************************
  Return a talloced copy of a UNIX_USER_TOKEN. NULL on fail.
  (Should this be in locking.c.... ?).
@@ -1380,31 +1361,6 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKE
 	return True;
 }
 
-/****************************************************************************
- Sets the allow initial delete on close flag for this share mode.
-****************************************************************************/
-
-bool set_allow_initial_delete_on_close(struct share_mode_lock *lck, files_struct *fsp, bool delete_on_close)
-{
-	struct share_mode_entry entry, *e;
-
-	/* Don't care about the pid owner being correct here - just a search. */
-	fill_share_mode_entry(&entry, fsp, (uid_t)-1, 0, NO_OPLOCK);
-
-	e = find_share_mode_entry(lck, &entry);
-	if (e == NULL) {
-		return False;
-	}
-
-	if (delete_on_close) {
-		e->flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-	} else {
-		e->flags &= ~SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-	}
-	lck->modified = True;
-	return True;
-}
-
 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
 {
 	struct share_mode_lock *lck;
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 632e02d..7043f51 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -1962,13 +1962,11 @@ static NTSTATUS open_file_ntcreate_internal(connection_struct *conn,
 	}
 
 	set_share_mode(lck, fsp, conn->server_info->utok.uid, 0,
-		       fsp->oplock_type, new_file_created);
+		       fsp->oplock_type);
 
 	/* Handle strange delete on close create semantics. */
-	if ((create_options & FILE_DELETE_ON_CLOSE)
-	    && (((conn->fs_capabilities & FILE_NAMED_STREAMS)
-			&& is_ntfs_stream_name(fname))
-		|| can_set_initial_delete_on_close(lck))) {
+	if (create_options & FILE_DELETE_ON_CLOSE) {
+
 		status = can_set_delete_on_close(fsp, True, new_dos_attributes);
 
 		if (!NT_STATUS_IS_OK(status)) {
@@ -2435,8 +2433,7 @@ NTSTATUS open_directory(connection_struct *conn,
 		return status;
 	}
 
-	set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK,
-		       True);
+	set_share_mode(lck, fsp, conn->server_info->utok.uid, 0, NO_OPLOCK);
 
 	/* For directories the delete on close bit at open time seems
 	   always to be honored on close... See test 19 in Samba4 BASE-DELETE. */
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index afcb5b2..7e8f17a 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -5650,8 +5650,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 		 * depends on these semantics. JRA.
 		 */
 
-		set_allow_initial_delete_on_close(lck, fsp, True);
-
 		if (create_options & FILE_DELETE_ON_CLOSE) {
 			status = can_set_delete_on_close(fsp, True, 0);
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list