The Samba-Bugzilla – Attachment 12397 Details for
Bug 12150
SMB2 snapshot query fails on DFS shares.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Full patchset fix for 4.5.0
bug-12150-4.5.0 (text/plain), 9.65 KB, created by
Jeremy Allison
on 2016-08-24 23:23:16 UTC
(
hide
)
Description:
Full patchset fix for 4.5.0
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2016-08-24 23:23:16 UTC
Size:
9.65 KB
patch
obsolete
>From be49b032da16a7a103f492021957e026728a030b Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Fri, 12 Aug 2016 14:59:07 -0700 >Subject: [PATCH 1/6] 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. >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. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> > >Autobuild-User(master): Jeremy Allison <jra@samba.org> >Autobuild-Date(master): Sat Aug 13 05:44:39 CEST 2016 on sn-devel-144 > >(cherry picked from commit f1b42ec778e08875e076df7fdf67dd69bf9b2757) >--- > source3/smbd/smb2_create.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c >index 4c1b81d..75da8a1 100644 >--- a/source3/smbd/smb2_create.c >+++ b/source3/smbd/smb2_create.c >@@ -913,14 +913,14 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, > > TALLOC_FREE(fname); > fname = talloc_asprintf(state, >- "@GMT-%04u.%02u.%02u-%02u.%02u.%02u\\%s", >+ "%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, >- in_name); >+ tm->tm_sec); > if (tevent_req_nomem(fname, req)) { > return tevent_req_post(req, ev); > } >-- >2.8.0.rc3.226.g39d4020 > > >From ff9c5d660704cad2108bb6de7b66793cb0112fb4 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Tue, 16 Aug 2016 09:41:43 -0700 >Subject: [PATCH 2/6] s3: vfs: shadow_copy2: Re-use an existing variable > already set to the right value (p - name). > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit 6245f2c042da55c71086e1d40186b11964ddeba8) >--- > source3/modules/vfs_shadow_copy2.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c >index bda934e..b1aae1e 100644 >--- a/source3/modules/vfs_shadow_copy2.c >+++ b/source3/modules/vfs_shadow_copy2.c >@@ -486,7 +486,8 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, > * with a path prefix. > */ > if (pstripped != NULL) { >- stripped = talloc_strndup(mem_ctx, name, p - name); >+ stripped = talloc_strndup(mem_ctx, name, >+ len_before_gmt); > if (stripped == NULL) { > return false; > } >-- >2.8.0.rc3.226.g39d4020 > > >From cc7b5c0236e0682619443a68bba691b4db527abd Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Tue, 16 Aug 2016 09:43:37 -0700 >Subject: [PATCH 3/6] s3: vfs: shadow_copy2. Remove any trailing slash when > stripping @GMT-YYYY... from the end of a path. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> > >Autobuild-User(master): Jeremy Allison <jra@samba.org> >Autobuild-Date(master): Wed Aug 17 05:25:30 CEST 2016 on sn-devel-144 > >(cherry picked from commit 639063da8c5077170bfe2dc4d3a69c3219a4f6a1) >--- > source3/modules/vfs_shadow_copy2.c | 7 +++++++ > 1 file changed, 7 insertions(+) > >diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c >index b1aae1e..4ac16d3 100644 >--- a/source3/modules/vfs_shadow_copy2.c >+++ b/source3/modules/vfs_shadow_copy2.c >@@ -486,6 +486,13 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, > * with a path prefix. > */ > if (pstripped != NULL) { >+ if (len_before_gmt > 0) { >+ /* >+ * There is a slash before >+ * the @GMT-. Remove it. >+ */ >+ len_before_gmt -= 1; >+ } > stripped = talloc_strndup(mem_ctx, name, > len_before_gmt); > if (stripped == NULL) { >-- >2.8.0.rc3.226.g39d4020 > > >From d17cf79c9efa4e3d3a726e1fae34e47aced2d2e4 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 17 Aug 2016 10:49:50 -0700 >Subject: [PATCH 4/6] s3: vfs: shadow_copy2: Replace all uses of (p-name) with > len_before_gmt. > >p and name don't change, and we've already calculated this length. >Part of the effort to make the code inside vfs_snapper.c that does >the same thing more similar (we can't make these functions identical >due to the 'snapdir' use case). > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >(cherry picked from commit abf18f42dc398f5f17088de87fd0e681fd44ebeb) >--- > source3/modules/vfs_shadow_copy2.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c >index 4ac16d3..2a72740 100644 >--- a/source3/modules/vfs_shadow_copy2.c >+++ b/source3/modules/vfs_shadow_copy2.c >@@ -514,7 +514,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, > q += 1; > > rest_len = strlen(q); >- dst_len = (p-name) + rest_len; >+ dst_len = len_before_gmt + rest_len; > > if (priv->config->snapdirseverywhere) { > char *insert; >@@ -580,10 +580,10 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, > return false; > } > if (p > name) { >- memcpy(stripped, name, p-name); >+ memcpy(stripped, name, len_before_gmt); > } > if (rest_len > 0) { >- memcpy(stripped + (p-name), q, rest_len); >+ memcpy(stripped + len_before_gmt, q, rest_len); > } > stripped[dst_len] = '\0'; > *pstripped = stripped; >-- >2.8.0.rc3.226.g39d4020 > > >From 0009373ca2b59b996af07cf1e49b99a62e03c5c3 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 17 Aug 2016 10:53:08 -0700 >Subject: [PATCH 5/6] s3: vfs: snapper: Add and use len_before_gmt, calculated > as (p-name). > >Make the code closer to the same functionality in shadow_copy2.c:shadow_copy2_strip_snapshot(). > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >(cherry picked from commit 3e3b9be948d873696a1ab9c0cb859bd8911165f0) >--- > source3/modules/vfs_snapper.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > >diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c >index 8f3c647..f5ccc15 100644 >--- a/source3/modules/vfs_snapper.c >+++ b/source3/modules/vfs_snapper.c >@@ -1729,6 +1729,7 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > char *q; > char *stripped; > size_t rest_len, dst_len; >+ ptrdiff_t len_before_gmt; > > p = strstr_m(name, "@GMT-"); > if (p == NULL) { >@@ -1737,6 +1738,7 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > if ((p > name) && (p[-1] != '/')) { > goto no_snapshot; > } >+ len_before_gmt = p - name; > q = strptime(p, GMT_FORMAT, &tm); > if (q == NULL) { > goto no_snapshot; >@@ -1763,7 +1765,7 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > q += 1; > > rest_len = strlen(q); >- dst_len = (p-name) + rest_len; >+ dst_len = len_before_gmt + rest_len; > > if (pstripped != NULL) { > stripped = talloc_array(mem_ctx, char, dst_len+1); >@@ -1772,10 +1774,10 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > return false; > } > if (p > name) { >- memcpy(stripped, name, p-name); >+ memcpy(stripped, name, len_before_gmt); > } > if (rest_len > 0) { >- memcpy(stripped + (p-name), q, rest_len); >+ memcpy(stripped + len_before_gmt, q, rest_len); > } > stripped[dst_len] = '\0'; > *pstripped = stripped; >-- >2.8.0.rc3.226.g39d4020 > > >From 23e42a9e117629e13a8b52c21d7b0b74055b9341 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 17 Aug 2016 10:57:10 -0700 >Subject: [PATCH 6/6] s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() > function to strip @GMT token identically to > shadow_copy2.c:shadow_copy2_strip_snapshot() > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> > >Autobuild-User(master): David Disseldorp <ddiss@samba.org> >Autobuild-Date(master): Thu Aug 18 06:43:02 CEST 2016 on sn-devel-144 > >(cherry picked from commit b21308252eb409bad6089cc0f09fada0229d33e8) >--- > source3/modules/vfs_snapper.c | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > >diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c >index f5ccc15..5c1821d 100644 >--- a/source3/modules/vfs_snapper.c >+++ b/source3/modules/vfs_snapper.c >@@ -1748,9 +1748,23 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > if (timestamp == (time_t)-1) { > goto no_snapshot; > } >- if ((p == name) && (q[0] == '\0')) { >+ if (q[0] == '\0') { >+ /* >+ * The name consists of only the GMT token or the GMT >+ * token is at the end of the path. XP seems to send >+ * @GMT- at the end under certain circumstances even >+ * with a path prefix. >+ */ > if (pstripped != NULL) { >- stripped = talloc_strdup(mem_ctx, ""); >+ if (len_before_gmt > 0) { >+ /* >+ * There is a slash before >+ * the @GMT-. Remove it. >+ */ >+ len_before_gmt -= 1; >+ } >+ stripped = talloc_strndup(mem_ctx, name, >+ len_before_gmt); > if (stripped == NULL) { > return false; > } >@@ -1760,6 +1774,10 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx, > return true; > } > if (q[0] != '/') { >+ /* >+ * It is not a complete path component, i.e. the path >+ * component continues after the gmt-token. >+ */ > goto no_snapshot; > } > q += 1; >-- >2.8.0.rc3.226.g39d4020 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
cs
:
review+
Actions:
View
Attachments on
bug 12150
:
12372
| 12397