Initializing case based parameters during share switch in create_conn_struct_tos_cwd()

Jeremy Allison jra at
Tue Jan 12 19:13:28 UTC 2021

On Fri, Jan 08, 2021 at 03:27:20PM +0530, Shilpa K via samba-technical wrote:
>We are creating DFS referrals when a folder is created under the share
>root. In one instance, an user was trying to create a folder with the name
>"FOLDER~1" (with exactly 8 chars in the folder name) from Windows. So, we
>created the DFS referral with the name ending "FOLDER~1" and returned the
>error STATUS_PATH_NOT_COVERED to the client. Then,the client had sent
>DFS_GET_REFERRALS request. While  processing this request, when
>unix_convert() is called as part of returning the referral, it was
>normalizing the name to lowercase because the name is a mangled name and
>the below parameters were null:
>conn->case sensitive = 0
>conn->share_case_preserve = 0
>and default case is lower
>The case_sensitive and short_case_preserve were null because we were not
>initializing these values in conn struct to the share configuration that we
>were switching to. We are using below settings for the share:
>case sensitive = no
>preserve case = yes
>short preserve case = yes
>default case = lower
>I used the code changes that are in the below patch and now we return the
>folder name in the referral as is. Could you please review this patch and
>let me know if it is fine?

Thanks Shilpa, this does look correct. It sets up the
dfs share in the same way as the case options are created
in source3/smbd/service.c:make_connection_snum().

I think the best fix here would be to factor this code
out into a function called by both make_connection_snum()
and create_conn_struct_as_root() so we know they are
setting things up identically.

I'll set up a gitlab-MR for this. Thanks for your
help !

>  diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
>index 50014e1832..d39d7ee859 100644
>--- a/source3/smbd/msdfs.c
>+++ b/source3/smbd/msdfs.c
>@@ -427,6 +427,17 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX
>        }
>        conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn,
>+  /* Case options for the share. */
>+  if (lp_case_sensitive(snum) == Auto) {
>+    conn->case_sensitive = False;
>+  } else {
>+    conn->case_sensitive = lp_case_sensitive(snum) == 1;
>+  }
>+  conn->case_preserve = lp_preserve_case(snum);
>+  conn->short_case_preserve = lp_short_preserve_case(snum);
>        *pconn = conn;
>        return NT_STATUS_OK;

More information about the samba-technical mailing list