summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2020-02-12 13:17:51 -0800
committerRalph Boehme <slow@samba.org>2020-02-18 21:08:33 +0000
commit1668c9ee15b421093756ac9d709f55ce3e808791 (patch)
tree9d1bf5fbd7706464b375ea240c0883970f2d049b
parent1ffc52abedae9787f745795a4f502c26b4c005d1 (diff)
downloadsamba-1668c9ee15b421093756ac9d709f55ce3e808791.tar.gz
s3: DFS: Change dfs_path_lookup() to return struct referral list and count directly.
Remove external parse of returned link targetpath, expose the parsing previously added to dfs_path_lookup(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--source3/smbd/msdfs.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index ada261651cb..681b170f527 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -730,7 +730,8 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
server+share+extrapath. */
uint32_t ucf_flags,
int *consumedcntp,
- char **pp_targetpath)
+ struct referral **ppreflist,
+ size_t *preferral_count)
{
char *p = NULL;
char *q = NULL;
@@ -738,6 +739,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
struct smb_filename *smb_fname = NULL;
char *canon_dfspath = NULL; /* Canonicalized dfs path. (only '/'
components). */
+ char *targetpath = NULL;
DEBUG(10,("dfs_path_lookup: Conn path = %s reqpath = %s\n",
conn->connectpath, pdp->reqpath));
@@ -764,7 +766,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
/* Optimization - check if we can redirect the whole path. */
- if (is_msdfs_link_internal(ctx, conn, smb_fname, pp_targetpath)) {
+ if (is_msdfs_link_internal(ctx, conn, smb_fname, &targetpath)) {
/* XX_ALLOW_WCARD_XXX is called from search functions. */
if (ucf_flags &
(UCF_COND_ALLOW_WCARD_LCOMP|
@@ -777,7 +779,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
DEBUG(6,("dfs_path_lookup: %s resolves to a "
"valid dfs link %s.\n", dfspath,
- pp_targetpath ? *pp_targetpath : ""));
+ targetpath != NULL ? targetpath : ""));
if (consumedcntp) {
*consumedcntp = strlen(dfspath);
@@ -827,7 +829,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
}
if (is_msdfs_link_internal(ctx, conn,
- smb_fname, pp_targetpath)) {
+ smb_fname, &targetpath)) {
DEBUG(4, ("dfs_path_lookup: Redirecting %s because "
"parent %s is dfs link\n", dfspath,
smb_fname_str_dbg(smb_fname)));
@@ -863,16 +865,12 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
* the code transition to SMB_VFS_READ_DFS_PATHAT().
* (which will make this code redundent).
*/
- if (pp_targetpath != NULL) {
- struct referral *preflist = NULL;
- size_t referral_count = 0;
-
+ if (targetpath != NULL) {
bool ok = parse_msdfs_symlink(ctx,
lp_msdfs_shuffle_referrals(SNUM(conn)),
- *pp_targetpath,
- &preflist,
- &referral_count);
- TALLOC_FREE(preflist);
+ targetpath,
+ ppreflist,
+ preferral_count);
if (!ok) {
status = NT_STATUS_NO_MEMORY;
}
@@ -880,6 +878,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
}
+ TALLOC_FREE(targetpath);
TALLOC_FREE(smb_fname);
return status;
}
@@ -971,8 +970,14 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
}
- status = dfs_path_lookup(ctx, conn, path_in, pdp,
- ucf_flags, NULL, NULL);
+ status = dfs_path_lookup(ctx,
+ conn,
+ path_in,
+ pdp,
+ ucf_flags,
+ NULL, /* int *consumedcntp */
+ NULL, /* struct referral **ppreflist */
+ NULL); /* size_t *preferral_count */
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status, NT_STATUS_PATH_NOT_COVERED)) {
DEBUG(3,("dfs_redirect: Redirecting %s\n", path_in));
@@ -1051,7 +1056,6 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
loadparm_s3_global_substitution();
struct conn_struct_tos *c = NULL;
struct connection_struct *conn = NULL;
- char *targetpath = NULL;
int snum;
NTSTATUS status = NT_STATUS_NOT_FOUND;
bool dummy;
@@ -1192,8 +1196,14 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
/* If this is a DFS path dfs_lookup should return
* NT_STATUS_PATH_NOT_COVERED. */
- status = dfs_path_lookup(ctx, conn, dfs_path, pdp,
- 0, consumedcntp, &targetpath);
+ status = dfs_path_lookup(ctx,
+ conn,
+ dfs_path,
+ pdp,
+ 0, /* ucf_flags */
+ consumedcntp,
+ &jucn->referral_list,
+ &jucn->referral_count);
if (!NT_STATUS_EQUAL(status, NT_STATUS_PATH_NOT_COVERED)) {
DEBUG(3,("get_referred_path: No valid referrals for path %s\n",
@@ -1214,18 +1224,6 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
goto err_exit;
}
- /* We know this is a valid dfs link. Parse the targetpath. */
- if (!parse_msdfs_symlink(ctx,
- lp_msdfs_shuffle_referrals(snum),
- targetpath,
- &jucn->referral_list,
- &jucn->referral_count)) {
- DEBUG(3,("get_referred_path: failed to parse symlink "
- "target %s\n", targetpath ));
- status = NT_STATUS_NOT_FOUND;
- goto err_exit;
- }
-
status = NT_STATUS_OK;
err_exit:
TALLOC_FREE(frame);