From: Ralph Boehme Date: Mon, 2 Mar 2026 13:26:22 +0000 (+0100) Subject: smbd: implement POSIX-FSA 2.1.4.8.1 FileDispositionInformation X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e44528f50b59828ae7b3fc2e8c7f2f78d30af668;p=thirdparty%2Fsamba.git smbd: implement POSIX-FSA 2.1.4.8.1 FileDispositionInformation Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Fri Jul 17 18:26:27 UTC 2026 on atb-devel-224 --- diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index e177ed4bf9f..aa61945919d 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -196,12 +196,31 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode) * Only allow delete on close for writable files. */ - if ((dosmode & FILE_ATTRIBUTE_READONLY) && - !lp_delete_readonly(SNUM(fsp->conn))) { - DEBUG(10,("can_set_delete_on_close: file %s delete on close " - "flag set but file attribute is readonly.\n", - fsp_str_dbg(fsp))); - return NT_STATUS_CANNOT_DELETE; + if (dosmode & FILE_ATTRIBUTE_READONLY) { + bool delete_readonly = false; + + if (lp_delete_readonly(SNUM(fsp->conn))) { + delete_readonly = true; + } else if (fsp->fsp_flags.posix_open && + fsp->access_mask & FILE_WRITE_ATTRIBUTES) + { + delete_readonly = true; + } else if (fsp->fsp_flags.posix_open) { + status = smbd_check_access_rights_fsp( + fsp->conn->cwd_fsp, + fsp, + false, + FILE_WRITE_ATTRIBUTES); + if (NT_STATUS_IS_OK(status)) { + delete_readonly = true; + } + } + if (!delete_readonly) { + DBG_DEBUG("file %s delete on close " + "flag set but file attribute is readonly.\n", + fsp_str_dbg(fsp)); + return NT_STATUS_CANNOT_DELETE; + } } /*