From: Ralph Boehme Date: Fri, 19 Aug 2022 10:02:43 +0000 (+0200) Subject: smbd: fix opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED X-Git-Tag: talloc-2.4.0~1235 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=772319412df7804236e1cc06056474469bcdcb66;p=thirdparty%2Fsamba.git smbd: fix opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Aug 29 18:20:20 UTC 2022 on sn-devel-184 --- 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 index 80fb1a317c3..00000000000 --- a/selftest/knownfail.d/samba3.smb2.maximum_allowed.read_only +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.maximum_allowed.read_only diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 3dd9f69b8cc..db0cb47d34d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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; }