]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: apply read-only attribute access restrictions only to files
authorRalph Boehme <slow@samba.org>
Wed, 1 Apr 2026 12:10:38 +0000 (14:10 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 29 Apr 2026 10:56:35 +0000 (10:56 +0000)
Also mask off the exact access rights given in MS_FSA 2.1.5.1.2.1 "Algorithm to
Check Access to an Existing File".

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16030

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/smb2.maximum_allowed
source3/smbd/open.c

index fdaa58a67cc7955ab0cf79da738e5e855cacfe7a..17dad39d48abf7a94a0146f98c66a9afe92887e8 100644 (file)
@@ -1,2 +1 @@
-^samba3.smb2.maximum_allowed.read_only_file\(.*\)
 ^samba3.smb2.maximum_allowed.read_only_dir\(.*\)
index dcaf208f10544fff2e1a1c25411436e8e999d8b4..63da0a3563bbb6da48982b958d13ace65aa4eee9 100644 (file)
@@ -3402,9 +3402,19 @@ static NTSTATUS smbd_calculate_maximum_allowed_access_fsp(
                goto done;
        }
 
-       dosattrs = fdos_mode(fsp);
-       if (dosattrs & FILE_ATTRIBUTE_READONLY) {
-               *p_access_mask &= ~(FILE_GENERIC_WRITE | DELETE_ACCESS);
+       /*
+        * MS_FSA 2.1.5.1.2.1 "Algorithm to Check Access to an Existing File"
+        * has the below, although it misses to state that this only affects
+        * files, not directories.
+        */
+       if (S_ISREG(fsp->fsp_name->st.st_ex_mode)) {
+               dosattrs = fdos_mode(fsp);
+               if (dosattrs & FILE_ATTRIBUTE_READONLY) {
+                       *p_access_mask &= ~(FILE_WRITE_DATA |
+                                           FILE_APPEND_DATA |
+                                           FILE_ADD_SUBDIRECTORY |
+                                           FILE_DELETE_CHILD);
+               }
        }
 
 done: