]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: talloc the static locator child
authorSamuel Cabrero <scabrero@samba.org>
Tue, 12 Dec 2023 14:49:07 +0000 (15:49 +0100)
committerSamuel Cabrero <scabrero@samba.org>
Wed, 13 Dec 2023 15:07:38 +0000 (15:07 +0000)
Next commits will use talloc_get_type_abort() to get the reference.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/winbindd/winbindd.c
source3/winbindd/winbindd_locator.c
source3/winbindd/winbindd_proto.h

index b87686f04c552433cb003eb2405e96485e86d3fe..608c77c291b028c0e618566f522ab4a65fa049cc 100644 (file)
@@ -1184,7 +1184,12 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx,
                DBG_ERR("Unable to start idmap child: %s\n", nt_errstr(status));
                exit(1);
        }
-       init_locator_child();
+
+       status = init_locator_child(global_event_context());
+       if (NT_STATUS_IS_ERR(status)) {
+               DBG_ERR("Unable to start locator child: %s\n", nt_errstr(status));
+               exit(1);
+       }
 
        smb_nscd_flush_user_cache();
        smb_nscd_flush_group_cache();
index 653ee93d12291b2c0c23590839b41d9b9b446116..c915bf280c48f3ab9d35040bd3af40cfbd979467 100644 (file)
 #define DBGC_CLASS DBGC_WINBIND
 
 
-static struct winbindd_child static_locator_child;
+static struct winbindd_child *static_locator_child = NULL;
 
 struct winbindd_child *locator_child(void)
 {
-       return &static_locator_child;
+       return static_locator_child;
 }
 
 struct dcerpc_binding_handle *locator_child_handle(void)
 {
-       return static_locator_child.binding_handle;
+       return static_locator_child->binding_handle;
 }
 
-void init_locator_child(void)
+NTSTATUS init_locator_child(TALLOC_CTX *mem_ctx)
 {
-       setup_child(NULL, &static_locator_child, "log.winbindd", "locator");
+       if (static_locator_child != NULL) {
+               DBG_ERR("locator child already allocated\n");
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
+       static_locator_child = talloc_zero(mem_ctx, struct winbindd_child);
+       if (static_locator_child == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       setup_child(NULL, static_locator_child, "log.winbindd", "locator");
+       return NT_STATUS_OK;
 }
index 975263bc656d399293bb48a5660da0761db8c735..d42e41fed9405f26146d39fb9e8ef6471f69e9ae 100644 (file)
@@ -404,7 +404,7 @@ bool lp_scan_idmap_domains(bool (*fn)(const char *domname,
 
 /* The following definitions come from winbindd/winbindd_locator.c  */
 
-void init_locator_child(void);
+NTSTATUS init_locator_child(TALLOC_CTX *mem_ctx);
 struct winbindd_child *locator_child(void);
 struct dcerpc_binding_handle *locator_child_handle(void);