[PATCH] dfs_server: randomize the server redirect set
Andrew Bartlett
abartlet at samba.org
Thu Mar 20 16:37:17 MDT 2014
On Thu, 2014-03-20 at 22:49 +0100, Arvid Requate wrote:
> comply with [MS-DFSC] section 3.2.1.1
For reference I see, this matches the code in
kcctpl_shuffle_bridgeheads()
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Can I get a second team reviewer please?
> Signed-off-by: Arvid Requate <requate at univention.de>
> ---
> dfs_server/dfs_server_ad.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
> index 504ab79..51df322 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;
> }
--
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical
mailing list