[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre2-402-gf9cb81c

Karolin Seeger kseeger at samba.org
Thu Apr 3 08:44:43 GMT 2008


The branch, v3-2-stable has been updated
       via  f9cb81c1615d5cc34981dc3b483bbf6f36847a41 (commit)
       via  ec2928e65e0053c188a68b665a01fbc130a35a9e (commit)
       via  856c6b41de4a3ae4fa9dcb2ba54f7916586f986b (commit)
       via  69e1f41228b59e8c31d3da7ea5c285dae6cf7387 (commit)
       via  2d186f175ed4a0942145f2c97557b17f15e95ce2 (commit)
       via  0fb5b3282d50520f857f584126a33acbf866b774 (commit)
       via  4b40a23233a745ea80246d896d408f1e947995aa (commit)
       via  87ed31c9c67c2d2a9dcc84fda17cfc048778803d (commit)
      from  2ba0037a3bb1e0692e5c35b11dd632590735d869 (commit)

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


- Log -----------------------------------------------------------------
commit f9cb81c1615d5cc34981dc3b483bbf6f36847a41
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 1 12:29:12 2008 +0200

    smbd: ignore nttrans renames as w2k3 does
    
    This lets us pass the RAW-RENAME test.
    
    metze
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 2d50a1fef022023588e9963131951f8f3e4c7c23)

commit ec2928e65e0053c188a68b665a01fbc130a35a9e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 1 18:18:38 2008 +0200

    smbd: always close the base_fsp even if the real close returned an error
    
    Otherwise we may end up with share mode entry without an open file.
    
    Volker, Jeremy: please check...
    
    metze
    (cherry picked from commit 547eacf6058d2bc5b41b266b70f8f4747aca4eae)

commit 856c6b41de4a3ae4fa9dcb2ba54f7916586f986b
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Mar 31 17:01:27 2008 -0700

    Ok, final move of this code :-). I think I've found the correct
    place for it now where it will cause minimal disruption (only
    call the extra message_dispatch just before reading the next
    smb off the wire).
    Jeremy.
    (cherry picked from commit da2c19c481d0041872b4ce2f5105052077f3d3b8)

commit 69e1f41228b59e8c31d3da7ea5c285dae6cf7387
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Mar 31 16:56:21 2008 -0700

    Move the message_dispatch() call after the check for errno on
    the select return. We don't want the call to message_dispatch
    to mess up the errno value.
    Jeremy.
    (cherry picked from commit 26a74d01bb2b53ffa5d296ff1c7d8b2b0d17831a)

commit 2d186f175ed4a0942145f2c97557b17f15e95ce2
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 11 15:26:02 2008 -0700

    Using Metze's S4 nttrans rename test, the nttrans rename
    behaves the same as the trans2 one.
    Jeremy.
    (cherry picked from commit c4fa4917dad97c5047f7336c6675739b44da256b)

commit 0fb5b3282d50520f857f584126a33acbf866b774
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Mar 31 16:46:20 2008 -0700

    Reduce the race condition in Samba4 in RAW-RENAME test. We rename a file
    using trans2 setfileinfo on one connection, and then check the
    file name has changed on the other. In Samba we achieve this by
    sending a local message to the other process. This change causes
    us to re-scan for incoming messages after we've woken up from the
    select (which is cheap if there are no pending messages). This reduces
    the race significantly. Volker please review.
    Jeremy.
    (cherry picked from commit a7499e994aef743ea9c443f9a1618b262f6eda93)

commit 4b40a23233a745ea80246d896d408f1e947995aa
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 11 13:38:25 2008 -0700

    Allow us to pass RAW-RENAME by testing that the connection struct
    connection paths are equal, not just the conn structs themselves.
    Jeremy.
    (cherry picked from commit 632f3fe66fbcbe3cc25d070c3885177264f5ad65)

