The Samba-Bugzilla – Bug 11440
s3: smbd returned 'Permission denied' after copied a file to the read-only share.
Last modified: 2015-08-16 15:24:27 UTC
When trying to to delete a file on a read-only share it does give the expected 'Read-only file system' error message.
When using a Linux (CentOS 7) or Windows 2008/Cygwin client, 'cp' gives 'Permission denied' when trying to write to a read-only share.
The error message is slightly misleading in this case, as it would make the user think that there is a file (directory) permission issue, when in fact, it is a file-system level access issue.
It looks like Samba checks the requested access mask against the share access mask through source3/smbd/open.c::smbd_calculate_access_mask(). It will return NT_STATUS_ACCESS_DENIED, which is mapped to EPERM. It doesn't differentiate whether it is a WRITE on a read-only or any other access mask denied error.