]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Add dfs_filename_convert(). Simple wrapper around parse_dfs_path().
authorJeremy Allison <jra@samba.org>
Mon, 8 Aug 2022 18:16:17 +0000 (11:16 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 12 Aug 2022 18:19:31 +0000 (18:19 +0000)
Not yet used.

This is what we will use to replace dfs_redirect() in the filename
conversion code. Keep as a wrapper for now as we might want to
add some error checking around the 'hostname' and 'service'
returns.

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
source3/smbd/proto.h

index fce887de9aa7c2b8961a18b447638d2ea0660d78..1b66911faf0759b5028f67a4bad1a39f6c6acbda 100644 (file)
@@ -902,6 +902,68 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
        return status;
 }
 
+/*****************************************************************
+ Decides if a dfs pathname should be redirected or not.
+ If not, the pathname is converted to a tcon-relative local unix path
+ This is now a simple wrapper around parse_dfs_path()
+ as it does all the required checks.
+*****************************************************************/
+
+NTSTATUS dfs_filename_convert(TALLOC_CTX *ctx,
+                             connection_struct *conn,
+                             uint32_t ucf_flags,
+                             const char *dfs_path_in,
+                             char **pp_path_out)
+{
+       char *hostname = NULL;
+       char *servicename = NULL;
+       char *reqpath = NULL;
+       NTSTATUS status;
+
+       status = parse_dfs_path(ctx,
+                               conn,
+                               dfs_path_in,
+                               !conn->sconn->using_smb2,
+                               &hostname,
+                               &servicename,
+                               &reqpath);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       /*
+        * Caller doesn't care about hostname
+        * or servicename.
+        */
+       TALLOC_FREE(hostname);
+       TALLOC_FREE(servicename);
+
+       /*
+        * If parse_dfs_path fell back to a local path
+        * after skipping hostname or servicename, ensure
+        * we still have called check_path_syntax()
+        * on the full returned local path. check_path_syntax()
+        * is idempotent so this is safe.
+        */
+       if (ucf_flags & UCF_POSIX_PATHNAMES) {
+               status = check_path_syntax_posix(reqpath);
+       } else {
+               status = check_path_syntax(reqpath);
+       }
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+       /*
+        * Previous (and current logic) just ignores
+        * the server, share components if a DFS
+        * path is sent on a non-DFS share except to
+        * check that they match an existing share. Should
+        * we tighten this up to return an error here ?
+        */
+       *pp_path_out = reqpath;
+       return NT_STATUS_OK;
+}
+
 /*****************************************************************
  Decides if a dfs pathname should be redirected or not.
  If not, the pathname is converted to a tcon-relative local unix path
index 33fc222311ebdc511fda80064c0378e6de3d4795..1c10849346eb66c083b931891023354c4373ae5f 100644 (file)
@@ -560,6 +560,11 @@ bool remove_msdfs_link(const struct junction_map *jucn,
 struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx,
                                      struct auth_session_info *session_info,
                                      size_t *p_num_jn);
+NTSTATUS dfs_filename_convert(TALLOC_CTX *ctx,
+                             connection_struct *conn,
+                             uint32_t ucf_flags,
+                             const char *dfs_path_in,
+                             char **pp_path_out);
 NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
                        connection_struct *conn,
                        const char *name_in,