From ce55cf1b825ce1d76310aff6829eafc8defe53ad Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 28 Apr 2004 20:07:51 +0000 Subject: r395: BUG 1232: patch from landonf@opendarwin.org (Landon Fuller) to fix user/group enumeration on systems whose libc does not call setgrent() before trying to enumerate users (i.e. FreeBSD 5.2) (This used to be commit 8106d8097258eae260ed834399881bf0be9b515b) --- source3/nsswitch/winbindd.h | 2 ++ source3/nsswitch/winbindd_group.c | 6 ++++++ source3/nsswitch/winbindd_user.c | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h index e884ea8380..751f6f3700 100644 --- a/source3/nsswitch/winbindd.h +++ b/source3/nsswitch/winbindd.h @@ -46,6 +46,8 @@ struct winbindd_cli_state { struct winbindd_request request; /* Request from client */ struct winbindd_response response; /* Respose to client */ + BOOL getpwent_initialized; /* Has getpwent_state been initialized? */ + BOOL getgrent_initialized; /* Has getgrent_state been initialized? */ struct getent_state *getpwent_state; /* State for getpwent() */ struct getent_state *getgrent_state; /* State for getgrent() */ }; diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c index ec77d2db34..4800ab20cf 100644 --- a/source3/nsswitch/winbindd_group.c +++ b/source3/nsswitch/winbindd_group.c @@ -472,6 +472,8 @@ enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state) DLIST_ADD(state->getgrent_state, domain_state); } + state->getgrent_initialized = True; + return WINBINDD_OK; } @@ -482,6 +484,7 @@ enum winbindd_result winbindd_endgrent(struct winbindd_cli_state *state) DEBUG(3, ("[%5lu]: endgrent\n", (unsigned long)state->pid)); free_getent_state(state->getgrent_state); + state->getgrent_initialized = False; state->getgrent_state = NULL; return WINBINDD_OK; @@ -632,6 +635,9 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) group_list = (struct winbindd_gr *)state->response.extra_data; + if (!state->getgrent_initialized) + winbindd_setgrent(state); + if (!(ent = state->getgrent_state)) return WINBINDD_ERROR; diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c index d10fd5664b..40c398755d 100644 --- a/source3/nsswitch/winbindd_user.c +++ b/source3/nsswitch/winbindd_user.c @@ -360,6 +360,8 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state) DLIST_ADD(state->getpwent_state, domain_state); } + state->getpwent_initialized = True; + return WINBINDD_OK; } @@ -370,6 +372,7 @@ enum winbindd_result winbindd_endpwent(struct winbindd_cli_state *state) DEBUG(3, ("[%5lu]: endpwent\n", (unsigned long)state->pid)); free_getent_state(state->getpwent_state); + state->getpwent_initialized = False; state->getpwent_state = NULL; return WINBINDD_OK; @@ -501,6 +504,9 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state) sizeof(struct winbindd_pw)); user_list = (struct winbindd_pw *)state->response.extra_data; + + if (!state->getpwent_initialized) + winbindd_setpwent(state); if (!(ent = state->getpwent_state)) return WINBINDD_ERROR; -- cgit