a3a04f
From be3f182c7bda75d531fa60c6d08a734f0098f2cc Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Tue, 14 Mar 2017 16:12:20 +0100
a3a04f
Subject: [PATCH] s3:vfs_expand_msdfs: Do not open the remote address as a file
a3a04f
a3a04f
The arguments get passed in the wrong order to read_target_host().
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12687
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
(cherry picked from commit 1115f152de9ec25bc9e5e499874b4a7c92c888c0)
a3a04f
---
a3a04f
 source3/modules/vfs_expand_msdfs.c | 3 +--
a3a04f
 1 file changed, 1 insertion(+), 2 deletions(-)
a3a04f
a3a04f
diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c
a3a04f
index ffbfa333bad..e42d0098b32 100644
a3a04f
--- a/source3/modules/vfs_expand_msdfs.c
a3a04f
+++ b/source3/modules/vfs_expand_msdfs.c
a3a04f
@@ -147,8 +147,7 @@ static char *expand_msdfs_target(TALLOC_CTX *ctx,
a3a04f
 		return NULL;
a3a04f
 	}
a3a04f
 
a3a04f
-	targethost = read_target_host(
a3a04f
-		ctx, raddr, mapfilename);
a3a04f
+	targethost = read_target_host(ctx, mapfilename, raddr);
a3a04f
 	if (targethost == NULL) {
a3a04f
 		DEBUG(1, ("Could not expand target host from file %s\n",
a3a04f
 			  mapfilename));
a3a04f
-- 
a3a04f
2.12.0
a3a04f
a3a04f
From cf65cc80e8598beef855678118c7c603d4b5729e Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Tue, 21 Mar 2017 15:32:37 +0100
a3a04f
Subject: [PATCH 1/2] s3:smbd: Pass down remote and local address to
a3a04f
 get_referred_path()
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12687
a3a04f
a3a04f
Pair-Programmed-With: Ralph Boehme <slow@samba.org>
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
Signed-off-by: Ralph Boehme <slow@samba.org>
a3a04f
Reviewed-by: Jeremy Allison <jra@samba.org>
a3a04f
(cherry picked from commit cbf67123e037207662ec0d4e53c55990e21b157e)
a3a04f
---
a3a04f
 source3/modules/vfs_default.c       |  2 ++
a3a04f
 source3/rpc_server/dfs/srv_dfs_nt.c |  6 ++++++
a3a04f
 source3/smbd/msdfs.c                | 12 +++++++-----
a3a04f
 source3/smbd/proto.h                | 12 +++++++-----
a3a04f
 4 files changed, 22 insertions(+), 10 deletions(-)
a3a04f
a3a04f
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
a3a04f
index e0b6125f7d8..dcae861103d 100644
a3a04f
--- a/source3/modules/vfs_default.c
a3a04f
+++ b/source3/modules/vfs_default.c
a3a04f
@@ -216,6 +216,8 @@ static NTSTATUS vfswrap_get_dfs_referrals(struct vfs_handle_struct *handle,
a3a04f
 
a3a04f
 	/* The following call can change cwd. */
a3a04f
 	status = get_referred_path(r, pathnamep,
a3a04f
+				   handle->conn->sconn->remote_address,
a3a04f
+				   handle->conn->sconn->local_address,
a3a04f
 				   !handle->conn->sconn->using_smb2,
a3a04f
 				   junction, &consumedcnt, &self_referral);
a3a04f
 	if (!NT_STATUS_IS_OK(status)) {
a3a04f
diff --git a/source3/rpc_server/dfs/srv_dfs_nt.c b/source3/rpc_server/dfs/srv_dfs_nt.c
a3a04f
index ab2af53c0ba..0a4d6d31b7c 100644
a3a04f
--- a/source3/rpc_server/dfs/srv_dfs_nt.c
a3a04f
+++ b/source3/rpc_server/dfs/srv_dfs_nt.c
a3a04f
@@ -76,6 +76,8 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
a3a04f
 
a3a04f
 	/* The following call can change the cwd. */
a3a04f
 	status = get_referred_path(ctx, r->in.path,
a3a04f
+				   p->remote_address,
a3a04f
+				   p->local_address,
a3a04f
 				   true, /*allow_broken_path */
a3a04f
 				   jn, &consumedcnt, &self_ref);
a3a04f
 	if(!NT_STATUS_IS_OK(status)) {
a3a04f
@@ -146,6 +148,8 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
a3a04f
 	}
a3a04f
 
a3a04f
 	status = get_referred_path(ctx, r->in.dfs_entry_path,
a3a04f
+				   p->remote_address,
a3a04f
+				   p->local_address,
a3a04f
 				   true, /*allow_broken_path */
a3a04f
 				   jn, &consumedcnt, &self_ref);
a3a04f
 	if(!NT_STATUS_IS_OK(status)) {
a3a04f
@@ -374,6 +378,8 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
a3a04f
 
a3a04f
 	/* The following call can change the cwd. */
a3a04f
 	status = get_referred_path(ctx, r->in.dfs_entry_path,
a3a04f
+				   p->remote_address,
a3a04f
+				   p->local_address,
a3a04f
 				   true, /*allow_broken_path */
a3a04f
 				   jn, &consumedcnt, &self_ref);
a3a04f
 	if(!NT_STATUS_IS_OK(status) ||
a3a04f
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
a3a04f
index 61538cec832..3cf82d3b430 100644
a3a04f
--- a/source3/smbd/msdfs.c
a3a04f
+++ b/source3/smbd/msdfs.c
a3a04f
@@ -953,11 +953,13 @@ static NTSTATUS self_ref(TALLOC_CTX *ctx,
a3a04f
 **********************************************************************/
a3a04f
 
a3a04f
 NTSTATUS get_referred_path(TALLOC_CTX *ctx,
a3a04f
-			const char *dfs_path,
a3a04f
-			bool allow_broken_path,
a3a04f
-			struct junction_map *jucn,
a3a04f
-			int *consumedcntp,
a3a04f
-			bool *self_referralp)
a3a04f
+			   const char *dfs_path,
a3a04f
+			   const struct tsocket_address *remote_address,
a3a04f
+			   const struct tsocket_address *local_address,
a3a04f
+			   bool allow_broken_path,
a3a04f
+			   struct junction_map *jucn,
a3a04f
+			   int *consumedcntp,
a3a04f
+			   bool *self_referralp)
a3a04f
 {
a3a04f
 	struct connection_struct *conn;
a3a04f
 	char *targetpath = NULL;
a3a04f
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
a3a04f
index c1b8201b472..e64457cf9e0 100644
a3a04f
--- a/source3/smbd/proto.h
a3a04f
+++ b/source3/smbd/proto.h
a3a04f
@@ -473,11 +473,13 @@ bool is_msdfs_link(connection_struct *conn,
a3a04f
 		SMB_STRUCT_STAT *sbufp);
a3a04f
 struct junction_map;
a3a04f
 NTSTATUS get_referred_path(TALLOC_CTX *ctx,
a3a04f
-			const char *dfs_path,
a3a04f
-			bool allow_broken_path,
a3a04f
-			struct junction_map *jucn,
a3a04f
-			int *consumedcntp,
a3a04f
-			bool *self_referralp);
a3a04f
+			   const char *dfs_path,
a3a04f
+			   const struct tsocket_address *remote_address,
a3a04f
+			   const struct tsocket_address *local_address,
a3a04f
+			   bool allow_broken_path,
a3a04f
+			   struct junction_map *jucn,
a3a04f
+			   int *consumedcntp,
a3a04f
+			   bool *self_referralp);
a3a04f
 int setup_dfs_referral(connection_struct *orig_conn,
a3a04f
 			const char *dfs_path,
a3a04f
 			int max_referral_level,
a3a04f
-- 
a3a04f
2.13.0
a3a04f
a3a04f
a3a04f
From 8f748924275fa8cb3951c296ad4ba5ca5989ac41 Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Tue, 21 Mar 2017 15:45:34 +0100
a3a04f
Subject: [PATCH 2/2] s3:smbd: Set up local and remote address for fake
a3a04f
 connection
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12687
a3a04f
a3a04f
Pair-Programmed-With: Ralph Boehme <slow@samba.org>
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
Signed-off-by: Ralph Boehme <slow@samba.org>
a3a04f
Reviewed-by: Jeremy Allison <jra@samba.org>
a3a04f
a3a04f
(cherry picked from commit e530e43d67436881fd039877f956f0ad9b562af9)
a3a04f
---
a3a04f
 source3/smbd/msdfs.c | 24 ++++++++++++++++++++++++
a3a04f
 1 file changed, 24 insertions(+)
a3a04f
a3a04f
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
a3a04f
index 3cf82d3b430..c25fb17cee8 100644
a3a04f
--- a/source3/smbd/msdfs.c
a3a04f
+++ b/source3/smbd/msdfs.c
a3a04f
@@ -31,6 +31,7 @@
a3a04f
 #include "lib/param/loadparm.h"
a3a04f
 #include "libcli/security/security.h"
a3a04f
 #include "librpc/gen_ndr/ndr_dfsblobs.h"
a3a04f
+#include "lib/tsocket/tsocket.h"
a3a04f
 
a3a04f
 /**********************************************************************
a3a04f
  Parse a DFS pathname of the form \hostname\service\reqpath
a3a04f
@@ -1071,6 +1072,29 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
a3a04f
 		return status;
a3a04f
 	}
a3a04f
 
a3a04f
+	/*
a3a04f
+	 * TODO
a3a04f
+	 *
a3a04f
+	 * The remote and local address should be passed down to
a3a04f
+	 * create_conn_struct_cwd.
a3a04f
+	 */
a3a04f
+	if (conn->sconn->remote_address == NULL) {
a3a04f
+		conn->sconn->remote_address =
a3a04f
+			tsocket_address_copy(remote_address, conn->sconn);
a3a04f
+		if (conn->sconn->remote_address == NULL) {
a3a04f
+			TALLOC_FREE(pdp);
a3a04f
+			return NT_STATUS_NO_MEMORY;
a3a04f
+		}
a3a04f
+	}
a3a04f
+	if (conn->sconn->local_address == NULL) {
a3a04f
+		conn->sconn->local_address =
a3a04f
+			tsocket_address_copy(local_address, conn->sconn);
a3a04f
+		if (conn->sconn->local_address == NULL) {
a3a04f
+			TALLOC_FREE(pdp);
a3a04f
+			return NT_STATUS_NO_MEMORY;
a3a04f
+		}
a3a04f
+	}
a3a04f
+
a3a04f
 	/* If this is a DFS path dfs_lookup should return
a3a04f
 	 * NT_STATUS_PATH_NOT_COVERED. */
a3a04f
 
a3a04f
-- 
a3a04f
2.13.0
a3a04f