Remove useless layer of indirection, where every service called
[jelmer/samba4-debian.git] / source / rpc_server / service_rpc.c
index e5ed3bd0cf266218d9b696450df9b36486b57a6d..ddcf1c2a999166172aec47e42e207786a3c57c26 100644 (file)
@@ -107,7 +107,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
        struct dcesrv_connection *dcesrv_conn = NULL;
        struct auth_session_info *session_info = NULL;
 
        struct dcesrv_connection *dcesrv_conn = NULL;
        struct auth_session_info *session_info = NULL;
 
-       status = auth_anonymous_session_info(srv_conn, global_loadparm, &session_info);
+       status = auth_anonymous_session_info(srv_conn, dcesrv_sock->dcesrv_ctx->lp_ctx, &session_info);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("dcesrv_sock_accept: auth_anonymous_session_info failed: %s\n", 
                        nt_errstr(status)));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("dcesrv_sock_accept: auth_anonymous_session_info failed: %s\n", 
                        nt_errstr(status)));
@@ -232,8 +232,10 @@ static NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx,
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
+       status = stream_setup_socket(event_ctx, lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
                                     "unix", e->ep_description->endpoint, &port, 
                                     "unix", e->ep_description->endpoint, &port, 
+                                    lp_socket_options(lp_ctx), 
                                     dcesrv_sock);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(path=%s) failed - %s\n",
                                     dcesrv_sock);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(path=%s) failed - %s\n",
@@ -270,8 +272,11 @@ static NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx,
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
-                                    "unix", full_path, &port, dcesrv_sock);
+       status = stream_setup_socket(event_ctx, lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
+                                    "unix", full_path, &port, 
+                                    lp_socket_options(lp_ctx), 
+                                    dcesrv_sock);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(identifier=%s,path=%s) failed - %s\n",
                         e->ep_description->endpoint, full_path, nt_errstr(status)));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(identifier=%s,path=%s) failed - %s\n",
                         e->ep_description->endpoint, full_path, nt_errstr(status)));
@@ -349,8 +354,11 @@ static NTSTATUS add_socket_rpc_tcp_iface(struct dcesrv_context *dce_ctx, struct
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
-                                    "ipv4", address, &port, dcesrv_sock);
+       status = stream_setup_socket(event_ctx, dce_ctx->lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
+                                    "ipv4", address, &port, 
+                                    lp_socket_options(dce_ctx->lp_ctx), 
+                                    dcesrv_sock);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(address=%s,port=%u) failed - %s\n", 
                         address, port, nt_errstr(status)));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("service_setup_stream_socket(address=%s,port=%u) failed - %s\n", 
                         address, port, nt_errstr(status)));
@@ -372,10 +380,15 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx,
 
        /* Add TCP/IP sockets */
        if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
 
        /* Add TCP/IP sockets */
        if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
-               int num_interfaces = iface_count();
+               int num_interfaces;
                int i;
                int i;
+               struct interface *ifaces;
+
+               load_interfaces(dce_ctx, lp_interfaces(lp_ctx), &ifaces);
+
+               num_interfaces = iface_count(ifaces);
                for(i = 0; i < num_interfaces; i++) {
                for(i = 0; i < num_interfaces; i++) {
-                       const char *address = iface_n_ip(i);
+                       const char *address = iface_n_ip(ifaces, i);
                        status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address);
                        NT_STATUS_NOT_OK_RETURN(status);
                }
                        status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address);
                        NT_STATUS_NOT_OK_RETURN(status);
                }
@@ -444,20 +457,9 @@ failed:
        task_server_terminate(task, "Failed to startup dcerpc server task");    
 }
 
        task_server_terminate(task, "Failed to startup dcerpc server task");    
 }
 
-/*
-  called on startup of the smb server service It's job is to start
-  listening on all configured sockets
-*/
-static NTSTATUS dcesrv_init(struct event_context *event_context, 
-                           struct loadparm_context *lp_ctx,
-                           const struct model_ops *model_ops)
-{      
-       return task_server_startup(event_context, model_ops, dcesrv_task_init);
-}
-
 NTSTATUS server_service_rpc_init(void)
 {
 NTSTATUS server_service_rpc_init(void)
 {
-       init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
+       init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES };
        init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
 
        run_init_functions(static_init);
        init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
 
        run_init_functions(static_init);
@@ -465,5 +467,5 @@ NTSTATUS server_service_rpc_init(void)
 
        talloc_free(shared_init);
        
 
        talloc_free(shared_init);
        
-       return register_server_service("rpc", dcesrv_init);
+       return register_server_service("rpc", dcesrv_task_init);
 }
 }