]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Add cli_dfs_is_already_full_path() function.
authorJeremy Allison <jra@samba.org>
Fri, 19 Aug 2022 21:59:04 +0000 (14:59 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 15 Sep 2022 18:43:32 +0000 (18:43 +0000)
Returns true if it's already a fully qualified DFS path.

Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/libsmb/clidfs.c
source3/libsmb/proto.h

index d8355f8058b3aa57b03a07164e52994210247071..83e725d0abff9663b007ec90856f0360d9d9af1d 100644 (file)
@@ -588,6 +588,46 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
                        dir);
 }
 
+/********************************************************************
+ Check if a path has already been converted to DFS.
+********************************************************************/
+
+bool cli_dfs_is_already_full_path(struct cli_state *cli, const char *path)
+{
+       const char *server = smbXcli_conn_remote_name(cli->conn);
+       size_t server_len = strlen(server);
+       bool found_server = false;
+       const char *share = cli->share;
+       size_t share_len = strlen(share);
+       bool found_share = false;
+
+       if (!IS_DIRECTORY_SEP(path[0])) {
+               return false;
+       }
+       path++;
+       found_server = (strncasecmp_m(path, server, server_len) == 0);
+       if (!found_server) {
+               return false;
+       }
+       path += server_len;
+       if (!IS_DIRECTORY_SEP(path[0])) {
+               return false;
+       }
+       path++;
+       found_share = (strncasecmp_m(path, share, share_len) == 0);
+       if (!found_share) {
+               return false;
+       }
+       path += share_len;
+       if (path[0] == '\0') {
+               return true;
+       }
+       if (IS_DIRECTORY_SEP(path[0])) {
+               return true;
+       }
+       return false;
+}
+
 /********************************************************************
  Get the dfs referral link.
 ********************************************************************/
index df709dbb6ff6dac1470d42efe73ee2b2503c7ac8..222fcafb5f4e2440a09cbcaabb185ee054200a95 100644 (file)
@@ -135,6 +135,7 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                     struct cli_state **pcli);
 void cli_cm_display(struct cli_state *c);
 struct client_dfs_referral;
+bool cli_dfs_is_already_full_path(struct cli_state *cli, const char *path);
 NTSTATUS cli_dfs_get_referral_ex(TALLOC_CTX *ctx,
                        struct cli_state *cli,
                        const char *path,