[linux-cifs-client] [PATCH] cifs: handle DFS path_names that
don't start with double backslash
Jeff Layton
jlayton at redhat.com
Mon Dec 15 20:48:27 GMT 2008
On Mon, 15 Dec 2008 07:47:08 -0500
Jeff Layton <jlayton at redhat.com> wrote:
> Apparently some servers (notably, Samba 3.0.x) do not respond to DFS
> referrals with a DFS path_name that begins with a double backslash. When
> this occurs, the path_consumed sent is generally too short by 1
> character. Fix this by checking whether the second character in the
> path_name is a '\'. If not, then adjust path_consumed by 1 when
> building the mount option string.
>
> Tested against Samba 3.0.28-ish server and Win2k8.
>
> Signed-off-by: Jeff Layton <jlayton at redhat.com>
> ---
> fs/cifs/cifs_dfs_ref.c | 14 +++++++++++---
> 1 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
> index e1c1836..9185dfa 100644
> --- a/fs/cifs/cifs_dfs_ref.c
> +++ b/fs/cifs/cifs_dfs_ref.c
> @@ -127,7 +127,7 @@ static char *compose_mount_options(const char *sb_mountdata,
> char *tkn_e;
> char *srvIP = NULL;
> char sep = ',';
> - int off, noff;
> + int off, noff, path_consumed;
> char *fullpath;
>
> if (sb_mountdata == NULL)
> @@ -200,14 +200,22 @@ static char *compose_mount_options(const char *sb_mountdata,
> if (tkn_e == NULL) /* invalid unc, missing share name*/
> goto compose_mount_options_out;
>
> + /*
> + * Some servers do not send a path_name that starts with a double '\\'.
> + * This means that path_consumed will be off by one.
> + */
> + path_consumed = ref->path_consumed;
> + if (ref->path_name[1] != '\\')
> + path_consumed++;
> +
> fullpath = build_path_from_dentry(dentry);
> tkn_e = strchr(tkn_e + 1, '\\');
> - if (tkn_e || strlen(fullpath) - (ref->path_consumed)) {
> + if (tkn_e || strlen(fullpath) - path_consumed) {
> strncat(mountdata, &sep, 1);
> strcat(mountdata, "prefixpath=");
> if (tkn_e)
> strcat(mountdata, tkn_e + 1);
> - strcat(mountdata, fullpath + (ref->path_consumed));
> + strcat(mountdata, fullpath + path_consumed);
> }
> kfree(fullpath);
>
Actually...self-NAK on this patch too...
I think I see the problem. The paths in DFS request and response are
supposed to only have a single backslash prefix, but we're sending them
with double backslashes. Samba recognizes this and sends back a
properly formed response, but windows sends back the path with an extra
preceding backslash when we do that. I think we need to fix that bug in
the client as well. I'll respin the patch, recheck the results and
repost...
--
Jeff Layton <jlayton at redhat.com>
More information about the linux-cifs-client
mailing list