]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Remove the old dfs_path_lookup() code.
authorJeremy Allison <jra@samba.org>
Tue, 9 Aug 2022 19:13:10 +0000 (12:13 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 12 Aug 2022 18:19:31 +0000 (18:19 +0000)
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 55ab12a75e36e043844cee291092940f3ef79f0a..4819df35837827d319e7f4e44f00ea1f379b8e01 100644 (file)
@@ -972,197 +972,6 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
        return status;
 }
 
-#if 0
-/*****************************************************************
- Used by other functions to decide if a dfs path is remote,
- and to get the list of referred locations for that remote path.
-
- consumedcntp: how much of the dfs path is being redirected. the client
- should try the remaining path on the redirected server.
-
- If this returns NT_STATUS_PATH_NOT_COVERED the contents of the msdfs
- link redirect are in targetpath.
-*****************************************************************/
-
-static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
-               connection_struct *conn,
-               const char *dfspath, /* Incoming complete dfs path */
-               const char *reqpath, /* Parsed out remaining path. */
-               uint32_t ucf_flags,
-               NTTIME *_twrp,
-               size_t *consumedcntp,
-               struct referral **ppreflist,
-               size_t *preferral_count)
-{
-       char *p = NULL;
-       char *q = NULL;
-       NTSTATUS status;
-       struct smb_filename *smb_fname = NULL;
-       struct smb_filename *parent_fname = NULL;
-       struct smb_filename *atname = NULL;
-       char *canon_dfspath = NULL; /* Canonicalized dfs path. (only '/'
-                                 components). */
-
-       DEBUG(10,("dfs_path_lookup: Conn path = %s reqpath = %s\n",
-               conn->connectpath, reqpath));
-
-       /*
-        * Note the unix path conversion here we're doing we
-        * throw away. We're looking for a symlink for a dfs
-        * resolution, if we don't find it we'll do another
-        * unix_convert later in the codepath.
-        */
-
-       status = unix_convert(ctx, conn, reqpath, 0, &smb_fname,
-                             ucf_flags);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               if (!NT_STATUS_EQUAL(status,
-                                    NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
-                       return status;
-               }
-               if (smb_fname == NULL || smb_fname->base_name == NULL) {
-                       return status;
-               }
-       }
-
-       /* Optimization - check if we can redirect the whole path. */
-       status = parent_pathref(ctx,
-                               conn->cwd_fsp,
-                               smb_fname,
-                               &parent_fname,
-                               &atname);
-       if (NT_STATUS_IS_OK(status)) {
-               /*
-                * We must have a parent_fname->fsp before
-                * we can call SMB_VFS_READ_DFS_PATHAT().
-                */
-               status = SMB_VFS_READ_DFS_PATHAT(conn,
-                                                ctx,
-                                                parent_fname->fsp,
-                                                atname,
-                                                ppreflist,
-                                                preferral_count);
-               /* We're now done with parent_fname and atname. */
-               TALLOC_FREE(parent_fname);
-
-               if (NT_STATUS_IS_OK(status)) {
-                       DBG_INFO("%s resolves to a valid dfs link\n",
-                                dfspath);
-
-                       if (consumedcntp) {
-                               *consumedcntp = strlen(dfspath);
-                       }
-                       status = NT_STATUS_PATH_NOT_COVERED;
-                       goto out;
-               }
-       }
-
-       /* Prepare to test only for '/' components in the given path,
-        * so if a Windows path replace all '\\' characters with '/'.
-        * For a POSIX DFS path we know all separators are already '/'. */
-
-       canon_dfspath = talloc_strdup(ctx, dfspath);
-       if (!canon_dfspath) {
-               status = NT_STATUS_NO_MEMORY;
-               goto out;
-       }
-       string_replace(canon_dfspath, '\\', '/');
-
-       /*
-        * localpath comes out of unix_convert, so it has
-        * no trailing backslash. Make sure that canon_dfspath hasn't either.
-        * Fix for bug #4860 from Jan Martin <Jan.Martin@rwedea.com>.
-        */
-
-       trim_char(canon_dfspath,0,'/');
-
-       /*
-        * Redirect if any component in the path is a link.
-        * We do this by walking backwards through the
-        * local path, chopping off the last component
-        * in both the local path and the canonicalized
-        * DFS path. If we hit a DFS link then we're done.
-        */
-
-       p = strrchr_m(smb_fname->base_name, '/');
-       if (consumedcntp) {
-               q = strrchr_m(canon_dfspath, '/');
-       }
-
-       while (p) {
-               *p = '\0';
-               if (q) {
-                       *q = '\0';
-               }
-
-               /*
-                * Ensure parent_pathref() calls vfs_stat() on
-                * the newly truncated path.
-                */
-               SET_STAT_INVALID(smb_fname->st);
-               status = parent_pathref(ctx,
-                                       conn->cwd_fsp,
-                                       smb_fname,
-                                       &parent_fname,
-                                       &atname);
-               if (NT_STATUS_IS_OK(status)) {
-                       /*
-                        * We must have a parent_fname->fsp before
-                        * we can call SMB_VFS_READ_DFS_PATHAT().
-                        */
-                       status = SMB_VFS_READ_DFS_PATHAT(conn,
-                                                        ctx,
-                                                        parent_fname->fsp,
-                                                        atname,
-                                                        ppreflist,
-                                                        preferral_count);
-
-                       /* We're now done with parent_fname and atname. */
-                       TALLOC_FREE(parent_fname);
-
-                       if (NT_STATUS_IS_OK(status)) {
-                               DBG_INFO("Redirecting %s because "
-                                        "parent %s is a dfs link\n",
-                                        dfspath,
-                                        smb_fname_str_dbg(smb_fname));
-
-                               if (consumedcntp) {
-                                       *consumedcntp = strlen(canon_dfspath);
-                                       DBG_DEBUG("Path consumed: %s "
-                                                 "(%zu)\n",
-                                                 canon_dfspath,
-                                                 *consumedcntp);
-                               }
-
-                               status = NT_STATUS_PATH_NOT_COVERED;
-                               goto out;
-                       }
-               }
-
-               /* Step back on the filesystem. */
-               p = strrchr_m(smb_fname->base_name, '/');
-
-               if (consumedcntp) {
-                       /* And in the canonicalized dfs path. */
-                       q = strrchr_m(canon_dfspath, '/');
-               }
-       }
-
-       if ((ucf_flags & UCF_GMT_PATHNAME) && _twrp != NULL) {
-               *_twrp = smb_fname->twrp;
-       }
-
-       status = NT_STATUS_OK;
- out:
-
-       /* This should already be free, but make sure. */
-       TALLOC_FREE(parent_fname);
-       TALLOC_FREE(smb_fname);
-       return status;
-}
-#endif
-
 /*****************************************************************
  Decides if a dfs pathname should be redirected or not.
  If not, the pathname is converted to a tcon-relative local unix path