commit 87ed31c9c67c2d2a9dcc84fda17cfc048778803d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 11 13:27:33 2008 -0700

    Try and fix bug #5315, as well as S4 torture tests RAW-OPLOCK BATCH19,
    BATCH20 and RAW-RENAME.
    Jeremy.
    (cherry picked from commit 9065792d4bc42522f12f9732de3c0ad82c72a2d3)

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

Summary of changes:
 source/smbd/close.c   |    4 ----
 source/smbd/nttrans.c |   28 ++++------------------------
 source/smbd/process.c |   13 +++++++++++--
 source/smbd/reply.c   |   17 +++++++++--------
 source/smbd/trans2.c  |    3 ++-
 5 files changed, 26 insertions(+), 39 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/smbd/close.c b/source/smbd/close.c
index 4bd23a3..b06c0d1 100644
--- a/source/smbd/close.c
+++ b/source/smbd/close.c
@@ -665,10 +665,6 @@ NTSTATUS close_file(files_struct *fsp, enum file_close_type close_type)
 		status = close_normal_file(fsp, close_type);
 	}
 
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
-	}
-
 	if ((base_fsp != NULL) && (close_type != SHUTDOWN_CLOSE)) {
 
 		/*
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 5293ca5..60e5464 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -1353,7 +1353,7 @@ void reply_ntrename(struct smb_request *req)
 		case RENAME_FLAG_RENAME:
 			status = rename_internals(ctx, conn, req, oldname,
 					newname, attrs, False, src_has_wcard,
-					dest_has_wcard);
+					dest_has_wcard, DELETE_ACCESS);
 			break;
 		case RENAME_FLAG_HARD_LINK:
 			if (src_has_wcard || dest_has_wcard) {
@@ -1518,7 +1518,6 @@ static void call_nt_transact_rename(connection_struct *conn,
 	char *params = *ppparams;
 	char *new_name = NULL;
 	files_struct *fsp = NULL;
-	bool replace_if_exists = False;
 	bool dest_has_wcard = False;
 	NTSTATUS status;
 	TALLOC_CTX *ctx = talloc_tos();
@@ -1529,7 +1528,6 @@ static void call_nt_transact_rename(connection_struct *conn,
 	}
 
 	fsp = file_fsp(SVAL(params, 0));
-	replace_if_exists = (SVAL(params,2) & RENAME_REPLACE_IF_EXISTS) ? True : False;
 	if (!check_fsp(conn, req, fsp, &current_user)) {
 		return;
 	}
@@ -1541,31 +1539,13 @@ static void call_nt_transact_rename(connection_struct *conn,
 		return;
 	}
 
-	status = rename_internals(ctx,
-			conn,
-			req,
-			fsp->fsp_name,
-			new_name,
-			0,
-			replace_if_exists,
-			False,
-			dest_has_wcard);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		if (open_was_deferred(req->mid)) {
-			/* We have re-scheduled this call. */
-			return;
-		}
-		reply_nterror(req, status);
-		return;
-	}
-
 	/*
-	 * Rename was successful.
+	 * W2K3 ignores this request as the RAW-RENAME test
+	 * demonstrates, so we do.
 	 */
 	send_nt_replies(conn, req, NT_STATUS_OK, NULL, 0, NULL, 0);
 
-	DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n",
+	DEBUG(3,("nt transact rename from = %s, to = %s ignored!\n",
 		 fsp->fsp_name, new_name));
 
 	return;
diff --git a/source/smbd/process.c b/source/smbd/process.c
index 9c01bba..8868431 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -871,8 +871,8 @@ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer,
 	if (selrtn == -1) {
 		/* something is wrong. Maybe the socket is dead? */
 		return map_nt_error_from_unix(errno);
-	} 
-    
+	}
+
 	/* Did we timeout ? */
 	if (selrtn == 0) {
 		return NT_STATUS_IO_TIMEOUT;
@@ -894,6 +894,15 @@ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer,
 		goto again;
 	}
 
