summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2009-01-04 10:45:34 -0800
committerTim Prouty <tprouty@samba.org>2009-01-04 19:31:30 -0800
commit3e0e756104dc77059843bcef4a8d44981df28a18 (patch)
tree4f6bbbb00cb819ac25ae7b14996cfe1dead49736 /source3/smbd/reply.c
parent2ddaebb2e11ba13ff7428e45dbfdc90b1bf2d630 (diff)
downloadsamba-3e0e756104dc77059843bcef4a8d44981df28a18.tar.gz
samba-3e0e756104dc77059843bcef4a8d44981df28a18.tar.bz2
samba-3e0e756104dc77059843bcef4a8d44981df28a18.zip
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
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 2133a30dc6..593558e399 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5439,7 +5439,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);
@@ -5508,6 +5508,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
*/
@@ -5519,18 +5531,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;
}