The branch, master has been updated via bdab6f9 Optimization. Don't do the retry logic if sitename_fetch() returned NULL, we already did a NULL query. via 68e7b1c Move the retry logic when site_name is passed in a NULL or "" to the wrapper function. via 181c110 Move the manipulation of site_name into the caller function dsgetdcname(). via 66006be Refactor dsgetdcname to be called via a wrapper function. via dd12bfb dsgetdcname_cache_fetch() doesn't use the site_name parameter so don't pass it. from ade8477 torture3: Trigger a nasty cleanup bug in smbd
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit bdab6f9431715fbfd28f8cc0dfb4dde2966f22f3 Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 3 14:07:43 2013 -0700 Optimization. Don't do the retry logic if sitename_fetch() returned NULL, we already did a NULL query. Bug 5917 - Samba does not work on site with Read Only Domain Controller Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Wed Sep 4 01:19:05 CEST 2013 on sn-devel-104 commit 68e7b1c9446c7d1274b0fb85b59b90ac1a7f6041 Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 3 12:20:52 2013 -0700 Move the retry logic when site_name is passed in a NULL or "" to the wrapper function. Bug 5917 - Samba does not work on site with Read Only Domain Controller Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Richard Sharpe <rsha...@samba.org> commit 181c11066bd53b07015a199f56eb71182e89ff71 Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 3 12:08:46 2013 -0700 Move the manipulation of site_name into the caller function dsgetdcname(). Leave dsgetdcname_internal() only using const char *site_name. Bug 5917 - Samba does not work on site with Read Only Domain Controller Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Richard Sharpe <rsha...@samba.org> commit 66006be7ef703b2935334633d27641050cee5f58 Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 3 12:04:37 2013 -0700 Refactor dsgetdcname to be called via a wrapper function. Bug 5917 - Samba does not work on site with Read Only Domain Controller Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Richard Sharpe <rsha...@samba.org> commit dd12bfbcbf359c1642cc2e968aec62ae904aad5d Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 3 12:13:45 2013 -0700 dsgetdcname_cache_fetch() doesn't use the site_name parameter so don't pass it. Bug 5917 - Samba does not work on site with Read Only Domain Controller Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Richard Sharpe <rsha...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/libsmb/dsgetdcname.c | 85 ++++++++++++++++++++++++++++++++---------- 1 files changed, 65 insertions(+), 20 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 028a31b..6818b01 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -320,7 +320,6 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, const char *domain_name, const struct GUID *domain_guid, uint32_t flags, - const char *site_name, struct netr_DsRGetDCNameInfo **info_p) { char *key; @@ -393,7 +392,7 @@ static NTSTATUS dsgetdcname_cached(TALLOC_CTX *mem_ctx, NTSTATUS status; status = dsgetdcname_cache_fetch(mem_ctx, domain_name, domain_guid, - flags, site_name, info); + flags, info); if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { DEBUG(10,("dsgetdcname_cached: cache fetch failed with: %s\n", @@ -1094,12 +1093,10 @@ static bool is_closest_site(struct netr_DsRGetDCNameInfo *info) } /******************************************************************** - dsgetdcname. - - This will be the only public function here. + Internal dsgetdcname. ********************************************************************/ -NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, +static NTSTATUS dsgetdcname_internal(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, const char *domain_name, const struct GUID *domain_guid, @@ -1109,15 +1106,14 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, { NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; struct netr_DsRGetDCNameInfo *myinfo = NULL; - char *query_site = NULL; bool first = true; struct netr_DsRGetDCNameInfo *first_info = NULL; - DEBUG(10,("dsgetdcname: domain_name: %s, " + DEBUG(10,("dsgetdcname_internal: domain_name: %s, " "domain_guid: %s, site_name: %s, flags: 0x%08x\n", domain_name, domain_guid ? GUID_string(mem_ctx, domain_guid) : "(null)", - site_name, flags)); + site_name ? site_name : "(null)", flags)); *info = NULL; @@ -1126,18 +1122,12 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if ((site_name == NULL) || (site_name[0] == '\0')) { - query_site = sitename_fetch(domain_name); - } else { - query_site = SMB_STRDUP(site_name); - } - if (flags & DS_FORCE_REDISCOVERY) { goto rediscover; } status = dsgetdcname_cached(mem_ctx, msg_ctx, domain_name, domain_guid, - flags, query_site, &myinfo); + flags, site_name, &myinfo); if (NT_STATUS_IS_OK(status)) { goto done; } @@ -1148,12 +1138,10 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, rediscover: status = dsgetdcname_rediscover(mem_ctx, msg_ctx, domain_name, - domain_guid, flags, query_site, + domain_guid, flags, site_name, &myinfo); done: - SAFE_FREE(query_site); - if (!NT_STATUS_IS_OK(status)) { if (!first) { *info = first_info; @@ -1168,10 +1156,67 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, first = false; first_info = myinfo; /* TODO: may use the next_closest_site here */ - query_site = SMB_STRDUP(myinfo->client_site_name); + site_name = myinfo->client_site_name; goto rediscover; } *info = myinfo; return NT_STATUS_OK; } + +/******************************************************************** + dsgetdcname. + + This will be the only public function here. +********************************************************************/ + +NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, + struct messaging_context *msg_ctx, + const char *domain_name, + const struct GUID *domain_guid, + const char *site_name, + uint32_t flags, + struct netr_DsRGetDCNameInfo **info) +{ + NTSTATUS status; + const char *query_site = NULL; + char *ptr_to_free = NULL; + bool retry_query_with_null = false; + + if ((site_name == NULL) || (site_name[0] == '\0')) { + ptr_to_free = sitename_fetch(domain_name); + if (ptr_to_free != NULL) { + retry_query_with_null = true; + } + query_site = ptr_to_free; + } else { + query_site = site_name; + } + + status = dsgetdcname_internal(mem_ctx, + msg_ctx, + domain_name, + domain_guid, + query_site, + flags, + info); + + SAFE_FREE(ptr_to_free); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) { + return status; + } + + /* Should we try again with site_name == NULL ? */ + if (retry_query_with_null) { + status = dsgetdcname_internal(mem_ctx, + msg_ctx, + domain_name, + domain_guid, + NULL, + flags, + info); + } + + return status; +} -- Samba Shared Repository