From beb9d50d62ffc1356534a1c6c05a69b4c215f714 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 14 May 2010 17:26:46 +1000 Subject: [PATCH] s3compat-only s3:winbind Split wb_process_request() into a new file This splits up winbindd.c, which was previously very long. Andrew Bartlett --- source3/Makefile.in | 2 + source3/winbindd/winbindd.c | 263 ------------------------- source3/winbindd/winbindd_process.c | 292 ++++++++++++++++++++++++++++ source3/winbindd/winbindd_proto.h | 4 + 4 files changed, 298 insertions(+), 263 deletions(-) create mode 100644 source3/winbindd/winbindd_process.c diff --git a/source3/Makefile.in b/source3/Makefile.in index c72a6c30abc..4bcf6443a7d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1292,6 +1292,8 @@ IDMAP_ADEX_OBJ = \ WINBINDD_OBJ1 = \ winbindd/winbindd.o \ + winbindd/winbindd_event.o \ + winbindd/winbindd_process.o \ winbindd/winbindd_group.o \ winbindd/winbindd_util.o \ winbindd/winbindd_cache.o \ diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 97ca4d1cbb8..72aabdb8bd2 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -411,266 +411,6 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx, _exit(0); } -static struct winbindd_dispatch_table { - enum winbindd_cmd cmd; - void (*fn)(struct winbindd_cli_state *state); - const char *winbindd_cmd_name; -} dispatch_table[] = { - - /* Enumeration functions */ - - { WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains, - "LIST_TRUSTDOM" }, - - /* Miscellaneous */ - - { WINBINDD_INFO, winbindd_info, "INFO" }, - { WINBINDD_INTERFACE_VERSION, winbindd_interface_version, - "INTERFACE_VERSION" }, - { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" }, - { WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" }, - { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" }, - { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir, - "WINBINDD_PRIV_PIPE_DIR" }, - - /* Credential cache access */ - { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" }, - { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" }, - - /* WINS functions */ - - { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" }, - { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" }, - - /* End of list */ - - { WINBINDD_NUM_CMDS, NULL, "NONE" } -}; - -struct winbindd_async_dispatch_table { - enum winbindd_cmd cmd; - const char *cmd_name; - struct tevent_req *(*send_req)(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct winbindd_cli_state *cli, - struct winbindd_request *request); - NTSTATUS (*recv_req)(struct tevent_req *req, - struct winbindd_response *presp); -}; - -static struct winbindd_async_dispatch_table async_nonpriv_table[] = { - { WINBINDD_PING, "PING", - wb_ping_send, wb_ping_recv }, - { WINBINDD_LOOKUPSID, "LOOKUPSID", - winbindd_lookupsid_send, winbindd_lookupsid_recv }, - { WINBINDD_LOOKUPNAME, "LOOKUPNAME", - winbindd_lookupname_send, winbindd_lookupname_recv }, - { WINBINDD_SID_TO_UID, "SID_TO_UID", - winbindd_sid_to_uid_send, winbindd_sid_to_uid_recv }, - { WINBINDD_SID_TO_GID, "SID_TO_GID", - winbindd_sid_to_gid_send, winbindd_sid_to_gid_recv }, - { WINBINDD_UID_TO_SID, "UID_TO_SID", - winbindd_uid_to_sid_send, winbindd_uid_to_sid_recv }, - { WINBINDD_GID_TO_SID, "GID_TO_SID", - winbindd_gid_to_sid_send, winbindd_gid_to_sid_recv }, - { WINBINDD_GETPWSID, "GETPWSID", - winbindd_getpwsid_send, winbindd_getpwsid_recv }, - { WINBINDD_GETPWNAM, "GETPWNAM", - winbindd_getpwnam_send, winbindd_getpwnam_recv }, - { WINBINDD_GETPWUID, "GETPWUID", - winbindd_getpwuid_send, winbindd_getpwuid_recv }, - { WINBINDD_GETSIDALIASES, "GETSIDALIASES", - winbindd_getsidaliases_send, winbindd_getsidaliases_recv }, - { WINBINDD_GETUSERDOMGROUPS, "GETUSERDOMGROUPS", - winbindd_getuserdomgroups_send, winbindd_getuserdomgroups_recv }, - { WINBINDD_GETGROUPS, "GETGROUPS", - winbindd_getgroups_send, winbindd_getgroups_recv }, - { WINBINDD_SHOW_SEQUENCE, "SHOW_SEQUENCE", - winbindd_show_sequence_send, winbindd_show_sequence_recv }, - { WINBINDD_GETGRGID, "GETGRGID", - winbindd_getgrgid_send, winbindd_getgrgid_recv }, - { WINBINDD_GETGRNAM, "GETGRNAM", - winbindd_getgrnam_send, winbindd_getgrnam_recv }, - { WINBINDD_GETUSERSIDS, "GETUSERSIDS", - winbindd_getusersids_send, winbindd_getusersids_recv }, - { WINBINDD_LOOKUPRIDS, "LOOKUPRIDS", - winbindd_lookuprids_send, winbindd_lookuprids_recv }, - { WINBINDD_SETPWENT, "SETPWENT", - winbindd_setpwent_send, winbindd_setpwent_recv }, - { WINBINDD_GETPWENT, "GETPWENT", - winbindd_getpwent_send, winbindd_getpwent_recv }, - { WINBINDD_ENDPWENT, "ENDPWENT", - winbindd_endpwent_send, winbindd_endpwent_recv }, - { WINBINDD_DSGETDCNAME, "DSGETDCNAME", - winbindd_dsgetdcname_send, winbindd_dsgetdcname_recv }, - { WINBINDD_GETDCNAME, "GETDCNAME", - winbindd_getdcname_send, winbindd_getdcname_recv }, - { WINBINDD_SETGRENT, "SETGRENT", - winbindd_setgrent_send, winbindd_setgrent_recv }, - { WINBINDD_GETGRENT, "GETGRENT", - winbindd_getgrent_send, winbindd_getgrent_recv }, - { WINBINDD_ENDGRENT, "ENDGRENT", - winbindd_endgrent_send, winbindd_endgrent_recv }, - { WINBINDD_LIST_USERS, "LIST_USERS", - winbindd_list_users_send, winbindd_list_users_recv }, - { WINBINDD_LIST_GROUPS, "LIST_GROUPS", - winbindd_list_groups_send, winbindd_list_groups_recv }, - { WINBINDD_CHECK_MACHACC, "CHECK_MACHACC", - winbindd_check_machine_acct_send, winbindd_check_machine_acct_recv }, - { WINBINDD_PING_DC, "PING_DC", - winbindd_ping_dc_send, winbindd_ping_dc_recv }, - { WINBINDD_PAM_AUTH, "PAM_AUTH", - winbindd_pam_auth_send, winbindd_pam_auth_recv }, - { WINBINDD_PAM_LOGOFF, "PAM_LOGOFF", - winbindd_pam_logoff_send, winbindd_pam_logoff_recv }, - { WINBINDD_PAM_CHAUTHTOK, "PAM_CHAUTHTOK", - winbindd_pam_chauthtok_send, winbindd_pam_chauthtok_recv }, - { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, "PAM_CHNG_PSWD_AUTH_CRAP", - winbindd_pam_chng_pswd_auth_crap_send, - winbindd_pam_chng_pswd_auth_crap_recv }, - - { 0, NULL, NULL, NULL } -}; - -static struct winbindd_async_dispatch_table async_priv_table[] = { - { WINBINDD_ALLOCATE_UID, "ALLOCATE_UID", - winbindd_allocate_uid_send, winbindd_allocate_uid_recv }, - { WINBINDD_ALLOCATE_GID, "ALLOCATE_GID", - winbindd_allocate_gid_send, winbindd_allocate_gid_recv }, - { WINBINDD_CHANGE_MACHACC, "CHANGE_MACHACC", - winbindd_change_machine_acct_send, winbindd_change_machine_acct_recv }, - { WINBINDD_PAM_AUTH_CRAP, "PAM_AUTH_CRAP", - winbindd_pam_auth_crap_send, winbindd_pam_auth_crap_recv }, - - { 0, NULL, NULL, NULL } -}; - -static void wb_request_done(struct tevent_req *req); - -void wb_process_request(struct winbindd_cli_state *state) -{ - struct winbindd_dispatch_table *table = dispatch_table; - struct winbindd_async_dispatch_table *atable; - - state->mem_ctx = talloc_named(state, 0, "winbind request"); - if (state->mem_ctx == NULL) - return; - - /* Remember who asked us. */ - state->pid = state->request->pid; - - state->cmd_name = "unknown request"; - state->recv_fn = NULL; - - /* Process command */ - - for (atable = async_nonpriv_table; atable->send_req; atable += 1) { - if (state->request->cmd == atable->cmd) { - break; - } - } - - if ((atable->send_req == NULL) && state->privileged) { - for (atable = async_priv_table; atable->send_req; - atable += 1) { - if (state->request->cmd == atable->cmd) { - break; - } - } - } - - if (atable->send_req != NULL) { - struct tevent_req *req; - - state->cmd_name = atable->cmd_name; - state->recv_fn = atable->recv_req; - - DEBUG(10, ("wb_process_request: Handling async request %d:%s\n", - (int)state->pid, state->cmd_name)); - - req = atable->send_req(state->mem_ctx, winbind_event_context(), - state, state->request); - if (req == NULL) { - DEBUG(0, ("wb_process_request: atable->send failed for " - "%s\n", atable->cmd_name)); - request_error(state); - return; - } - tevent_req_set_callback(req, wb_request_done, state); - return; - } - - state->response = talloc_zero(state->mem_ctx, - struct winbindd_response); - if (state->response == NULL) { - DEBUG(10, ("talloc failed\n")); - winbindd_remove_client(state); - return; - } - state->response->result = WINBINDD_PENDING; - state->response->length = sizeof(struct winbindd_response); - - for (table = dispatch_table; table->fn; table++) { - if (state->request->cmd == table->cmd) { - DEBUG(10,("wb_process_request: request fn %s\n", - table->winbindd_cmd_name )); - state->cmd_name = table->winbindd_cmd_name; - table->fn(state); - break; - } - } - - if (!table->fn) { - DEBUG(10,("wb_process_request: unknown request fn number %d\n", - (int)state->request->cmd )); - request_error(state); - } -} - -static void wb_request_done(struct tevent_req *req) -{ - struct winbindd_cli_state *state = tevent_req_callback_data( - req, struct winbindd_cli_state); - NTSTATUS status; - - state->response = talloc_zero(state->mem_ctx, - struct winbindd_response); - if (state->response == NULL) { - DEBUG(0, ("wb_request_done[%d:%s]: talloc_zero failed - removing client\n", - (int)state->pid, state->cmd_name)); - winbindd_remove_client(state); - return; - } - state->response->result = WINBINDD_PENDING; - state->response->length = sizeof(struct winbindd_response); - - status = state->recv_fn(req, state->response); - TALLOC_FREE(req); - - DEBUG(10,("wb_request_done[%d:%s]: %s\n", - (int)state->pid, state->cmd_name, nt_errstr(status))); - - if (!NT_STATUS_IS_OK(status)) { - request_error(state); - return; - } - request_ok(state); -} - -void request_error(struct winbindd_cli_state *state) -{ - SMB_ASSERT(state->response->result == WINBINDD_PENDING); - state->response->result = WINBINDD_ERROR; - request_finished(state); -} - -void request_ok(struct winbindd_cli_state *state) -{ - SMB_ASSERT(state->response->result == WINBINDD_PENDING); - state->response->result = WINBINDD_OK; - request_finished(state); -} - bool winbindd_use_idmap_cache(void) { return !opt_nocache; @@ -769,9 +509,6 @@ void winbindd_register_handlers(void) } } - -/* Main function */ - int main(int argc, char **argv, char **envp) { static bool is_daemon = False; diff --git a/source3/winbindd/winbindd_process.c b/source3/winbindd/winbindd_process.c new file mode 100644 index 00000000000..1d0f189c44b --- /dev/null +++ b/source3/winbindd/winbindd_process.c @@ -0,0 +1,292 @@ +/* + Unix SMB/CIFS implementation. + + Winbind daemon for ntdom nss module + + Copyright (C) by Tim Potter 2000-2002 + Copyright (C) Andrew Tridgell 2002 + Copyright (C) Jelmer Vernooij 2003 + Copyright (C) Volker Lendecke 2004 + Copyright (C) Andrew Bartlett 2010 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "winbindd.h" +#include "../../nsswitch/libwbclient/wbc_async.h" +#include "librpc/gen_ndr/messaging.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_WINBIND + +static struct winbindd_dispatch_table { + enum winbindd_cmd cmd; + void (*fn)(struct winbindd_cli_state *state); + const char *winbindd_cmd_name; +} dispatch_table[] = { + + /* Enumeration functions */ + + { WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains, + "LIST_TRUSTDOM" }, + + /* Miscellaneous */ + + { WINBINDD_INFO, winbindd_info, "INFO" }, + { WINBINDD_INTERFACE_VERSION, winbindd_interface_version, + "INTERFACE_VERSION" }, + { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" }, + { WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" }, + { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" }, + { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir, + "WINBINDD_PRIV_PIPE_DIR" }, + + /* Credential cache access */ + { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" }, + { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" }, + + /* WINS functions */ + + { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" }, + { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" }, + + /* End of list */ + + { WINBINDD_NUM_CMDS, NULL, "NONE" } +}; + +struct winbindd_async_dispatch_table { + enum winbindd_cmd cmd; + const char *cmd_name; + struct tevent_req *(*send_req)(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct winbindd_cli_state *cli, + struct winbindd_request *request); + NTSTATUS (*recv_req)(struct tevent_req *req, + struct winbindd_response *presp); +}; + +static struct winbindd_async_dispatch_table async_nonpriv_table[] = { + { WINBINDD_PING, "PING", + wb_ping_send, wb_ping_recv }, + { WINBINDD_LOOKUPSID, "LOOKUPSID", + winbindd_lookupsid_send, winbindd_lookupsid_recv }, + { WINBINDD_LOOKUPNAME, "LOOKUPNAME", + winbindd_lookupname_send, winbindd_lookupname_recv }, + { WINBINDD_SID_TO_UID, "SID_TO_UID", + winbindd_sid_to_uid_send, winbindd_sid_to_uid_recv }, + { WINBINDD_SID_TO_GID, "SID_TO_GID", + winbindd_sid_to_gid_send, winbindd_sid_to_gid_recv }, + { WINBINDD_UID_TO_SID, "UID_TO_SID", + winbindd_uid_to_sid_send, winbindd_uid_to_sid_recv }, + { WINBINDD_GID_TO_SID, "GID_TO_SID", + winbindd_gid_to_sid_send, winbindd_gid_to_sid_recv }, + { WINBINDD_GETPWSID, "GETPWSID", + winbindd_getpwsid_send, winbindd_getpwsid_recv }, + { WINBINDD_GETPWNAM, "GETPWNAM", + winbindd_getpwnam_send, winbindd_getpwnam_recv }, + { WINBINDD_GETPWUID, "GETPWUID", + winbindd_getpwuid_send, winbindd_getpwuid_recv }, + { WINBINDD_GETSIDALIASES, "GETSIDALIASES", + winbindd_getsidaliases_send, winbindd_getsidaliases_recv }, + { WINBINDD_GETUSERDOMGROUPS, "GETUSERDOMGROUPS", + winbindd_getuserdomgroups_send, winbindd_getuserdomgroups_recv }, + { WINBINDD_GETGROUPS, "GETGROUPS", + winbindd_getgroups_send, winbindd_getgroups_recv }, + { WINBINDD_SHOW_SEQUENCE, "SHOW_SEQUENCE", + winbindd_show_sequence_send, winbindd_show_sequence_recv }, + { WINBINDD_GETGRGID, "GETGRGID", + winbindd_getgrgid_send, winbindd_getgrgid_recv }, + { WINBINDD_GETGRNAM, "GETGRNAM", + winbindd_getgrnam_send, winbindd_getgrnam_recv }, + { WINBINDD_GETUSERSIDS, "GETUSERSIDS", + winbindd_getusersids_send, winbindd_getusersids_recv }, + { WINBINDD_LOOKUPRIDS, "LOOKUPRIDS", + winbindd_lookuprids_send, winbindd_lookuprids_recv }, + { WINBINDD_SETPWENT, "SETPWENT", + winbindd_setpwent_send, winbindd_setpwent_recv }, + { WINBINDD_GETPWENT, "GETPWENT", + winbindd_getpwent_send, winbindd_getpwent_recv }, + { WINBINDD_ENDPWENT, "ENDPWENT", + winbindd_endpwent_send, winbindd_endpwent_recv }, + { WINBINDD_DSGETDCNAME, "DSGETDCNAME", + winbindd_dsgetdcname_send, winbindd_dsgetdcname_recv }, + { WINBINDD_GETDCNAME, "GETDCNAME", + winbindd_getdcname_send, winbindd_getdcname_recv }, + { WINBINDD_SETGRENT, "SETGRENT", + winbindd_setgrent_send, winbindd_setgrent_recv }, + { WINBINDD_GETGRENT, "GETGRENT", + winbindd_getgrent_send, winbindd_getgrent_recv }, + { WINBINDD_ENDGRENT, "ENDGRENT", + winbindd_endgrent_send, winbindd_endgrent_recv }, + { WINBINDD_LIST_USERS, "LIST_USERS", + winbindd_list_users_send, winbindd_list_users_recv }, + { WINBINDD_LIST_GROUPS, "LIST_GROUPS", + winbindd_list_groups_send, winbindd_list_groups_recv }, + { WINBINDD_CHECK_MACHACC, "CHECK_MACHACC", + winbindd_check_machine_acct_send, winbindd_check_machine_acct_recv }, + { WINBINDD_PING_DC, "PING_DC", + winbindd_ping_dc_send, winbindd_ping_dc_recv }, + { WINBINDD_PAM_AUTH, "PAM_AUTH", + winbindd_pam_auth_send, winbindd_pam_auth_recv }, + { WINBINDD_PAM_LOGOFF, "PAM_LOGOFF", + winbindd_pam_logoff_send, winbindd_pam_logoff_recv }, + { WINBINDD_PAM_CHAUTHTOK, "PAM_CHAUTHTOK", + winbindd_pam_chauthtok_send, winbindd_pam_chauthtok_recv }, + { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, "PAM_CHNG_PSWD_AUTH_CRAP", + winbindd_pam_chng_pswd_auth_crap_send, + winbindd_pam_chng_pswd_auth_crap_recv }, + + { 0, NULL, NULL, NULL } +}; + +static struct winbindd_async_dispatch_table async_priv_table[] = { + { WINBINDD_ALLOCATE_UID, "ALLOCATE_UID", + winbindd_allocate_uid_send, winbindd_allocate_uid_recv }, + { WINBINDD_ALLOCATE_GID, "ALLOCATE_GID", + winbindd_allocate_gid_send, winbindd_allocate_gid_recv }, + { WINBINDD_CHANGE_MACHACC, "CHANGE_MACHACC", + winbindd_change_machine_acct_send, winbindd_change_machine_acct_recv }, + { WINBINDD_PAM_AUTH_CRAP, "PAM_AUTH_CRAP", + winbindd_pam_auth_crap_send, winbindd_pam_auth_crap_recv }, + + { 0, NULL, NULL, NULL } +}; + +static void wb_request_done(struct tevent_req *req); + +void wb_process_request(struct winbindd_cli_state *state) +{ + struct winbindd_dispatch_table *table = dispatch_table; + struct winbindd_async_dispatch_table *atable; + + state->mem_ctx = talloc_named(state, 0, "winbind request"); + if (state->mem_ctx == NULL) + return; + + /* Remember who asked us. */ + state->pid = state->request->pid; + + state->cmd_name = "unknown request"; + state->recv_fn = NULL; + + /* Process command */ + + for (atable = async_nonpriv_table; atable->send_req; atable += 1) { + if (state->request->cmd == atable->cmd) { + break; + } + } + + if ((atable->send_req == NULL) && state->privileged) { + for (atable = async_priv_table; atable->send_req; + atable += 1) { + if (state->request->cmd == atable->cmd) { + break; + } + } + } + + if (atable->send_req != NULL) { + struct tevent_req *req; + + state->cmd_name = atable->cmd_name; + state->recv_fn = atable->recv_req; + + DEBUG(10, ("wb_process_request: Handling async request %d:%s\n", + (int)state->pid, state->cmd_name)); + + req = atable->send_req(state->mem_ctx, winbind_event_context(), + state, state->request); + if (req == NULL) { + DEBUG(0, ("wb_process_request: atable->send failed for " + "%s\n", atable->cmd_name)); + request_error(state); + return; + } + tevent_req_set_callback(req, wb_request_done, state); + return; + } + + state->response = talloc_zero(state->mem_ctx, + struct winbindd_response); + if (state->response == NULL) { + DEBUG(10, ("talloc failed\n")); + winbindd_remove_client(state); + return; + } + state->response->result = WINBINDD_PENDING; + state->response->length = sizeof(struct winbindd_response); + + for (table = dispatch_table; table->fn; table++) { + if (state->request->cmd == table->cmd) { + DEBUG(10,("wb_process_request: request fn %s\n", + table->winbindd_cmd_name )); + state->cmd_name = table->winbindd_cmd_name; + table->fn(state); + break; + } + } + + if (!table->fn) { + DEBUG(10,("wb_process_request: unknown request fn number %d\n", + (int)state->request->cmd )); + request_error(state); + } +} + +static void wb_request_done(struct tevent_req *req) +{ + struct winbindd_cli_state *state = tevent_req_callback_data( + req, struct winbindd_cli_state); + NTSTATUS status; + + state->response = talloc_zero(state->mem_ctx, + struct winbindd_response); + if (state->response == NULL) { + DEBUG(0, ("wb_request_done[%d:%s]: talloc_zero failed - removing client\n", + (int)state->pid, state->cmd_name)); + winbindd_remove_client(state); + return; + } + state->response->result = WINBINDD_PENDING; + state->response->length = sizeof(struct winbindd_response); + + status = state->recv_fn(req, state->response); + TALLOC_FREE(req); + + DEBUG(10,("wb_request_done[%d:%s]: %s\n", + (int)state->pid, state->cmd_name, nt_errstr(status))); + + if (!NT_STATUS_IS_OK(status)) { + request_error(state); + return; + } + request_ok(state); +} + +void request_error(struct winbindd_cli_state *state) +{ + SMB_ASSERT(state->response->result == WINBINDD_PENDING); + state->response->result = WINBINDD_ERROR; + request_finished(state); +} + +void request_ok(struct winbindd_cli_state *state) +{ + SMB_ASSERT(state->response->result == WINBINDD_PENDING); + state->response->result = WINBINDD_OK; + request_finished(state); +} diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 55dbd54ae88..5b89db4a0c7 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -50,9 +50,13 @@ bool client_is_idle(struct winbindd_cli_state *state); /* The following definitions come from winbindd/winbindd.c */ struct messaging_context *winbind_messaging_context(void); + +/* The following definitions come from winbindd/winbindd_process.c */ void wb_process_request(struct winbindd_cli_state *state); void request_error(struct winbindd_cli_state *state); void request_ok(struct winbindd_cli_state *state); + +/* The following definitions come from winbindd/winbindd.c */ bool winbindd_setup_sig_term_handler(bool parent); bool winbindd_setup_sig_hup_handler(const char *lfile); bool winbindd_use_idmap_cache(void); -- 2.34.1