]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: implement POSIX-FSA 2.1.4.8.1 FileDispositionInformation master
authorRalph Boehme <slow@samba.org>
Mon, 2 Mar 2026 13:26:22 +0000 (14:26 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 18:26:27 +0000 (18:26 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jul 17 18:26:27 UTC 2026 on atb-devel-224

source3/smbd/file_access.c

index e177ed4bf9fb30563f040442ce9531343909f6fe..aa61945919d0ff4a3ffbc0c73caea0858b5b2af6 100644 (file)
@@ -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;
+               }
        }
 
        /*