From: Jeremy Allison Date: Tue, 9 Aug 2022 17:53:18 +0000 (-0700) Subject: s3: smbd: Use helper function msdfs_servicename_matches_connection() in parse_dfs_path(). X-Git-Tag: talloc-2.4.0~1459 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0a1d7c7a8a7f24890e60c7a371498949dec11c2;p=thirdparty%2Fsamba.git s3: smbd: Use helper function msdfs_servicename_matches_connection() in parse_dfs_path(). Replaces ugly complex logic. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 463601cf1ee..a48ae642ae8 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -36,7 +36,6 @@ #include "lib/global_contexts.h" #include "source3/lib/substitute.h" -#if 0 /********************************************************************** Function to determine if a given sharename matches a connection. **********************************************************************/ @@ -80,7 +79,6 @@ done: TALLOC_FREE(conn_servicename); return match; } -#endif /********************************************************************** Parse a DFS pathname of the form /hostname/service/reqpath @@ -112,14 +110,13 @@ static NTSTATUS parse_dfs_path(TALLOC_CTX *ctx, char **_servicename, char **_remaining_path) { - const struct loadparm_substitution *lp_sub = - loadparm_s3_global_substitution(); char *hostname = NULL; char *pathname_local = NULL; char *p = NULL; char *servicename = NULL; char *reqpath = NULL; char *eos_ptr = NULL; + bool servicename_matches = false; pathname_local = talloc_strdup(ctx, pathname); if (pathname_local == NULL) { @@ -196,10 +193,12 @@ static NTSTATUS parse_dfs_path(TALLOC_CTX *ctx, } /* Is this really our servicename ? */ - if (conn && !( strequal(servicename, lp_servicename(talloc_tos(), lp_sub, SNUM(conn))) - || (strequal(servicename, HOMES_NAME) - && strequal(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)), - get_current_username()) )) ) { + servicename_matches = msdfs_servicename_matches_connection( + conn, + servicename, + get_current_username()); + + if (!servicename_matches) { DBG_ERR("%s is not our servicename\n", servicename); /*