From 95f0f22ca5150642c77bbbbe40a921ac50861e1c Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 31 Oct 2019 18:56:10 +0100 Subject: [PATCH] smbdotconf: mark "msdfs proxy" with substitution="1" Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- docs-xml/smbdotconf/vfs/msdfsproxy.xml | 3 ++- source3/smbd/msdfs.c | 16 +++++++++++----- source3/smbd/service.c | 6 ++++-- source3/smbd/smb2_tcon.c | 4 +++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs-xml/smbdotconf/vfs/msdfsproxy.xml b/docs-xml/smbdotconf/vfs/msdfsproxy.xml index 566dcd7d691..55a410fe49e 100644 --- a/docs-xml/smbdotconf/vfs/msdfsproxy.xml +++ b/docs-xml/smbdotconf/vfs/msdfsproxy.xml @@ -1,6 +1,7 @@ This parameter indicates that the share is a diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 7ef368240d5..45015cae140 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1009,6 +1009,8 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx, bool *self_referralp) { TALLOC_CTX *frame = talloc_stackframe(); + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); struct conn_struct_tos *c = NULL; struct connection_struct *conn = NULL; char *targetpath = NULL; @@ -1058,7 +1060,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx, } } - if (!lp_msdfs_root(snum) && (*lp_msdfs_proxy(talloc_tos(), snum) == '\0')) { + if (!lp_msdfs_root(snum) && (*lp_msdfs_proxy(talloc_tos(), lp_sub, snum) == '\0')) { DEBUG(3,("get_referred_path: |%s| in dfs path %s is not " "a dfs root.\n", pdp->servicename, dfs_path)); @@ -1079,7 +1081,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx, struct referral *ref; int refcount; - if (*lp_msdfs_proxy(talloc_tos(), snum) == '\0') { + if (*lp_msdfs_proxy(talloc_tos(), lp_sub, snum) == '\0') { TALLOC_FREE(frame); return self_ref(ctx, dfs_path, @@ -1094,7 +1096,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx, */ tmp = talloc_asprintf(frame, "msdfs:%s", - lp_msdfs_proxy(frame, snum)); + lp_msdfs_proxy(frame, lp_sub, snum)); if (tmp == NULL) { TALLOC_FREE(frame); return NT_STATUS_NO_MEMORY; @@ -1495,12 +1497,14 @@ bool remove_msdfs_link(const struct junction_map *jucn) static int count_dfs_links(TALLOC_CTX *ctx, int snum) { TALLOC_CTX *frame = talloc_stackframe(); + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); size_t cnt = 0; DIR *dirp = NULL; const char *dname = NULL; char *talloced = NULL; const char *connect_path = lp_path(frame, snum); - const char *msdfs_proxy = lp_msdfs_proxy(frame, snum); + const char *msdfs_proxy = lp_msdfs_proxy(frame, lp_sub, snum); struct conn_struct_tos *c = NULL; connection_struct *conn = NULL; NTSTATUS status; @@ -1585,13 +1589,15 @@ static int form_junctions(TALLOC_CTX *ctx, size_t jn_remain) { TALLOC_CTX *frame = talloc_stackframe(); + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); size_t cnt = 0; DIR *dirp = NULL; const char *dname = NULL; char *talloced = NULL; const char *connect_path = lp_path(frame, snum); char *service_name = lp_servicename(frame, snum); - const char *msdfs_proxy = lp_msdfs_proxy(frame, snum); + const char *msdfs_proxy = lp_msdfs_proxy(frame, lp_sub, snum); struct conn_struct_tos *c = NULL; connection_struct *conn = NULL; struct referral *ref = NULL; diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 4b574661256..e1a718b6d91 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -1027,6 +1027,8 @@ connection_struct *make_connection(struct smb_request *req, NTSTATUS *status) { struct smbd_server_connection *sconn = req->sconn; + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); uid_t euid; struct user_struct *vuser = NULL; char *service = NULL; @@ -1127,10 +1129,10 @@ connection_struct *make_connection(struct smb_request *req, } /* Handle non-Dfs clients attempting connections to msdfs proxy */ - if (lp_host_msdfs() && (*lp_msdfs_proxy(talloc_tos(), snum) != '\0')) { + if (lp_host_msdfs() && (*lp_msdfs_proxy(talloc_tos(), lp_sub, snum) != '\0')) { DEBUG(3, ("refusing connection to dfs proxy share '%s' " "(pointing to %s)\n", - service, lp_msdfs_proxy(talloc_tos(), snum))); + service, lp_msdfs_proxy(talloc_tos(), lp_sub, snum))); *status = NT_STATUS_BAD_NETWORK_NAME; return NULL; } diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c index c2a5cbc39aa..4ae75d79dd6 100644 --- a/source3/smbd/smb2_tcon.c +++ b/source3/smbd/smb2_tcon.c @@ -191,6 +191,8 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req, uint32_t *out_tree_id, bool *disconnect) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); struct smbXsrv_connection *conn = req->xconn; const char *share = in_path; char *service = NULL; @@ -276,7 +278,7 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req, /* Handle non-DFS clients attempting connections to msdfs proxy */ if (lp_host_msdfs()) { - char *proxy = lp_msdfs_proxy(talloc_tos(), snum); + char *proxy = lp_msdfs_proxy(talloc_tos(), lp_sub, snum); if ((proxy != NULL) && (*proxy != '\0')) { DBG_NOTICE("refusing connection to dfs proxy share " -- 2.47.3