+	/*
+	 * We've just woken up from a protentially long select sleep.
+	 * Ensure we process local messages as we need to synchronously
+	 * process any messages from other smbd's to avoid file rename race
+	 * conditions. This call is cheap if there are no messages waiting.
+	 * JRA.
+	 */
+	message_dispatch(smbd_messaging_context());
+
 	status = receive_smb_talloc(mem_ctx, smbd_server_fd(), buffer, 0,
 				    p_unread, p_encrypted, &len);
 
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 427fadc..972f30d 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -2184,7 +2184,7 @@ static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
 		return NT_STATUS_OK;
 	}
 
-	if (fsp->access_mask & DELETE_ACCESS) {
+	if (fsp->access_mask & (DELETE_ACCESS|FILE_WRITE_ATTRIBUTES)) {
 		return NT_STATUS_OK;
 	}
 
@@ -5295,7 +5295,7 @@ static void rename_open_files(connection_struct *conn,
 		   sharepaths we need to manipulate relative paths. */
 		/* TODO - create the absolute path and manipulate the newname
 		   relative to the sharepath. */
-		if (fsp->conn != conn) {
+		if (!strequal(fsp->conn->connectpath, conn->connectpath)) {
 			continue;
 		}
 		DEBUG(10,("rename_open_files: renaming file fnum %d (file_id %s) from %s -> %s\n",
@@ -5585,7 +5585,8 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
 			uint32 attrs,
 			bool replace_if_exists,
 			bool src_has_wild,
-			bool dest_has_wild)
+			bool dest_has_wild,
+			uint32_t access_mask)
 {
 	char *directory = NULL;
 	char *mask = NULL;
@@ -5715,12 +5716,12 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
 
 		status = S_ISDIR(sbuf1.st_mode) ?
 			open_directory(conn, req, directory, &sbuf1,
-				       DELETE_ACCESS,
+				       access_mask,
 				       FILE_SHARE_READ|FILE_SHARE_WRITE,
 				       FILE_OPEN, 0, 0, NULL,
 				       &fsp)
 			: open_file_ntcreate(conn, req, directory, &sbuf1,
-					     DELETE_ACCESS,
+					     access_mask,
 					     FILE_SHARE_READ|FILE_SHARE_WRITE,
 					     FILE_OPEN, 0, 0, 0, NULL,
 					     &fsp);
@@ -5819,12 +5820,12 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
 
 		status = S_ISDIR(sbuf1.st_mode) ?
 			open_directory(conn, req, fname, &sbuf1,
-				       DELETE_ACCESS,
+				       access_mask,
 				       FILE_SHARE_READ|FILE_SHARE_WRITE,
 				       FILE_OPEN, 0, 0, NULL,
 				       &fsp)
 			: open_file_ntcreate(conn, req, fname, &sbuf1,
-					     DELETE_ACCESS,
+					     access_mask,
 					     FILE_SHARE_READ|FILE_SHARE_WRITE,
 					     FILE_OPEN, 0, 0, 0, NULL,
 					     &fsp);
@@ -5947,7 +5948,7 @@ void reply_mv(struct smb_request *req)
 	DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
 
 	status = rename_internals(ctx, conn, req, name, newname, attrs, False,
-				  src_has_wcard, dest_has_wcard);
+				  src_has_wcard, dest_has_wcard, DELETE_ACCESS);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (open_was_deferred(req->mid)) {
 			/* We have re-scheduled this call. */
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 008ffed..06efbc0 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -5322,7 +5322,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
 		DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION %s -> %s\n",
 			fname, base_name ));
 		status = rename_internals(ctx, conn, req, fname, base_name, 0,
-					  overwrite, False, dest_has_wcard);
+					overwrite, False, dest_has_wcard,
+					FILE_WRITE_ATTRIBUTES);
 	}
 
 	return status;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list