s3:winbind: Move winbindd_dual_init_connection() function
authorSamuel Cabrero <scabrero@samba.org>
Mon, 9 May 2022 14:56:18 +0000 (16:56 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 19 May 2022 17:51:33 +0000 (17:51 +0000)
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 <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_dual_srv.c
source3/winbindd/winbindd_util.c

index ae2bd77c8a6cd8230908f09aee236bbe2ae0d046..013dd27ea6e6d78f41526b082f2ceeb432f091b7 100644 (file)
@@ -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)
index 53e7f32b5b982acf4f9f5a63d4a0e7082426d867..b4c53ba971c56aa6ba7e1eb26d7aa323df2a996b 100644 (file)
@@ -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,