]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Add new function check_path_syntax_smb2_msdfs() for SMB2 MSDFS paths.
authorJeremy Allison <jra@samba.org>
Fri, 5 Aug 2022 19:16:44 +0000 (12:16 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 12 Aug 2022 18:19:30 +0000 (18:19 +0000)
 #ifdef'ed out as static and not yet used.

We can't just call check_path_syntax() on these as
they are of the form hostname\share[\extrapath]
(where [\extrapath] is optional).

hostname here can be an IPv6 ':' separated address,
which check_path_syntax() fails on due to the streamname
processing.

NB. This also has to cope with out existing (broken)
libsmbclient libraries that sometimes set the DFS
flag and then send a local pathname. Cope by just
calling the normal check_path_syntax() on the
whole pathname in that case.

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/smb2_reply.c

index 870c3bcb898bc90aa195d308e703b605ef3f459b..6052f94354a8d3a94f7ab684f094d5c679bb19eb 100644 (file)
@@ -243,6 +243,44 @@ NTSTATUS check_path_syntax_posix(char *path)
        return check_path_syntax_internal(path, true);
 }
 
+#if 0
+/****************************************************************************
+ Check the path for an SMB2 DFS path.
+ SMB2 DFS paths look like hostname\share (followed by a possible \extrapath.
+ Path returned from here must look like:
+       hostname/share (followed by a possible /extrapath).
+****************************************************************************/
+
+static NTSTATUS check_path_syntax_smb2_msdfs(char *path)
+{
+       char *share = NULL;
+       char *remaining_path = NULL;
+       /* No SMB2 names can start with '\\' */
+       if (path[0] == '\\') {
+               return NT_STATUS_OBJECT_NAME_INVALID;
+       }
+       /*
+        * smbclient libraries sometimes set the DFS flag and send
+        * local pathnames. Cope with this by just calling
+        * check_path_syntax() on the whole path if it doesn't
+        * look like a DFS path, similar to what parse_dfs_path() does.
+        */
+       /* servername should be at path[0] */
+       share = strchr(path, '\\');
+       if (share == NULL) {
+               return check_path_syntax(path);
+       }
+       *share++ = '/';
+       remaining_path = strchr(share, '\\');
+       if (remaining_path == NULL) {
+               /* Only hostname\share. We're done. */
+               return NT_STATUS_OK;
+       }
+       *remaining_path++ = '/';
+       return check_path_syntax(remaining_path);
+}
+#endif
+
 /****************************************************************************
  Pull a string and check the path allowing a wildcard - provide for error return.
  Passes in posix flag.