[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Feb 27 17:23:04 MST 2015


The branch, master has been updated
       via  debf8ff selftest: shuffle msdfs-share DFS referral responses
       via  13c9774 MSDFS referral shuffling
       via  200d0bc winbind: Slightly simplify wb_sids2xids
       via  c6577f3 lib: Fix talloc hierarchy in init_lsa_ref_domain_list
      from  d76f800 lib/util: Build iov_buf library only when building samba

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit debf8ff31626c08c55661956151269b178b244b4
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Feb 27 14:52:47 2015 +0000

    selftest: shuffle msdfs-share DFS referral responses
    
    Add a secondary server path to the msdfs-src1 DFS link, and test "msdfs
    shuffle referrals" behaviour during selftest using the existing
    samba3.blackbox.smbclient_s3 suite.
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Feb 28 01:22:36 CET 2015 on sn-devel-104

commit 13c9774662b74c4188d41bb275b9cb72dcc9df74
Author: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date:   Fri Feb 27 14:52:46 2015 +0000

    MSDFS referral shuffling
    
    Shuffle MSDFS referral list in smbd in accordance with [MS-DFSC] 3.2.1.1
    When parsing an MSDFS symlink, the names are shuffled with a Fisher-Yates
    algorithm.
    
    Signed-off-by: Robin McCorkell <rmccorkell at karoshi.org.uk>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 200d0bc3a870f1d7d3c5bcf33fceaa2b99e8299f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 23 13:32:45 2015 +0000

    winbind: Slightly simplify wb_sids2xids
    
    We only needs "names" and "domains" wb_sids2xids_lookupsids_done. It confused
    me when reading this code that these variables are stored in "state".
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c6577f3043acfd649511011894554250bfbe7761
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Feb 27 14:04:36 2015 +0000

    lib: Fix talloc hierarchy in init_lsa_ref_domain_list
    
    The sid is copied, so the name should also be copied.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/smbdotconf/vfs/msdfsshufflereferrals.xml | 16 +++++++++++++
 lib/param/param_table.c                           |  9 +++++++
 selftest/target/Samba3.pm                         |  4 +++-
 source3/lib/lsa.c                                 |  6 ++++-
 source3/param/loadparm.c                          |  1 +
 source3/smbd/msdfs.c                              | 29 ++++++++++++++++++++---
 source3/winbindd/wb_sids2xids.c                   | 15 ++++++------
 7 files changed, 68 insertions(+), 12 deletions(-)
 create mode 100644 docs-xml/smbdotconf/vfs/msdfsshufflereferrals.xml


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/vfs/msdfsshufflereferrals.xml b/docs-xml/smbdotconf/vfs/msdfsshufflereferrals.xml
new file mode 100644
index 0000000..3461f3a
--- /dev/null
+++ b/docs-xml/smbdotconf/vfs/msdfsshufflereferrals.xml
@@ -0,0 +1,16 @@
+<samba:parameter name="msdfs shuffle referrals"
+                 context="S"
+                 type="boolean"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+	<para>If set to <constant>yes</constant>, Samba will shuffle
+	Dfs referrals for a given Dfs link if multiple are available,
+	allowing for load balancing across clients. For more information
+	on setting up a Dfs tree on Samba, refer to the MSDFS chapter in
+	the Samba3-HOWTO book.</para>
+</description>
+
+<related>host msdfs</related>
+<related>msdfs root</related>
+<value type="default">no</value>
+</samba:parameter>
diff --git a/lib/param/param_table.c b/lib/param/param_table.c
index 18b0628..00274ca 100644
--- a/lib/param/param_table.c
+++ b/lib/param/param_table.c
@@ -3942,6 +3942,15 @@ struct parm_struct parm_table[] = {
 		.flags		= FLAG_ADVANCED | FLAG_SHARE,
 	},
 	{
+		.label		= "msdfs shuffle referrals",
+		.type		= P_BOOL,
+		.p_class	= P_LOCAL,
+		.offset		= LOCAL_VAR(msdfs_shuffle_referrals),
+		.special	= NULL,
+		.enum_list	= NULL,
+		.flags		= FLAG_ADVANCED | FLAG_SHARE,
+	},
+	{
 		.label		= "host msdfs",
 		.type		= P_BOOL,
 		.p_class	= P_GLOBAL,
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 8209402..934153c 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1026,7 +1026,8 @@ sub provision($$$$$$$$)
 	}
 	close(MSDFS_TARGET);
 	chmod 0666, $msdfs_target;
-	symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1";
+	symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
+		"$msdfs_shrdir/msdfs-src1";
 	symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
 
 	##
@@ -1253,6 +1254,7 @@ sub provision($$$$$$$$)
 [msdfs-share]
 	path = $msdfs_shrdir
 	msdfs root = yes
+	msdfs shuffle referrals = yes
 	guest ok = yes
 [hideunread]
 	copy = tmp
diff --git a/source3/lib/lsa.c b/source3/lib/lsa.c
index 0046fda..6b9015a 100644
--- a/source3/lib/lsa.c
+++ b/source3/lib/lsa.c
@@ -57,7 +57,11 @@ int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
 
 	ZERO_STRUCT(ref->domains[num]);
 
-	ref->domains[num].name.string = dom_name;
+	ref->domains[num].name.string = talloc_strdup(mem_ctx, dom_name);
+	if (!ref->domains[num].name.string) {
+		return -1;
+	}
+
 	ref->domains[num].sid = dom_sid_dup(mem_ctx, dom_sid);
 	if (!ref->domains[num].sid) {
 		return -1;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index da50e3a..4a74843 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -222,6 +222,7 @@ static struct loadparm_service sDefault =
 	.inherit_acls = false,
 	.inherit_owner = false,
 	.msdfs_root = false,
+	.msdfs_shuffle_referrals = false,
 	.use_client_driver = false,
 	.default_devmode = true,
 	.force_printername = false,
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index 3bd8a09..a39efce 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -4,6 +4,7 @@
    MSDFS services for Samba
    Copyright (C) Shirish Kalele 2000
    Copyright (C) Jeremy Allison 2007
+   Copyright (C) Robin McCorkell 2015
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -428,6 +429,22 @@ NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
 	return NT_STATUS_OK;
 }
 
+static void shuffle_strlist(char **list, int count)
+{
+	int i, r;
+	char *tmp;
+
+	srandom(time(NULL));
+
+	for (i = count; i > 1; i--) {
+		r = random() % i;
+
+		tmp = list[i-1];
+		list[i-1] = list[r];
+		list[r] = tmp;
+	}
+}
+
 /**********************************************************************
  Parse the contents of a symlink to verify if it is an msdfs referral
  A valid referral is of the form:
@@ -448,6 +465,7 @@ NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
  **********************************************************************/
 
 static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
+				int snum,
 				const char *target,
 				struct referral **preflist,
 				int *refcount)
