From cf4b4a7ba3075e3710aea40e0e7c670682c8c700 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Feb 2018 16:09:58 +0100 Subject: [PATCH 1/3] winbind: call lp_winbind_enum_{users,groups}() already in set{pw,gr}ent() This way we don't keep winbindd_cli_state->{pw,gr}ent_state arround forever, if the client forgets an explicit end{pw,gr}ent(). This allows client_is_idle() return true in more cases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13293 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit 6548b82b5c1ed30ce14e17e4ba9d4bc24ab49c42) --- source3/winbindd/winbindd_getgrent.c | 5 ----- source3/winbindd/winbindd_getpwent.c | 5 ----- source3/winbindd/winbindd_setgrent.c | 5 +++++ source3/winbindd/winbindd_setpwent.c | 5 +++++ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source3/winbindd/winbindd_getgrent.c b/source3/winbindd/winbindd_getgrent.c index 2c8cbac083a..1056555dc23 100644 --- a/source3/winbindd/winbindd_getgrent.c +++ b/source3/winbindd/winbindd_getgrent.c @@ -50,11 +50,6 @@ struct tevent_req *winbindd_getgrent_send(TALLOC_CTX *mem_ctx, DEBUG(3, ("[%5lu]: getgrent\n", (unsigned long)cli->pid)); - if (!lp_winbind_enum_groups()) { - tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES); - return tevent_req_post(req, ev); - } - if (cli->grent_state == NULL) { tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES); return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_getpwent.c b/source3/winbindd/winbindd_getpwent.c index 3c035eac8a6..d33f5f9864f 100644 --- a/source3/winbindd/winbindd_getpwent.c +++ b/source3/winbindd/winbindd_getpwent.c @@ -49,11 +49,6 @@ struct tevent_req *winbindd_getpwent_send(TALLOC_CTX *mem_ctx, DEBUG(3, ("[%5lu]: getpwent\n", (unsigned long)cli->pid)); - if (!lp_winbind_enum_users()) { - tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES); - return tevent_req_post(req, ev); - } - if (cli->pwent_state == NULL) { tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES); return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_setgrent.c b/source3/winbindd/winbindd_setgrent.c index 79aa8c35962..ab7fa98425b 100644 --- a/source3/winbindd/winbindd_setgrent.c +++ b/source3/winbindd/winbindd_setgrent.c @@ -39,6 +39,11 @@ struct tevent_req *winbindd_setgrent_send(TALLOC_CTX *mem_ctx, } TALLOC_FREE(cli->grent_state); + if (!lp_winbind_enum_groups()) { + tevent_req_done(req); + return tevent_req_post(req, ev); + } + cli->grent_state = talloc_zero(cli, struct getgrent_state); if (tevent_req_nomem(cli->grent_state, req)) { return tevent_req_post(req, ev); diff --git a/source3/winbindd/winbindd_setpwent.c b/source3/winbindd/winbindd_setpwent.c index af287584757..4591731923a 100644 --- a/source3/winbindd/winbindd_setpwent.c +++ b/source3/winbindd/winbindd_setpwent.c @@ -39,6 +39,11 @@ struct tevent_req *winbindd_setpwent_send(TALLOC_CTX *mem_ctx, } TALLOC_FREE(cli->pwent_state); + if (!lp_winbind_enum_users()) { + tevent_req_done(req); + return tevent_req_post(req, ev); + } + cli->pwent_state = talloc_zero(cli, struct getpwent_state); if (tevent_req_nomem(cli->pwent_state, req)) { return tevent_req_post(req, ev); -- 2.13.6 From c54e47789650a65c849b90681fdefc625ffc7b3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Feb 2018 16:13:16 +0100 Subject: [PATCH 2/3] winbind: cleanup winbindd_cli_state->grent_state if winbindd_getgrent_recv() returns an error A client may skip the explicit endgrent() if getgrent() fails. This allows client_is_idle() return true in more cases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13293 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit b7789da8468c3f070727011639d5f74aca76cb59) --- source3/winbindd/winbindd_getgrent.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source3/winbindd/winbindd_getgrent.c b/source3/winbindd/winbindd_getgrent.c index 1056555dc23..15a35f7044e 100644 --- a/source3/winbindd/winbindd_getgrent.c +++ b/source3/winbindd/winbindd_getgrent.c @@ -141,6 +141,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, int i; if (tevent_req_is_nterror(req, &status)) { + TALLOC_FREE(state->cli->grent_state); DEBUG(5, ("getgrent failed: %s\n", nt_errstr(status))); return status; } @@ -151,6 +152,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, memberstrings = talloc_array(talloc_tos(), char *, state->num_groups); if (memberstrings == NULL) { + TALLOC_FREE(state->cli->grent_state); return NT_STATUS_NO_MEMORY; } @@ -165,6 +167,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(memberstrings); + TALLOC_FREE(state->cli->grent_state); return status; } TALLOC_FREE(state->members[i]); @@ -180,6 +183,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, result = talloc_realloc(state, state->groups, char, base_memberofs + total_memberlen); if (result == NULL) { + TALLOC_FREE(state->cli->grent_state); return NT_STATUS_NO_MEMORY; } state->groups = (struct winbindd_gr *)result; -- 2.13.6 From 64494d504d946eb8d8250e81a2477bd64af7c006 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Feb 2018 16:13:16 +0100 Subject: [PATCH 3/3] winbind: cleanup winbindd_cli_state->pwent_state if winbindd_getpwent_recv() returns an error A client may skip the explicit endpwent() if getgrent() fails. This allows client_is_idle() return true in more cases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13293 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit b158d4e4c1c3fee0a8884bc5e8f0c5a5ce49687f) --- source3/winbindd/winbindd_getpwent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source3/winbindd/winbindd_getpwent.c b/source3/winbindd/winbindd_getpwent.c index d33f5f9864f..9e5190a3c60 100644 --- a/source3/winbindd/winbindd_getpwent.c +++ b/source3/winbindd/winbindd_getpwent.c @@ -124,6 +124,7 @@ NTSTATUS winbindd_getpwent_recv(struct tevent_req *req, NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { + TALLOC_FREE(state->cli->pwent_state); DEBUG(5, ("getpwent failed: %s\n", nt_errstr(status))); return status; } -- 2.13.6