s4-rpc_server: Improve debug of new endpoints
[metze/samba/wip.git] / source4 / rpc_server / dcerpc_server.c
index 5deeb7c5aa3bf38044cc8b9b732a66e071597ed2..6a985c5c63c0dbc9ec32b6b3a228a538e6974e00 100644 (file)
@@ -275,7 +275,8 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
        enum dcerpc_transport_t transport;
        char *ep_string = NULL;
        bool use_single_process = true;
-       
+       const char *ep_process_string;
+
        /*
         * If we are not using handles, there is no need for force
         * this service into using a single process.
@@ -354,8 +355,15 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                 * If we have mulitiple endpoints on port 0, they each
                 * get an epemeral port (currently by walking up from
                 * 1024).
+                *
+                * Because one endpoint can only have one process
+                * model, we add a new IP_TCP endpoint for each model.
+                *
+                * This woks in conjunction with the forced overwrite
+                * of ep->use_single_process below.
                 */
-               if (!use_single_process && transport == NCACN_IP_TCP) {
+               if (ep->use_single_process != use_single_process
+                   && transport == NCACN_IP_TCP) {
                        add_ep = true;
                }
        }
@@ -437,8 +445,15 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
        /* Re-get the string as we may have set a port */
        ep_string = dcerpc_binding_string(dce_ctx, ep->ep_description);
 
-       DEBUG(4,("dcesrv_interface_register: interface '%s' registered on endpoint '%s'\n",
-                iface->name, ep_string));
+       if (use_single_process) {
+               ep_process_string = "single process required";
+       } else {
+               ep_process_string = "multi process compatible";
+       }
+
+       DBG_INFO("dcesrv_interface_register: interface '%s' "
+                "registered on endpoint '%s' (%s)\n",
+                iface->name, ep_string, ep_process_string);
        TALLOC_FREE(ep_string);
 
        return NT_STATUS_OK;
@@ -1186,12 +1201,16 @@ static NTSTATUS dcesrv_auth_reply(struct dcesrv_call_state *call)
 }
 
 
+static void dcesrv_auth3_done(struct tevent_req *subreq);
+
 /*
   handle a auth3 request
 */
 static NTSTATUS dcesrv_auth3(struct dcesrv_call_state *call)
 {
+       struct dcesrv_connection *conn = call->conn;
        struct dcesrv_auth *auth = &call->conn->auth_state;
+       struct tevent_req *subreq = NULL;
        NTSTATUS status;
 
        if (!call->conn->allow_auth3) {
@@ -1235,10 +1254,28 @@ static NTSTATUS dcesrv_auth3(struct dcesrv_call_state *call)
                return NT_STATUS_OK;
        }
 
-       status = gensec_update_ev(auth->gensec_security,
-                                 call, call->event_ctx,
-                                 call->in_auth_info.credentials,
-                                 &call->out_auth_info->credentials);
+       subreq = gensec_update_send(call, call->event_ctx,
+                                   auth->gensec_security,
+                                   call->in_auth_info.credentials);
+       if (subreq == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       tevent_req_set_callback(subreq, dcesrv_auth3_done, call);
+
+       return dcesrv_conn_auth_wait_setup(conn);
+}
+
+static void dcesrv_auth3_done(struct tevent_req *subreq)
+{
+       struct dcesrv_call_state *call =
+               tevent_req_callback_data(subreq,
+               struct dcesrv_call_state);
+       struct dcesrv_connection *conn = call->conn;
+       NTSTATUS status;
+
+       status = gensec_update_recv(subreq, call,
+                                   &call->out_auth_info->credentials);
+       TALLOC_FREE(subreq);
 
        status = dcesrv_auth_complete(call, status);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1251,17 +1288,21 @@ static NTSTATUS dcesrv_auth3(struct dcesrv_call_state *call)
                 */
                call->conn->auth_state.auth_invalid = true;
                if (call->fault_code != 0) {
-                       return dcesrv_fault_disconnect(call, call->fault_code);
+                       status = dcesrv_fault_disconnect(call, call->fault_code);
+                       dcesrv_conn_auth_wait_finished(conn, status);
+                       return;
                }
                TALLOC_FREE(call);
-               return NT_STATUS_OK;
+               dcesrv_conn_auth_wait_finished(conn, NT_STATUS_OK);
+               return;
        }
 
        /*
         * we don't send a reply to a auth3 request.
         */
        TALLOC_FREE(call);
-       return NT_STATUS_OK;
+       dcesrv_conn_auth_wait_finished(conn, NT_STATUS_OK);
+       return;
 }
 
 
@@ -2666,7 +2707,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
                        struct tsocket_address *r = NULL;
 
                        ret = tsocket_address_unix_from_path(dcesrv_conn,
-                                                            "/root/ncalrpc_as_system",
+                                                            AS_SYSTEM_MAGIC_PATH_TOKEN,
                                                             &r);
                        if (ret == -1) {
                                status = map_nt_error_from_unix_common(errno);