]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Use helper function msdfs_servicename_matches_connection() in dfs_redirect().
authorJeremy Allison <jra@samba.org>
Tue, 9 Aug 2022 17:58:24 +0000 (10:58 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 12 Aug 2022 18:19:31 +0000 (18:19 +0000)
Replaces ugly complex logic.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/msdfs.c

index a48ae642ae8b75cef4cfe1dc8a6e7d4acfd36957..fce887de9aa7c2b8961a18b447638d2ea0660d78 100644 (file)
@@ -925,11 +925,10 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
                        NTTIME *_twrp,
                        char **pp_path_out)
 {
-       const struct loadparm_substitution *lp_sub =
-               loadparm_s3_global_substitution();
        char *hostname = NULL;
        char *servicename = NULL;
        char *reqpath = NULL;
+       bool servicename_matches = false;
        NTSTATUS status;
 
        status = parse_dfs_path(ctx,
@@ -974,11 +973,11 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
                return NT_STATUS_OK;
        }
 
-       if (!( strequal(servicename, lp_servicename(talloc_tos(), lp_sub, SNUM(conn)))
-                       || (strequal(servicename, HOMES_NAME)
-                       && strequal(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
-                               conn->session_info->unix_info->sanitized_username) )) ) {
-
+       servicename_matches = msdfs_servicename_matches_connection(
+                       conn,
+                       servicename,
+                       conn->session_info->unix_info->sanitized_username);
+       if (!servicename_matches) {
                /* The given sharename doesn't match this connection. */
                return NT_STATUS_OBJECT_PATH_NOT_FOUND;
        }