s3-winbind: Move finding the domain to it's own function.
authorAndreas Schneider <asn@samba.org>
Tue, 3 Jan 2012 15:54:39 +0000 (16:54 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 5 Mar 2012 19:54:32 +0000 (20:54 +0100)
This the first part to fix bug #8678.
(cherry picked from commit 5075e565684627dfbd23f715da344b4365351ccb)
(cherry picked from commit 2fca06a63d47619f2b6902b1c8601021843c4b95)
(cherry picked from commit 76137cbcfa6f8ecae2417b034e3f08d43242f5fa)

source3/winbindd/wb_next_pwent.c

index 0970ce75fdbdf812cab83ff633bdfb05e4be5bcf..8a7b006727ea046eabefa2cb21682ad1e17c5599 100644 (file)
@@ -30,6 +30,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,
@@ -49,17 +69,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);