@@ -480,6 +498,11 @@ static bool parse_msdfs_symlink(TALLOC_CTX *ctx,
 		count++;
 	}
 
+	/* shuffle alternate paths */
+	if (lp_msdfs_shuffle_referrals(snum)) {
+		shuffle_strlist(alt_path, count);
+	}
+
 	DEBUG(10,("parse_msdfs_symlink: count=%d\n", count));
 
 	if (count) {
@@ -1007,7 +1030,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 			return NT_STATUS_NO_MEMORY;
 		}
 
-		if (!parse_msdfs_symlink(ctx, tmp, &ref, &refcount)) {
+		if (!parse_msdfs_symlink(ctx, snum, tmp, &ref, &refcount)) {
 			TALLOC_FREE(tmp);
 			TALLOC_FREE(pdp);
 			return NT_STATUS_INVALID_PARAMETER;
@@ -1056,7 +1079,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 	}
 
 	/* We know this is a valid dfs link. Parse the targetpath. */
-	if (!parse_msdfs_symlink(ctx, targetpath,
+	if (!parse_msdfs_symlink(ctx, snum, targetpath,
 				&jucn->referral_list,
 				&jucn->referral_count)) {
 		DEBUG(3,("get_referred_path: failed to parse symlink "
@@ -1517,7 +1540,7 @@ static int form_junctions(TALLOC_CTX *ctx,
 					conn,
 					dname, &link_target,
 					NULL)) {
-			if (parse_msdfs_symlink(ctx,
+			if (parse_msdfs_symlink(ctx, snum,
 					link_target,
 					&jucn[cnt].referral_list,
 					&jucn[cnt].referral_count)) {
diff --git a/source3/winbindd/wb_sids2xids.c b/source3/winbindd/wb_sids2xids.c
index 3e6f235..7614974 100644
--- a/source3/winbindd/wb_sids2xids.c
+++ b/source3/winbindd/wb_sids2xids.c
@@ -36,9 +36,6 @@ struct wb_sids2xids_state {
 	struct dom_sid *non_cached;
 	uint32_t num_non_cached;
 
-	struct lsa_RefDomainList *domains;
-	struct lsa_TransNameArray *names;
-
 	/*
 	 * Domain array to use for the idmap call. The output from
 	 * lookupsids cannot be used directly since for migrated
@@ -158,12 +155,13 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
 		subreq, struct tevent_req);
 	struct wb_sids2xids_state *state = tevent_req_data(
 		req, struct wb_sids2xids_state);
+	struct lsa_RefDomainList *domains = NULL;
+	struct lsa_TransNameArray *names = NULL;
 	struct winbindd_child *child;
 	NTSTATUS status;
 	int i;
 
-	status = wb_lookupsids_recv(subreq, state, &state->domains,
-				    &state->names);
+	status = wb_lookupsids_recv(subreq, state, &domains, &names);
 	TALLOC_FREE(subreq);
 	if (tevent_req_nterror(req, status)) {
 		return;
@@ -184,13 +182,13 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
 	for (i=0; i<state->num_non_cached; i++) {
 		struct dom_sid dom_sid;
 		struct lsa_DomainInfo *info;
-		struct lsa_TranslatedName *n = &state->names->names[i];
+		struct lsa_TranslatedName *n = &names->names[i];
 		struct wbint_TransID *t = &state->ids.ids[i];
 
 		sid_copy(&dom_sid, &state->non_cached[i]);
 		sid_split_rid(&dom_sid, &t->rid);
 
-		info = &state->domains->domains[n->sid_index];
+		info = &domains->domains[n->sid_index];
 		t->type = lsa_SidType_to_id_type(n->sid_type);
 		t->domain_index = init_lsa_ref_domain_list(state,
 							   state->idmap_doms,
@@ -200,6 +198,9 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
 		t->xid.type = t->type;
 	}
 
+	TALLOC_FREE(names);
+	TALLOC_FREE(domains);
+
 	child = idmap_child();
 
 	subreq = dcerpc_wbint_Sids2UnixIDs_send(


-- 
Samba Shared Repository


More information about the samba-cvs mailing list