summaryrefslogtreecommitdiff
path: root/source3/libsmb/clidfs.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2022-08-19 14:59:04 -0700
committerJeremy Allison <jra@samba.org>2022-09-15 18:43:32 +0000
commit26b4a6951b6ae2a8ba2341d64fa888fe52f6463a (patch)
treea1046031dcfd4ee1128c036fbeb63c7d03e6eed0 /source3/libsmb/clidfs.c
parent070b73e3f96c46bb4a96a8149c4c77ab3080a946 (diff)
downloadsamba-26b4a6951b6ae2a8ba2341d64fa888fe52f6463a.tar.gz
s3: libsmb: Add cli_dfs_is_already_full_path() function.
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>
Diffstat (limited to 'source3/libsmb/clidfs.c')
-rw-r--r--source3/libsmb/clidfs.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index d8355f8058b..83e725d0abf 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -589,6 +589,46 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
}
/********************************************************************
+ 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.
********************************************************************/