Hello, After upgrading to Samba 4.11 (from 4.10) I noticed that python scripts using tempfile.mkstemp fail when run against samba cifs mounts. Before I submit a bug report, could someone else try this out so it's not just my setup? How to reproduce: 1. Mount a Samba 4.11 share using the mount command: mount //server1/share /tmp/share1 2. Run python script that is using mkstemp: import shutil import tempfile tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=b'.file_tmp', dir='/tmp/share1', suffix='test.pdf') shutil.move('testfile', tmp_dest_name) Result: Traceback (most recent call last): File "./test.py", line 9, in <module> shutil.move('testfile', tmp_dest_name) File "/usr/lib64/python2.7/shutil.py", line 301, in move copy2(src, real_dst) File "/usr/lib64/python2.7/shutil.py", line 130, in copy2 copyfile(src, dst) File "/usr/lib64/python2.7/shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 116] Stale file handle: '/tmp/share1/.file_tmplB0NqLtest.pdf' Expected results: The operation should succeed without a stale file handle error. Environment: Centos 7.6 / 3.10.0-1062.el7.x86_64 Python 3.6 / 2 Samba 4.11 Regards, Kacper
After a git bisect I've identified the faulty commit. Reverting this commit solved this regression. a3caf4140c01136a412c129cae28b433e33ab014 is the first bad commit commit a3caf4140c01136a412c129cae28b433e33ab014 Author: Ralph Boehme <slow@samba.org> Date: Thu Jun 27 14:46:37 2019 +0200 s3:smbd: use stored file_id in SMB_VFS_FS_FILE_ID() Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> :040000 040000 aa947e4522bd0fb98feb6fda73f40ddfe81fcfee 5e27358a9576f582c47d84b69274c78a6cd77b7a M source3
Thanks, that nails it! You seems to be hitting bug 14121. Can you redo the test ensuring you have the patch for the bug in-tree? Thanks!
I've tried to apply the patch from #14121 however it failed on compile. According to #14121 the fix was included in 4.11-rc4, however I'm on latest 4.11-stable and the regression is still there. ../../source4/torture/smb2/create.c:2106:13: error: redefinition of ‘test_fileid’ static bool test_fileid(struct torture_context *tctx, ^ ../../source4/torture/smb2/create.c:1908:13: note: previous definition of ‘test_fileid’ was here static bool test_fileid(struct torture_context *tctx, ^ ../../source4/torture/smb2/create.c:2359:23: error: redefinition of ‘torture_smb2_fileid_init’ struct torture_suite *torture_smb2_fileid_init(TALLOC_CTX *ctx) ^ ../../source4/torture/smb2/create.c:2345:23: note: previous definition of ‘torture_smb2_fileid_init’ was here struct torture_suite *torture_smb2_fileid_init(TALLOC_CTX *ctx) ^
Can you please share the following: - smb.conf - mount command - network trace Thanks!
Created attachment 15481 [details] network trace
Created attachment 15482 [details] smb.conf
(In reply to Ralph Böhme from comment #4) The mount command is: mount //localhost/share /tmp/share -o username=Administrator
Thanks, that helps to understand the problem! I should have a fix ready within a few days. Stay tuned...
Created attachment 15486 [details] WIP patch for master Can you test the attached patch?
(In reply to Ralph Böhme from comment #9) I've tested the patch and it seemed have fixed the bug :)
https://gitlab.com/samba-team/samba/merge_requests/812
Created attachment 15505 [details] Patch for 4.11 cherry-picked from master
Comment on attachment 15505 [details] Patch for 4.11 cherry-picked from master LGTM.
Re-assigning to Karolin for inclusion in 4.11.next.
(In reply to Jeremy Allison from comment #14) Pushed to autobuild-v4-11-test.
(In reply to Karolin Seeger from comment #15) Pushed to v4-11-test. Closing out bug report. Thanks!