smbd: return the correct error in can_rename()
authorRalph Boehme <slow@samba.org>
Tue, 19 Dec 2023 12:06:55 +0000 (13:06 +0100)
committerJule Anger <janger@samba.org>
Tue, 16 Jan 2024 09:09:15 +0000 (09:09 +0000)
This is what Windows returns for this case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13688

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 276c5bd851ab6ab818a49d9c47f6b96de8024778)

source3/smbd/smb2_reply.c

index 9476c69b73ca907267278d13856f9642fc665d33..a4055c00a312add93927c715c66ebdc6722b1336 100644 (file)
@@ -1156,6 +1156,11 @@ ssize_t sendfile_short_send(struct smbXsrv_connection *xconn,
 static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
                        uint16_t dirtype)
 {
+       if (fsp->fsp_name->twrp != 0) {
+               /* Get the error right, this is what Windows returns. */
+               return NT_STATUS_NOT_SAME_DEVICE;
+       }
+
        if (!CAN_WRITE(conn)) {
                return NT_STATUS_MEDIA_WRITE_PROTECTED;
        }