Bug 13688 - Windows 2016 fails to restore previous version of a file from a shadow_copy2 snapshot
Summary: Windows 2016 fails to restore previous version of a file from a shadow_copy2 ...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-21 09:28 UTC by Ralph Böhme
Modified: 2018-12-17 11:31 UTC (History)
3 users (show)

See Also:


Attachments
Possible patch for master (3.77 KB, patch)
2018-11-21 09:30 UTC, Ralph Böhme
no flags Details
Patch for 4.9 backported from master (22.62 KB, patch)
2018-12-03 11:41 UTC, Ralph Böhme
jra: review+
Details
Patch for 4.8 backported from master (22.62 KB, patch)
2018-12-06 11:28 UTC, Ralph Böhme
jra: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Böhme 2018-11-21 09:28:53 UTC
The client asks for write access on the snapshot file which fails when Samba does the POSIX open() with O_RDWR with EROFS.

The interesting bit: Windows SMB server allows opening a snapshot file for writing, but fails any attempt to use the handle for writing with STATUS_MEDIA_WRITE_PROTECTED.

See also: https://lists.samba.org/archive/cifs-protocol/2018-November/003185.html

Possible fix: do the open O_RDONLY. Any subsequent write on the handle will fail with EINVAL, map that to EROFS.
Comment 1 Ralph Böhme 2018-11-21 09:30:20 UTC
Created attachment 14671 [details]
Possible patch for master
Comment 2 Ralph Böhme 2018-11-21 09:30:52 UTC
Now waiting for dochelp...
Comment 3 Ralph Böhme 2018-12-03 11:41:20 UTC
Created attachment 14713 [details]
Patch for 4.9 backported from master

The patch for this bug must be pushed before #13455.
Comment 4 Jeremy Allison 2018-12-05 20:08:20 UTC
Comment on attachment 14713 [details]
Patch for 4.9 backported from master

Applies cleanly to 4.9.next, but not 4.8.next:

Applying: vfs_shadow_copy2: nicely deal with attempts to open previous version for writing
error: patch failed: source3/modules/vfs_shadow_copy2.c:3249
error: source3/modules/vfs_shadow_copy2.c: patch does not apply
Patch failed at 0007 vfs_shadow_copy2: nicely deal with attempts to open previous version for writing

Ralph, can you update for 4.8.next ?
Comment 5 Ralph Böhme 2018-12-06 11:28:36 UTC
Created attachment 14722 [details]
Patch for 4.8 backported from master

This one should work, sorry!

No idea what happened, I generally cherry-pick on 4.9, then create a patchset which I apply with git am to 4.8. If it applies, I attach one patchset for both versions. Must have messed up something...
Comment 6 Ralph Böhme 2018-12-06 11:29:34 UTC
Let me reiterate that this one must be applied before bug #13455.
Comment 7 Jeremy Allison 2018-12-08 00:36:08 UTC
Re-assigning to Karolin for inclusion in 4.8.next, 4.9.next.
Comment 8 Karolin Seeger 2018-12-13 12:45:37 UTC
(In reply to Jeremy Allison from comment #7)
Pushed to autobuild-v4-{9,8}-test.
Comment 9 Karolin Seeger 2018-12-17 11:31:16 UTC
(In reply to Karolin Seeger from comment #8)
Pushed to both branches.
Closing out bug report.

Thanks!