]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: fix opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED
authorRalph Boehme <slow@samba.org>
Fri, 19 Aug 2022 10:02:43 +0000 (12:02 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 29 Aug 2022 18:20:19 +0000 (18:20 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Aug 29 18:20:20 UTC 2022 on sn-devel-184

selftest/knownfail.d/samba3.smb2.maximum_allowed.read_only [deleted file]
source3/smbd/open.c

diff --git a/selftest/knownfail.d/samba3.smb2.maximum_allowed.read_only b/selftest/knownfail.d/samba3.smb2.maximum_allowed.read_only
deleted file mode 100644 (file)
index 80fb1a3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.maximum_allowed.read_only
index 3dd9f69b8ccdbacce94e15d7539559952dc1fbfa..db0cb47d34d66f1be0f0a1a23804fa53c0d4f75b 100644 (file)
@@ -3269,6 +3269,7 @@ static NTSTATUS smbd_calculate_maximum_allowed_access_fsp(
 {
        struct security_descriptor *sd = NULL;
        uint32_t access_granted = 0;
+       uint32_t dosattrs;
        NTSTATUS status;
 
        /* Cope with symlinks */
@@ -3345,6 +3346,11 @@ static NTSTATUS smbd_calculate_maximum_allowed_access_fsp(
                }
        }
 
+       dosattrs = fdos_mode(fsp);
+       if (IS_DOS_READONLY(dosattrs) || !CAN_WRITE(fsp->conn)) {
+               *p_access_mask &= ~(FILE_GENERIC_WRITE | DELETE_ACCESS);
+       }
+
        return NT_STATUS_OK;
 }