aboutsummaryrefslogtreecommitdiffstats
path: root/dfs_server
diff options
context:
space:
mode:
authorArvid Requate <requate@univention.de>2014-03-20 22:49:08 +0100
committerJeremy Allison <jra@samba.org>2014-03-21 19:20:17 +0100
commitcfa6fe8d6974c35cc50aef2f6cdbbbd9b513e483 (patch)
treef998f099420389ca9ebe97b85c49ca5ce12cdda4 /dfs_server
parent6034ab521c47fc5f4732398652c9c6847ff92035 (diff)
downloadsamba-cfa6fe8d6974c35cc50aef2f6cdbbbd9b513e483.tar.gz
samba-cfa6fe8d6974c35cc50aef2f6cdbbbd9b513e483.tar.xz
samba-cfa6fe8d6974c35cc50aef2f6cdbbbd9b513e483.zip
dfs_server: randomize the server redirect set
comply with [MS-DFSC] section 3.2.1.1 Signed-off-by: Arvid Requate <requate@univention.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'dfs_server')
-rw-r--r--dfs_server/dfs_server_ad.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
index 504ab799ba3..5e2634fb7a1 100644
--- a/dfs_server/dfs_server_ad.c
+++ b/dfs_server/dfs_server_ad.c
@@ -38,6 +38,24 @@ struct dc_set {
uint32_t count;
};
+static void shuffle_dc_set(struct dc_set *list)
+{
+ uint32_t i;
+
+ srandom(time(NULL));
+
+ for (i = list->count; i > 1; i--) {
+ uint32_t r;
+ const char *tmp;
+
+ r = random() % i;
+
+ tmp = list->names[i - 1];
+ list->names[i - 1] = list->names[r];
+ list->names[r] = tmp;
+ }
+}
+
/*
fill a referral type structure
*/
@@ -265,6 +283,8 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
talloc_free(msg);
}
+ shuffle_dc_set(list);
+
talloc_free(r);
return NT_STATUS_OK;
}