From: Samuel Cabrero Date: Mon, 9 May 2022 14:56:18 +0000 (+0200) Subject: s3:winbind: Move winbindd_dual_init_connection() function X-Git-Tag: talloc-2.3.4~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=574c3ed9269789e11041d08a5d4eefee4c196dd3;p=thirdparty%2Fsamba.git s3:winbind: Move winbindd_dual_init_connection() function It will be converted later to a local RPC call handler so it must be in the file including ndr_winbind_scompat.c Signed-off-by: Samuel Cabrero Reviewed-by: Jeremy Allison --- diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index ae2bd77c8a6..013dd27ea6e 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -39,6 +39,7 @@ #include "rpc_client/util_netlogon.h" #include "libsmb/dsgetdcname.h" #include "lib/global_contexts.h" +#include "lib/util/string_wrappers.h" NTSTATUS _wbint_Ping(struct pipes_struct *p, struct wbint_Ping *r) { @@ -46,6 +47,50 @@ NTSTATUS _wbint_Ping(struct pipes_struct *p, struct wbint_Ping *r) return NT_STATUS_OK; } +enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain, + struct winbindd_cli_state *state) +{ + /* Ensure null termination */ + state->request->domain_name + [sizeof(state->request->domain_name)-1]='\0'; + state->request->data.init_conn.dcname + [sizeof(state->request->data.init_conn.dcname)-1]='\0'; + + if (strlen(state->request->data.init_conn.dcname) > 0) { + TALLOC_FREE(domain->dcname); + domain->dcname = talloc_strdup(domain, + state->request->data.init_conn.dcname); + if (domain->dcname == NULL) { + return WINBINDD_ERROR; + } + } + + init_dc_connection(domain, false); + + if (!domain->initialized) { + /* If we return error here we can't do any cached authentication, + but we may be in disconnected mode and can't initialize correctly. + Do what the previous code did and just return without initialization, + once we go online we'll re-initialize. + */ + DEBUG(5, ("winbindd_dual_init_connection: %s returning without initialization " + "online = %d\n", domain->name, (int)domain->online )); + } + + fstrcpy(state->response->data.domain_info.name, domain->name); + fstrcpy(state->response->data.domain_info.alt_name, domain->alt_name); + sid_to_fstring(state->response->data.domain_info.sid, &domain->sid); + + state->response->data.domain_info.native_mode + = domain->native_mode; + state->response->data.domain_info.active_directory + = domain->active_directory; + state->response->data.domain_info.primary + = domain->primary; + + return WINBINDD_OK; +} + bool reset_cm_connection_on_error(struct winbindd_domain *domain, struct dcerpc_binding_handle *b, NTSTATUS status) diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index 53e7f32b5b9..b4c53ba971c 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -787,50 +787,6 @@ static void wbd_ping_dc_done(struct tevent_req *subreq) return; } -enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain, - struct winbindd_cli_state *state) -{ - /* Ensure null termination */ - state->request->domain_name - [sizeof(state->request->domain_name)-1]='\0'; - state->request->data.init_conn.dcname - [sizeof(state->request->data.init_conn.dcname)-1]='\0'; - - if (strlen(state->request->data.init_conn.dcname) > 0) { - TALLOC_FREE(domain->dcname); - domain->dcname = talloc_strdup(domain, - state->request->data.init_conn.dcname); - if (domain->dcname == NULL) { - return WINBINDD_ERROR; - } - } - - init_dc_connection(domain, false); - - if (!domain->initialized) { - /* If we return error here we can't do any cached authentication, - but we may be in disconnected mode and can't initialize correctly. - Do what the previous code did and just return without initialization, - once we go online we'll re-initialize. - */ - DEBUG(5, ("winbindd_dual_init_connection: %s returning without initialization " - "online = %d\n", domain->name, (int)domain->online )); - } - - fstrcpy(state->response->data.domain_info.name, domain->name); - fstrcpy(state->response->data.domain_info.alt_name, domain->alt_name); - sid_to_fstring(state->response->data.domain_info.sid, &domain->sid); - - state->response->data.domain_info.native_mode - = domain->native_mode; - state->response->data.domain_info.active_directory - = domain->active_directory; - state->response->data.domain_info.primary - = domain->primary; - - return WINBINDD_OK; -} - static void wb_imsg_new_trusted_domain(struct imessaging_context *msg, void *private_data, uint32_t msg_type,