summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2022-08-08 11:16:17 -0700
committerStefan Metzmacher <metze@samba.org>2022-08-16 18:27:13 +0000
commitd1ba2845a2aa5ed2a88d1a9cb6d121eba0656764 (patch)
treecea46387b2566b456706f3f7a2a6b0e6f9869ad2
parentc0f9b5f41e478ea2d1019adb6cb085c8ed2b490a (diff)
downloadsamba-d1ba2845a2aa5ed2a88d1a9cb6d121eba0656764.tar.gz
s3: smbd: Add dfs_filename_convert(). Simple wrapper around parse_dfs_path().
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> BUG: https://bugzilla.samba.org/show_bug.cgi?id=15146 (cherry picked from commit 245d07ab84852b829c029496618e56782d070e83)
-rw-r--r--source3/smbd/msdfs.c62
-rw-r--r--source3/smbd/proto.h5
2 files changed, 67 insertions, 0 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index fce887de9aa..1b66911faf0 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -905,6 +905,68 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
/*****************************************************************
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
search_wcard_flag: this flag performs 2 functions both related
to searches. See resolve_dfs_path() and parse_dfs_path_XX()
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 33fc222311e..1c10849346e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -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,