Author: vlendec Date: 2007-08-19 19:57:55 +0000 (Sun, 19 Aug 2007) New Revision: 24548
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24548 Log: Fix the case-changing renames This was broken when I changed reply_mv to wrap in a open_file_ntcreate call, unix_convert on the destination was called twice Modified: branches/SAMBA_3_2/source/smbd/reply.c branches/SAMBA_3_2/source/smbd/trans2.c branches/SAMBA_3_2_0/source/smbd/reply.c branches/SAMBA_3_2_0/source/smbd/trans2.c Changeset: Modified: branches/SAMBA_3_2/source/smbd/reply.c =================================================================== --- branches/SAMBA_3_2/source/smbd/reply.c 2007-08-19 19:52:18 UTC (rev 24547) +++ branches/SAMBA_3_2/source/smbd/reply.c 2007-08-19 19:57:55 UTC (rev 24548) @@ -5111,24 +5111,18 @@ Rename an open file - given an fsp. ****************************************************************************/ -NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstring newname, uint32 attrs, BOOL replace_if_exists) +NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, + pstring newname, + const char *newname_last_component, + uint32 attrs, BOOL replace_if_exists) { SMB_STRUCT_STAT sbuf, sbuf1; - pstring newname_last_component; NTSTATUS status = NT_STATUS_OK; struct share_mode_lock *lck = NULL; BOOL dst_exists; ZERO_STRUCT(sbuf); - status = unix_convert(conn, newname, False, newname_last_component, &sbuf); - - /* If an error we expect this to be NT_STATUS_OBJECT_PATH_NOT_FOUND */ - - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(NT_STATUS_OBJECT_PATH_NOT_FOUND, status)) { - return status; - } - status = check_name(conn, newname); if (!NT_STATUS_IS_OK(status)) { return status; @@ -5420,8 +5414,9 @@ return status; } - status = rename_internals_fsp(conn, fsp, newname, attrs, - replace_if_exists); + status = rename_internals_fsp(conn, fsp, newname, + last_component_dest, + attrs, replace_if_exists); close_file(fsp, NORMAL_CLOSE); @@ -5517,8 +5512,8 @@ break; } - status = rename_internals_fsp(conn, fsp, destname, attrs, - replace_if_exists); + status = rename_internals_fsp(conn, fsp, destname, dname, + attrs, replace_if_exists); close_file(fsp, NORMAL_CLOSE); Modified: branches/SAMBA_3_2/source/smbd/trans2.c =================================================================== --- branches/SAMBA_3_2/source/smbd/trans2.c 2007-08-19 19:52:18 UTC (rev 24547) +++ branches/SAMBA_3_2/source/smbd/trans2.c 2007-08-19 19:57:55 UTC (rev 24548) @@ -4937,9 +4937,28 @@ pstrcat(base_name, newname); if (fsp) { + SMB_STRUCT_STAT sbuf; + pstring newname_last_component; + + ZERO_STRUCT(sbuf); + + status = unix_convert(conn, newname, False, + newname_last_component, &sbuf); + + /* If an error we expect this to be + * NT_STATUS_OBJECT_PATH_NOT_FOUND */ + + if (!NT_STATUS_IS_OK(status) + && !NT_STATUS_EQUAL(NT_STATUS_OBJECT_PATH_NOT_FOUND, + status)) { + return status; + } + DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n", fsp->fnum, fsp->fsp_name, base_name )); - status = rename_internals_fsp(conn, fsp, base_name, 0, overwrite); + status = rename_internals_fsp(conn, fsp, base_name, + newname_last_component, 0, + overwrite); } else { DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION %s -> %s\n", fname, newname )); Modified: branches/SAMBA_3_2_0/source/smbd/reply.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/reply.c 2007-08-19 19:52:18 UTC (rev 24547) +++ branches/SAMBA_3_2_0/source/smbd/reply.c 2007-08-19 19:57:55 UTC (rev 24548) @@ -4361,24 +4361,18 @@ Rename an open file - given an fsp. ****************************************************************************/ -NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, pstring newname, uint32 attrs, BOOL replace_if_exists) +NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, + pstring newname, + const char *newname_last_component, + uint32 attrs, BOOL replace_if_exists) { SMB_STRUCT_STAT sbuf, sbuf1; - pstring newname_last_component; NTSTATUS status = NT_STATUS_OK; struct share_mode_lock *lck = NULL; BOOL dst_exists; ZERO_STRUCT(sbuf); - status = unix_convert(conn, newname, False, newname_last_component, &sbuf); - - /* If an error we expect this to be NT_STATUS_OBJECT_PATH_NOT_FOUND */ - - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(NT_STATUS_OBJECT_PATH_NOT_FOUND, status)) { - return status; - } - status = check_name(conn, newname); if (!NT_STATUS_IS_OK(status)) { return status; @@ -4670,8 +4664,9 @@ return status; } - status = rename_internals_fsp(conn, fsp, newname, attrs, - replace_if_exists); + status = rename_internals_fsp(conn, fsp, newname, + last_component_dest, + attrs, replace_if_exists); close_file(fsp, NORMAL_CLOSE); @@ -4767,8 +4762,8 @@ break; } - status = rename_internals_fsp(conn, fsp, destname, attrs, - replace_if_exists); + status = rename_internals_fsp(conn, fsp, destname, dname, + attrs, replace_if_exists); close_file(fsp, NORMAL_CLOSE); Modified: branches/SAMBA_3_2_0/source/smbd/trans2.c =================================================================== --- branches/SAMBA_3_2_0/source/smbd/trans2.c 2007-08-19 19:52:18 UTC (rev 24547) +++ branches/SAMBA_3_2_0/source/smbd/trans2.c 2007-08-19 19:57:55 UTC (rev 24548) @@ -4630,9 +4630,28 @@ pstrcat(base_name, newname); if (fsp) { + SMB_STRUCT_STAT sbuf; + pstring newname_last_component; + + ZERO_STRUCT(sbuf); + + status = unix_convert(conn, newname, False, + newname_last_component, &sbuf); + + /* If an error we expect this to be + * NT_STATUS_OBJECT_PATH_NOT_FOUND */ + + if (!NT_STATUS_IS_OK(status) + && !NT_STATUS_EQUAL(NT_STATUS_OBJECT_PATH_NOT_FOUND, + status)) { + return status; + } + DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n", fsp->fnum, fsp->fsp_name, base_name )); - status = rename_internals_fsp(conn, fsp, base_name, 0, overwrite); + status = rename_internals_fsp(conn, fsp, base_name, + newname_last_component, 0, + overwrite); } else { DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION %s -> %s\n", fname, newname ));