Bug 12150 - SMB2 snapshot query fails on DFS shares.
Summary: SMB2 snapshot query fails on DFS shares.
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (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: 2016-08-12 23:50 UTC by Jeremy Allison
Modified: 2021-01-11 11:22 UTC (History)
3 users (show)

See Also:


Attachments
git-am fix for 4.5.0, 4.4.x, 4.3.x (1.62 KB, patch)
2016-08-15 22:26 UTC, Jeremy Allison
no flags Details
Full patchset fix for 4.5.0 (9.65 KB, patch)
2016-08-24 23:23 UTC, Jeremy Allison
cs: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Allison 2016-08-12 23:50:36 UTC
From: Christof Schmitt <cs@samba.org>
Date: Fri, 12 Aug 2016 14:59:07 -0700
Subject: [PATCH] smbd: Fix snapshot query on shares with DFS enabled

When DFS is enabled (host msdfs = yes and msdfs root = yes), then SMB
clients send create requests in the format \hostname\service\path.

The smbd SMB2 TWRP code currently creates the required path as below:

                       fname = talloc_asprintf(state,
                                        "@GMT-%04u.%02u.%02u-%02u.%02u.%02u\\%s",
                                        tm->tm_year + 1900,
                                        tm->tm_mon + 1,
                                        tm->tm_mday,
                                        tm->tm_hour,
                                        tm->tm_min,
                                        tm->tm_sec,
                                        in_name);

Putting the GMT tag as first element breaks the DFS parsing and results
in OBJECT_NOT_FOUND for snapshotted files.  Fix this by appending the
GMT tag to the end of the path.

                        fname = talloc_asprintf(state,
                                        "%s\\@GMT-%04u.%02u.%02u-%02u.%02u.%02u",
                                        in_name,
                                        tm->tm_year + 1900,
                                        tm->tm_mon + 1,
                                        tm->tm_mday,
                                        tm->tm_hour,
                                        tm->tm_min,
                                        tm->tm_sec);
Comment 1 Jeremy Allison 2016-08-15 22:26:39 UTC
Created attachment 12372 [details]
git-am fix for 4.5.0, 4.4.x, 4.3.x

Cherry picked from master.
Comment 2 Jeremy Allison 2016-08-15 23:41:10 UTC
Comment on attachment 12372 [details]
git-am fix for 4.5.0, 4.4.x, 4.3.x

I just came across one more thing: The test is on a system with the
shadowcopy2 module enabled. While the patches fixes the problem for
directories, there seems to be an issue when a SMB client is explicitly
asking for older versions of a file. It looks like shadowcopy leaves a
trailing slash from the GMT tag removal:

(test is a file, not  a directory)

[2016/08/15 16:12:36.178799, 10, pid=13125, effective(12000500, 12000513), real(12000500, 0)] ../source3/modules/vfs_shadow_copy2.c:245(shadow_copy2_strip_snapshot)
  ../source3/modules/vfs_shadow_copy2.c:245: enter path 'test/@GMT-2016.08.12-19.56.11'
[2016/08/15 16:12:36.178814, 10, pid=13125, effective(12000500, 12000513), real(12000500, 0)] ../source3/modules/vfs_shadow_copy2.c:462(shadow_copy2_do_convert)
 converting 'test/'
[2016/08/15 16:12:36.178837, 10, pid=13125, effective(12000500, 12000513), real(12000500, 0)] ../source3/modules/vfs_shadow_copy2.c:604(shadow_copy2_do_convert)
 Trying[snapdirseverywhere] /fs1/smbexport1/test/.snapshots/@GMT-2016.08.12-19.56.11/: -1 (Not a directory)
[2016/08/15 16:12:36.178860, 10, pid=13125, effective(12000500, 12000513), real(12000500, 0)] ../source3/modules/vfs_shadow_copy2.c:604(shadow_copy2_do_convert)
 Trying[snapdirseverywhere] /fs1/smbexport1/.snapshots/@GMT-2016.08.12-19.56.11/test/: -1 (No such file or directory)
[2016/08/15 16:12:36.178886, 10, pid=13125, effective(12000500, 12000513), real(12000500, 0)] ../source3/modules/vfs_shadow_copy2.c:604(shadow_copy2_do_convert)
 Trying[snapdirseverywhere] /fs1/.snapshots/@GMT-2016.08.12-19.56.11/smbexport1/test/: -1 (Not a directory)
Comment 3 Jeremy Allison 2016-08-24 23:23:16 UTC
Created attachment 12397 [details]
Full patchset fix for 4.5.0

Cherry-picked from master.
Comment 4 Jeremy Allison 2016-08-25 15:42:46 UTC
Reassigning to Karolin for inclusion in 4.5.0.
Comment 5 Stefan Metzmacher 2016-08-28 16:12:32 UTC
Pushed to autobuild-v4-5-test.
Comment 6 Stefan Metzmacher 2016-08-29 02:47:01 UTC
Pushed to v4-5-test.