diff options
author | Tim Prouty <tprouty@samba.org> | 2009-01-08 17:19:24 -0800 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-01-12 09:38:20 +0100 |
commit | 1a95b9b8ddf698553da1d767d8800c111db20ae8 (patch) | |
tree | 2f0b1ecab86d5455dddd51fd5e145ed2697acb86 | |
parent | c0d6fd9204da08b01fe08053ee16fed013640ccf (diff) | |
download | samba-1a95b9b8ddf698553da1d767d8800c111db20ae8.tar.gz |
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
(cherry picked from commit fb888dd4f10b00edb258e965ea06e29fa76827d6)
-rw-r--r-- | source/smbd/nttrans.c | 14 | ||||
-rw-r--r-- | source/smbd/reply.c | 25 |
2 files changed, 22 insertions, 17 deletions
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c index 91d896c8785..a3f5114bdf9 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 f78fb33fc8e..a613459a5b3 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; } |