conn->connection = c;
conn->service = ldapsrv_service;
- conn->lp_ctx = ldapsrv_service->task->lp_ctx;
+ conn->lp_ctx = ldapsrv_service->lp_ctx;
c->private_data = conn;
}
service->notification.retry = tevent_wakeup_send(service,
- service->task->event_ctx,
+ service->current_ev,
retry);
if (service->notification.retry == NULL) {
/* retry later */
NTSTATUS status;
status = auth_anonymous_session_info(
- c, ldapsrv_service->task->lp_ctx, &session_info);
+ c, ldapsrv_service->lp_ctx, &session_info);
if (!NT_STATUS_IS_OK(status)) {
stream_terminate_connection(c, "failed to setup anonymous "
"session info");
c->private_data, struct ldapsrv_service);
struct auth_session_info *session_info;
- session_info = system_session(ldapsrv_service->task->lp_ctx);
+ session_info = system_session(ldapsrv_service->lp_ctx);
if (!session_info) {
stream_terminate_connection(c, "failed to setup system "
"session info");
/* Load LDAP database, but only to read our settings */
ldb = samdb_connect(ldap_service,
- ldap_service->task->event_ctx,
+ ldap_service->current_ev,
lp_ctx,
system_session(lp_ctx),
NULL,
goto failed;
}
- ldap_service->task = task;
+ ldap_service->lp_ctx = task->lp_ctx;
+ ldap_service->current_ev = task->event_ctx;
+ ldap_service->current_msg = task->msg_ctx;
dns_host_name = talloc_asprintf(ldap_service, "%s.%s",
lpcfg_netbios_name(task->lp_ctx),
struct ldapsrv_service *ldap_service =
talloc_get_type_abort(task->private_data, struct ldapsrv_service);
+ /*
+ * As ldapsrv_before_loop() may changed the values for the parent loop
+ * we need to adjust the pointers to the correct value in the child
+ */
+ ldap_service->lp_ctx = task->lp_ctx;
+ ldap_service->current_ev = task->event_ctx;
+ ldap_service->current_msg = task->msg_ctx;
+
ldap_service->sam_ctx = samdb_connect(ldap_service,
- ldap_service->task->event_ctx,
- ldap_service->task->lp_ctx,
- system_session(ldap_service->task->lp_ctx),
+ ldap_service->current_ev,
+ ldap_service->lp_ctx,
+ system_session(ldap_service->lp_ctx),
NULL,
0);
if (ldap_service->sam_ctx == NULL) {
}
}
+static void ldapsrv_before_loop(struct task_server *task)
+{
+ struct ldapsrv_service *ldap_service =
+ talloc_get_type_abort(task->private_data, struct ldapsrv_service);
+
+ if (ldap_service->sam_ctx != NULL) {
+ /*
+ * Make sure the values are still the same
+ * as set in ldapsrv_post_fork()
+ */
+ SMB_ASSERT(task->lp_ctx == ldap_service->lp_ctx);
+ SMB_ASSERT(task->event_ctx == ldap_service->current_ev);
+ SMB_ASSERT(task->msg_ctx == ldap_service->current_msg);
+ } else {
+ /*
+ * We need to adjust the pointers to the correct value
+ * in the parent loop.
+ */
+ ldap_service->lp_ctx = task->lp_ctx;
+ ldap_service->current_ev = task->event_ctx;
+ ldap_service->current_msg = task->msg_ctx;
+ }
+}
+
/*
* Check the size of an ldap request packet.
*
.inhibit_pre_fork = false,
.task_init = ldapsrv_task_init,
.post_fork = ldapsrv_post_fork,
+ .before_loop = ldapsrv_before_loop,
};
return register_server_service(ctx, "ldap", &details);
}