Inside OpenDir() we have: struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn, const struct smb_filename *smb_dname, const char *mask, uint32_t attr) { struct files_struct *fsp = NULL; struct smb_Dir *dir_hnd = NULL; NTSTATUS status; status = open_internal_dirfsp(conn, smb_dname, O_RDONLY, &fsp); if (!NT_STATUS_IS_OK(status)) { return NULL; } dir_hnd = OpenDir_fsp(mem_ctx, conn, fsp, mask, attr); if (dir_hnd == NULL) { return NULL; } /* * This overwrites the destructor set by smb_Dir_OpenDir_destructor(), * but smb_Dir_OpenDir_destructor() calls the OpenDir_fsp() destructor. */ talloc_set_destructor(dir_hnd, smb_Dir_OpenDir_destructor); return dir_hnd; } The callers of OpenDir() then check errno if it returns NULL. However, open_internal_dirfsp() is quite a complex beast, calling non_widelink_open and others. The NTSTATUS returned from open_internal_dirfsp() can become disconnected from errno, depending on the module stack. OpenDir_fsp() is very careful to set the correct errno on exit, OpenDir() needs to do the same. Have patch, need bugnumber.
https://gitlab.com/samba-team/samba/-/merge_requests/2122
This bug was referenced in samba master: 72b4fe93f15e414ca3e7d7f0e77a5f0aae90556a
Created attachment 16746 [details] git-am fix for 4.15.0, 4.14.next Both 4.14 and 4.15 need this.
Comment on attachment 16746 [details] git-am fix for 4.15.0, 4.14.next Cherry-picked from master.
Comment on attachment 16746 [details] git-am fix for 4.15.0, 4.14.next lgtm
reassign to Jule for 4.14, 4.15
Pushed to autobuild-v4-{15,14}-test.
This bug was referenced in samba v4-15-test: 34d2bc284607ada608948bfccc7686fb14cb9c39
This bug was referenced in samba v4-15-stable (Release samba-4.15.0rc3): 34d2bc284607ada608948bfccc7686fb14cb9c39
This bug was referenced in samba v4-14-test: 4fbd8a22c3df7fe9ac4d0f17590a1b6fbdb906d3
Closing out bug report. Thanks!
This bug was referenced in samba v4-14-stable (Release samba-4.14.8): 4fbd8a22c3df7fe9ac4d0f17590a1b6fbdb906d3