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

Jeremy Allison jra at samba.org
Fri Jan 9 01:22:12 GMT 2009


The branch, v3-3-test has been updated
       via  98eb11ef99418e690ae43116432c0566a28da8a0 (commit)
       via  b377bce1371553e4a9545092cfc8527925b57b67 (commit)
       via  fb888dd4f10b00edb258e965ea06e29fa76827d6 (commit)
      from  935173a514bf54ebdf6269e872adfb86a9625f27 (commit)

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


- Log -----------------------------------------------------------------
commit 98eb11ef99418e690ae43116432c0566a28da8a0
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jan 8 17:21:08 2009 -0800

    s3: Remove a few unnecessary checks from the streams depot module and fix to work with NTRENAME
    
    Handling of error codes when renaming a file to a stream and a stream
    to a file is now done in rename_internals_fsp.
    
    The NTRENAME stream path only passes in the stream name, so the new
    base can now be different from the old base.

commit b377bce1371553e4a9545092cfc8527925b57b67
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jan 8 17:20:14 2009 -0800

    s3: Remove a few unnecessary checks from the streams xattr module
    
    Handling of error codes when renaming a file to a stream and a stream
    to a file is now done in rename_internals_fsp.
    
    The NTRENAME stream path only passes in the stream name, so the new
    base can now be different from the old base.

commit fb888dd4f10b00edb258e965ea06e29fa76827d6
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jan 8 17:19:24 2009 -0800

    s3: Allow renames of streams via NTRENAME and fix stream error codes on rename
    
    The test_streams_rename2 test in RAW-STREAMS verifies these changes

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

Summary of changes:
 source/modules/vfs_streams_depot.c |   30 ++++++++++++++++++------------
 source/modules/vfs_streams_xattr.c |   11 -----------
 source/smbd/nttrans.c              |   14 +++++++-------
 source/smbd/reply.c                |   25 +++++++++++++++----------
 4 files changed, 40 insertions(+), 40 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/modules/vfs_streams_depot.c b/source/modules/vfs_streams_depot.c
index d543ea3..8ff617c 100644
--- a/source/modules/vfs_streams_depot.c
+++ b/source/modules/vfs_streams_depot.c
@@ -525,6 +525,7 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 	char *nsname = NULL;
 	char *ostream_fname = NULL;
 	char *nstream_fname = NULL;
+	char *newname_full = NULL;
 
 	DEBUG(10, ("streams_depot_rename called for %s => %s\n",
 		   oldname, newname));
@@ -536,11 +537,6 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
 	}
 
-	if (!(old_is_stream && new_is_stream)) {
-		errno = ENOSYS;
-		return -1;
-	}
-
 	frame = talloc_stackframe();
 
 	if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), oldname,
@@ -549,7 +545,7 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 		goto done;
 	}
 
-	if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), oldname,
+	if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), newname,
 						    &nbase, &nsname))) {
 		errno = ENOMEM;
 		goto done;
@@ -561,17 +557,27 @@ static int streams_depot_rename(vfs_handle_struct *handle,
 		goto done;
 	}
 
-	if (StrCaseCmp(obase, nbase) != 0) {
-		errno = ENOSYS;
-		goto done;
-	}
-
 	ostream_fname = stream_name(handle, oldname, false);
 	if (ostream_fname == NULL) {
 		return -1;
 	}
 
-	nstream_fname = stream_name(handle, newname, false);
+	/*
+	 * Handle passing in a stream name without the base file.  This is
+	 * exercised by the NTRENAME streams rename path.
+	 */
+	if (StrCaseCmp(nbase, "./") == 0) {
+		newname_full = talloc_asprintf(talloc_tos(), "%s:%s", obase,
+					       nsname);
+		if (newname_full == NULL) {
+			errno = ENOMEM;
+			goto done;
+		}
+	}
+
+	nstream_fname = stream_name(handle,
+				    newname_full ? newname_full : newname,
+				    false);
 	if (nstream_fname == NULL) {
 		return -1;
 	}
diff --git a/source/modules/vfs_streams_xattr.c b/source/modules/vfs_streams_xattr.c
index ecfc319..7124c57 100644
--- a/source/modules/vfs_streams_xattr.c
+++ b/source/modules/vfs_streams_xattr.c
@@ -511,11 +511,6 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
 	}
 
-	if (!(o_is_stream && n_is_stream)) {
-		errno = ENOSYS;
-		goto fail;
-	}
-
 	frame = talloc_stackframe();
 	if (!frame) {
 		goto fail;
@@ -544,12 +539,6 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 		goto fail;
 	}
 
-	/* the new base should be empty */
-	if (StrCaseCmp(obase, nbase) != 0) {
-		errno = ENOSYS;
-		goto fail;
-	}
-
 	if (StrCaseCmp(ostream, nstream) == 0) {
 		goto done;
 	}
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 91d896c..a3f5114 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -1263,13 +1263,6 @@ void reply_ntrename(struct smb_request *req)
 		return;
 	}
 
-	if( is_ntfs_stream_name(oldname)) {
-		/* Can't rename a stream. */
-		reply_nterror(req, NT_STATUS_ACCESS_DENIED);
-		END_PROFILE(SMBntrename);
-		return;
-	}
-
 	if (ms_has_wild(oldname)) {
 		reply_nterror(req, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
 		END_PROFILE(SMBntrename);
@@ -1318,6 +1311,13 @@ void reply_ntrename(struct smb_request *req)
 		return;
 	}
 
+	/* The new name must begin with a ':' if the old name is a stream. */
+	if (is_ntfs_stream_name(oldname) && (newname[0] != ':')) {
+		reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		END_PROFILE(SMBntrename);
+		return;
+	}
+
 	DEBUG(3,("reply_ntrename : %s -> %s\n",oldname,newname));
 
 	switch(rename_type) {
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index f78fb33..a613459 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -5506,7 +5506,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 	SMB_STRUCT_STAT sbuf, sbuf1;
 	NTSTATUS status = NT_STATUS_OK;
 	struct share_mode_lock *lck = NULL;
-	bool dst_exists;
+	bool dst_exists, old_is_stream, new_is_stream;
 
 	ZERO_STRUCT(sbuf);
 
@@ -5575,6 +5575,18 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 		return NT_STATUS_OK;
 	}
 
+	old_is_stream = is_ntfs_stream_name(fsp->fsp_name);
+	new_is_stream = is_ntfs_stream_name(newname);
+
+	/* Return the correct error code if both names aren't streams. */
+	if (!old_is_stream && new_is_stream) {
+		return NT_STATUS_OBJECT_NAME_INVALID;
+	}
+
+	if (old_is_stream && !new_is_stream) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
 	/*
 	 * Have vfs_object_exist also fill sbuf1
 	 */
@@ -5586,18 +5598,11 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 		return NT_STATUS_OBJECT_NAME_COLLISION;
 	}
 
-	if(replace_if_exists && dst_exists) {
-		/* Ensure both or neither are stream names. */
-		if (is_ntfs_stream_name(fsp->fsp_name) !=
-				is_ntfs_stream_name(newname)) {
-			return NT_STATUS_INVALID_PARAMETER;
-		}
-	}
-
 	if (dst_exists) {
 		struct file_id fileid = vfs_file_id_from_sbuf(conn, &sbuf1);
 		files_struct *dst_fsp = file_find_di_first(fileid);
-		if (dst_fsp) {
+		/* The file can be open when renaming a stream */
+		if (dst_fsp && !new_is_stream) {
 			DEBUG(3, ("rename_internals_fsp: Target file open\n"));
 			return NT_STATUS_ACCESS_DENIED;
 		}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list