The branch, v3-2-test has been updated
       via  2cca28b3e999a8886539b9a5dde267bb8a3a1db7 (commit)
       via  078c4fbab8a5be2e23acda1978fd6d6071898dd9 (commit)
       via  ac7c18d642bef231730927347e7b0296b1c9d82b (commit)
      from  b13f7e296a70e1280baae9f2f3156043c48bafa9 (commit)

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


- Log -----------------------------------------------------------------
commit 2cca28b3e999a8886539b9a5dde267bb8a3a1db7
Author: Tim Prouty <[email protected]>
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 078c4fbab8a5be2e23acda1978fd6d6071898dd9
Author: Tim Prouty <[email protected]>
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 ac7c18d642bef231730927347e7b0296b1c9d82b
Author: Tim Prouty <[email protected]>
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 f66a06b..7f46f77 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 da7b2bf..920b0ec 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -1305,13 +1305,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);
@@ -1360,6 +1353,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 19f4ac1..92ef0b6 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -5480,7 +5480,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);
 
@@ -5549,6 +5549,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
         */
@@ -5560,18 +5572,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

Reply via email to