Created attachment 17068 [details]
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.
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.