summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-01-03 16:54:39 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-01-04 16:56:06 +0100
commit5075e565684627dfbd23f715da344b4365351ccb (patch)
treea7981430a7d890ea2629900a9d11a7ee15b2604d
parentbd5fe0a3333e5db49e74c982bcfef9737b65cc78 (diff)
downloadsamba-5075e565684627dfbd23f715da344b4365351ccb.tar.gz
samba-5075e565684627dfbd23f715da344b4365351ccb.tar.bz2
samba-5075e565684627dfbd23f715da344b4365351ccb.zip
s3-winbind: Move finding the domain to it's own function.
This the first part to fix bug #8678.
-rw-r--r--source3/winbindd/wb_next_pwent.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/source3/winbindd/wb_next_pwent.c b/source3/winbindd/wb_next_pwent.c
index d47b2fca91..998830952b 100644
--- a/source3/winbindd/wb_next_pwent.c
+++ b/source3/winbindd/wb_next_pwent.c
@@ -31,6 +31,26 @@ struct wb_next_pwent_state {
static void wb_next_pwent_fetch_done(struct tevent_req *subreq);
static void wb_next_pwent_fill_done(struct tevent_req *subreq);
+static struct winbindd_domain *wb_next_find_domain(struct winbindd_domain *domain)
+{
+ if (domain == NULL) {
+ domain = domain_list();
+ } else {
+ domain = domain->next;
+ }
+
+ if ((domain != NULL)
+ && sid_check_is_domain(&domain->sid)) {
+ domain = domain->next;
+ }
+
+ if (domain == NULL) {
+ return NULL;
+ }
+
+ return domain;
+}
+
struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct getpwent_state *gstate,
@@ -50,17 +70,7 @@ struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
if (state->gstate->next_user >= state->gstate->num_users) {
TALLOC_FREE(state->gstate->users);
- if (state->gstate->domain == NULL) {
- state->gstate->domain = domain_list();
- } else {
- state->gstate->domain = state->gstate->domain->next;
- }
-
- if ((state->gstate->domain != NULL)
- && sid_check_is_domain(&state->gstate->domain->sid)) {
- state->gstate->domain = state->gstate->domain->next;
- }
-
+ state->gstate->domain = wb_next_find_domain(state->gstate->domain);
if (state->gstate->domain == NULL) {
tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES);
return tevent_req_post(req, ev);