r15317: Because LDB is now async, there are more places were we might run the
authorAndrew Bartlett <abartlet@samba.org>
Sat, 29 Apr 2006 09:20:22 +0000 (09:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:05:11 +0000 (14:05 -0500)
even context again.  We need to ensure we don't process packets until
we are finished setting up the connection, have the ldb in place etc.

We may need to do the same in other servers.

Andrew Bartlett

source/ldap_server/ldap_server.c

index 9ce371b99b678d63a844af39fc90749630299d98..ba5f41516964bd9dd78cadbf6c2eedaa5e9b11a2 100644 (file)
@@ -420,21 +420,6 @@ static void ldapsrv_accept(struct stream_connection *c)
        conn->connection  = c;
        conn->service     = ldapsrv_service;
 
-       server_credentials 
-               = cli_credentials_init(conn);
-       if (!server_credentials) {
-               stream_terminate_connection(c, "Failed to init server credentials\n");
-               return;
-       }
-       
-       cli_credentials_set_conf(server_credentials);
-       status = cli_credentials_set_machine_account(server_credentials);
-       if (!NT_STATUS_IS_OK(status)) {
-               stream_terminate_connection(c, talloc_asprintf(conn, "Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(status)));
-               return;
-       }
-       conn->server_credentials = server_credentials;
-
        c->private        = conn;
 
        socket_address = socket_get_my_addr(c->socket, conn);
@@ -457,6 +442,7 @@ static void ldapsrv_accept(struct stream_connection *c)
                ldapsrv_terminate_connection(conn, "out of memory");
                return;
        }
+
        packet_set_private(conn->packet, conn);
        packet_set_tls(conn->packet, conn->tls);
        packet_set_callback(conn->packet, ldapsrv_decode);
@@ -465,6 +451,24 @@ static void ldapsrv_accept(struct stream_connection *c)
        packet_set_event_context(conn->packet, c->event.ctx);
        packet_set_fde(conn->packet, c->event.fde);
        packet_set_serialise(conn->packet);
+       
+       /* Ensure we don't get packets until the database is ready below */
+       packet_recv_disable(conn->packet);
+
+       server_credentials 
+               = cli_credentials_init(conn);
+       if (!server_credentials) {
+               stream_terminate_connection(c, "Failed to init server credentials\n");
+               return;
+       }
+       
+       cli_credentials_set_conf(server_credentials);
+       status = cli_credentials_set_machine_account(server_credentials);
+       if (!NT_STATUS_IS_OK(status)) {
+               stream_terminate_connection(c, talloc_asprintf(conn, "Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(status)));
+               return;
+       }
+       conn->server_credentials = server_credentials;
 
        /* Connections start out anonymous */
        if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, &conn->session_info))) {
@@ -487,6 +491,9 @@ static void ldapsrv_accept(struct stream_connection *c)
        conn->limits.ite = event_add_timed(c->event.ctx, conn, 
                                           timeval_current_ofs(conn->limits.initial_timeout, 0),
                                           ldapsrv_conn_init_timeout, conn);
+
+       packet_recv_enable(conn->packet);
+
 }
 
 static const struct stream_server_ops ldap_stream_ops = {