[cifs-protocol] [MS-SMB 184.108.40.206.1 <6>] Opening previous version of a file with WRITE access
realrichardsharpe at gmail.com
Fri Nov 16 19:17:24 UTC 2018
On Fri, Nov 16, 2018 at 11:04 AM Ralph Böhme via cifs-protocol
<cifs-protocol at lists.samba.org> wrote:
> Hello dochelp,
> I was debuging an interesting problem in the context previous versions of a file
> on a Samba server, opened from a Windows client.
> The unexpected client behaviour I obverved was a Windows 2016 client opening a
> previous version of a file over SMB2 for reading *and* writing (Access Mask:
> 0x0012019f). pcap available on request.
> With Samba this fails, in the specific configuration involving the VFS module
> shadow_copy2 with ZFS snapshots on FreeBSD, as we map the SMB layer access mask
> to O_RDWR for the POSIX open and when calling open() on the file in a ZFS
> snapshot with mode=O_RDWR, unsurprisingly this fails with EROFS.
> Now the interesting part.
> The same open of a previous version of a file over SMB2 against a Windows 2016
> server succeeds, *but* then a subsequent write on the handle files with
> STATUS_MEDIA_WRITE_PROTECTED, pcap attached. I've reproduced this with a Samba
> smbtorture test as client, cf attached pcap "twrp_write_w16.pcapng" packet 18.
In my experience this is standard Windows behavior. In a previous life
we handled this by changing the open to a RO open and then failing
with the correct response on the WRITE-like requests.
> The only section I could find in the protocol documentation dealing with opens
> of previous versions and the requested access mask is [MS-SMB 220.127.116.11.1 <6>]
> where we read:
> When enabled previous versions of files are accessible as read-only.
> Related to this question is how a server is supposed to return effective
> permissions of a previous version of a file. In the attached pcap the Windows
> 2016 server return "Access Mask: 0x001f01ff".
> 1. What is the expected behaviour for an SMB server for opens of previous
> version of a file with regard to the desired access bits? Is this documented
> anywhere in the protocol documentation?
> 2. What is the expected behaviour for an SMB server for opens of previous
> version of a file with regard to queries for effective permissions? Is this
> documented anywhere in the protocol documentation?
> Thanks a lot!
> Ralph Boehme, Samba Team https://samba.org/
> Samba Developer, SerNet GmbH https://sernet.de/en/samba/
> GPG Key Fingerprint: FAE2 C608 8A24 2520 51C5
> 59E4 AA1E 9B71 2639 9E46
> cifs-protocol mailing list
> cifs-protocol at lists.samba.org
More information about the cifs-protocol