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: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
: 15493 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-11-21 09:28 UTC by Ralph Böhme
Modified: 2024-02-19 10:47 UTC (History)
5 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
Patch for 4.19 backported from master (52.32 KB, patch)
2024-01-09 09:59 UTC, Ralph Böhme
metze: review+
Details
Patch for 4.18 backported from master (52.40 KB, patch)
2024-01-09 10:01 UTC, Ralph Böhme
metze: 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!
Comment 10 Ralph Böhme 2023-12-22 15:31:52 UTC
This is not working anymore in recent Samba versions. Have patches...
Comment 11 Ralph Böhme 2024-01-03 11:37:39 UTC
*** Bug 15493 has been marked as a duplicate of this bug. ***
Comment 12 Samba QA Contact 2024-01-08 16:59:03 UTC
This bug was referenced in samba master:

78119edba013583555069271bb61134c12c2c135
c62484bc2c60ebac42635793d94cb8e62629acbf
537eedfe2a79fba2e1f062f14ba7a0c5f8f70a88
276c5bd851ab6ab818a49d9c47f6b96de8024778
76c8fe16bff36a29fa326355256b50737d04bd85
96b577c380fa914eb1ffa95849c82bdb88aa1ec6
bf497819e61131cfa6469971596af3aa9bd4bb49
a0ae45be770a13373c148a689b9761f14c4f942c
ee3035218df4cfd68b6aab6825c78f2b85234c6c
995a31c8d4c1789c16bae6b8196f2565d4b1dfdb
02ed99343d19fd0845531ad99a46b1dd5b8a7a4f
fd4e41144a819b4403340e4a28664ac586722b41
f14a7065690b00e3c6af2c1f0b0aec51c1e0b372
Comment 13 Ralph Böhme 2024-01-09 09:59:26 UTC
Created attachment 18222 [details]
Patch for 4.19 backported from master
Comment 14 Ralph Böhme 2024-01-09 10:01:01 UTC
Created attachment 18223 [details]
Patch for 4.18 backported from master
Comment 15 Jule Anger 2024-01-09 12:12:13 UTC
Pushed to autobuild-v4-{19,18}-test.
Comment 16 Samba QA Contact 2024-01-09 13:18:04 UTC
This bug was referenced in samba v4-19-test:

b6c2c26e9ba02b6b7b0843e8a01344c774974dee
bb9aea6a7e69b92d76cc09812de8887e1ea6930c
a510fc46bcd0fc6e78d51eebdbbb7fbb44a134de
b838378024966ac75119d6426380178f8c482a16
9ee7991d97dfc0aeaecc12816d6e7a34b74106e8
0f865a34f1a080e35ce6a4c19fec80a84c7b8dc9
8318428f3f8dbdbc7ff11f2755ae6b702049c72d
0352aae6ea1e8c38ca8ca091123ddde455c2e5ab
bfa5f1780990e4f763f0214fb660c64c53188e65
44396d7bade98b41fb655e30d84195793684f593
f5eb449cac82de61c4eadc1b134c92896f69aacf
0874d3ab3e1cb7e42900da9543963799b864e485
cfbaab5654cc40ef08ab09492d20aac2f33cbf0e
Comment 17 Samba QA Contact 2024-01-16 10:06:03 UTC
This bug was referenced in samba v4-18-test:

29f629a155faae5945414b912a5f248c1d7fd43a
469c91c4133e18700a19558910449e59957afccd
7080c5b4850c39c63e61d458d5928151fa7f1c00
c8e1d26cea525c6d0642923bf1b5196813145744
d87294724e6066870346ff90b16c76fcfd294b9c
b775434b7eb1a08fff283e153817f3e0376c9af8
8c08511f97d0915fdc87c77f4c5a815e1dcfb42a
8ee0768d6f2c1b79a4ad381f0cef1ae32a9618b7
15536403f631e757b8d3db77ea442cb858e03bd3
77a71bc9932acc7e73fe4b89443bf500c0374a98
d3f062e21224f720ca724dee740ade5d56748da1
1e108b3ac072ac396fc07f4cb4073217af2877bf
ee2df0bbb3429ca2bece2b651e00182453d1b089
Comment 18 Jule Anger 2024-01-22 08:42:22 UTC
Closing out bug report.

Thanks!
Comment 19 Samba QA Contact 2024-01-31 20:42:22 UTC
This bug was referenced in samba v4-18-stable (Release samba-4.18.10):

29f629a155faae5945414b912a5f248c1d7fd43a
469c91c4133e18700a19558910449e59957afccd
7080c5b4850c39c63e61d458d5928151fa7f1c00
c8e1d26cea525c6d0642923bf1b5196813145744
d87294724e6066870346ff90b16c76fcfd294b9c
b775434b7eb1a08fff283e153817f3e0376c9af8
8c08511f97d0915fdc87c77f4c5a815e1dcfb42a
8ee0768d6f2c1b79a4ad381f0cef1ae32a9618b7
15536403f631e757b8d3db77ea442cb858e03bd3
77a71bc9932acc7e73fe4b89443bf500c0374a98
d3f062e21224f720ca724dee740ade5d56748da1
1e108b3ac072ac396fc07f4cb4073217af2877bf
ee2df0bbb3429ca2bece2b651e00182453d1b089
Comment 20 Samba QA Contact 2024-02-19 10:47:16 UTC
This bug was referenced in samba v4-19-stable (Release samba-4.19.5):

b6c2c26e9ba02b6b7b0843e8a01344c774974dee
bb9aea6a7e69b92d76cc09812de8887e1ea6930c
a510fc46bcd0fc6e78d51eebdbbb7fbb44a134de
b838378024966ac75119d6426380178f8c482a16
9ee7991d97dfc0aeaecc12816d6e7a34b74106e8
0f865a34f1a080e35ce6a4c19fec80a84c7b8dc9
8318428f3f8dbdbc7ff11f2755ae6b702049c72d
0352aae6ea1e8c38ca8ca091123ddde455c2e5ab
bfa5f1780990e4f763f0214fb660c64c53188e65
44396d7bade98b41fb655e30d84195793684f593
f5eb449cac82de61c4eadc1b134c92896f69aacf
0874d3ab3e1cb7e42900da9543963799b864e485
cfbaab5654cc40ef08ab09492d20aac2f33cbf0e