Bug 14938 - NT error code is not set when overwriting a file during rename in libsmbclient
Summary: NT error code is not set when overwriting a file during rename in libsmbclient
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 4.15.1
Hardware: x64 Linux
: P5 major (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-30 00:05 UTC by Paulo Vitor Magacho
Modified: 2022-01-04 01:08 UTC (History)
1 user (show)

See Also:


Attachments
patch-rename-operation-errno (804 bytes, patch)
2021-12-30 00:05 UTC, Paulo Vitor Magacho
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo Vitor Magacho 2021-12-30 00:05:26 UTC
Created attachment 17068 [details]
patch-rename-operation-errno

When using SMBC_rename_ctx (source3\libsmb\libsmb_dir.c) to overwrite an already existing file or folder, the error code is not set properly.

Looking at the source code, one can track it down to the fact that the cli->raw_status is not set. 

Therefore the conversion from NT error to UNIX error doesn't work properly and you end with a situation where the rename fails but the error code is equal to zero.

I am attaching a proposal for a patch against version 4.15.1.

Server runs NetApp.
Comment 1 Jeremy Allison 2022-01-04 01:08:44 UTC
Patch isn't correct (it assigns "state" to an NTSTATUS value), but gives me the correct idea. We need a regression test for this first though. I'll take a look at that later this week.