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: RESOLVED FIXED
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: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-30 00:05 UTC by Paulo Vitor Magacho
Modified: 2022-04-04 12:49 UTC (History)
2 users (show)

See Also:


Attachments
patch-rename-operation-errno (804 bytes, patch)
2021-12-30 00:05 UTC, Paulo Vitor Magacho
no flags Details
git-am fix for 4.16.rcNext., 4.15.next, 4.14.next. (5.63 KB, patch)
2022-02-02 22:09 UTC, Jeremy Allison
slow: review+
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.
Comment 2 Jeremy Allison 2022-02-02 19:06:59 UTC
Patch is under ci test at:

https://gitlab.com/samba-team/devel/samba/-/pipelines/462101182
Comment 4 Samba QA Contact 2022-02-02 21:51:05 UTC
This bug was referenced in samba master:

0ecc58858360bcc0181a02e52ada3e8327f97c5b
ca60f6350d566b7ecc822bcbb44fb65a1d150bbe
Comment 5 Jeremy Allison 2022-02-02 22:09:26 UTC
Created attachment 17142 [details]
git-am fix for 4.16.rcNext., 4.15.next, 4.14.next.

Cherry-picked from master. Applies cleanly to 4.16.rcNext, 4.15.next, 4.14.next.
Comment 6 Ralph Böhme 2022-02-03 09:37:50 UTC
Reassigning to Jule for inclusion in 4.16, 4.15 and 4.14.
Comment 7 Jule Anger 2022-02-04 07:05:06 UTC
Pushed to autobuild-v4-{16,15,14}-test.
Comment 8 Samba QA Contact 2022-02-04 08:25:12 UTC
This bug was referenced in samba v4-15-test:

641271eaa076cfbebdc22e472e57a088ef88a298
bbb7aacf4909d6cffb08b461e094cb8641ff9d39
Comment 9 Samba QA Contact 2022-02-04 08:42:03 UTC
This bug was referenced in samba v4-16-test:

5c55418c25eb18d44416f486d1468ca6ccce0ab7
64aea70f9f80acec2ba4f5da44e413f2f91c75c0
Comment 10 Samba QA Contact 2022-02-06 12:40:13 UTC
This bug was referenced in samba v4-14-test:

d775a15a34620da8b2cbe3c61621bd5cfe763f16
9a4c688c2e7dfe0c2ca1bdce4e7fa724e05b2f81
Comment 11 Samba QA Contact 2022-02-15 07:55:30 UTC
This bug was referenced in samba v4-16-stable (Release samba-4.16.0rc3):

5c55418c25eb18d44416f486d1468ca6ccce0ab7
64aea70f9f80acec2ba4f5da44e413f2f91c75c0
Comment 12 Samba QA Contact 2022-03-15 13:26:37 UTC
This bug was referenced in samba v4-15-stable (Release samba-4.15.6):

641271eaa076cfbebdc22e472e57a088ef88a298
bbb7aacf4909d6cffb08b461e094cb8641ff9d39
Comment 13 Samba QA Contact 2022-04-04 12:49:37 UTC
This bug was referenced in samba v4-14-stable (Release samba-4.14.13):

d775a15a34620da8b2cbe3c61621bd5cfe763f16
9a4c688c2e7dfe0c2ca1bdce4e7fa724e05b2f81