source4/smbd: Do not overstamp the process model with "single"
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 18 Sep 2017 01:05:24 +0000 (13:05 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2017 03:33:10 +0000 (05:33 +0200)
Instead, except in RPC which is a special SNOWFLAKE, we rely on the struct
service_details in the init function.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dns_server/dns_server.c
source4/echo_server/echo_server.c
source4/kdc/kdc-heimdal.c
source4/kdc/kdc-service-mit.c
source4/ldap_server/ldap_server.c
source4/ntp_signd/ntp_signd.c
source4/web_server/web_server.c
source4/wrepl_server/wrepl_in_connection.c

index 6a90e3089f5c325c86d2a6a8e086d7cc7a0716d1..cd293b8252283b2bb6af36d70c8b80b82c30f4ff 100644 (file)
@@ -684,23 +684,14 @@ static NTSTATUS dns_add_socket(struct dns_server *dns,
   setup our listening sockets on the configured network interfaces
 */
 static NTSTATUS dns_startup_interfaces(struct dns_server *dns,
-                                      struct interface *ifaces)
+                                      struct interface *ifaces,
+                                      const struct model_ops *model_ops)
 {
-       const struct model_ops *model_ops;
        int num_interfaces;
        TALLOC_CTX *tmp_ctx = talloc_new(dns);
        NTSTATUS status;
        int i;
 
-       /* within the dns task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops\n"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        if (ifaces != NULL) {
                num_interfaces = iface_list_count(ifaces);
 
@@ -907,7 +898,7 @@ static void dns_task_init(struct task_server *task)
                return;
        }
 
-       status = dns_startup_interfaces(dns, ifaces);
+       status = dns_startup_interfaces(dns, ifaces, task->model_ops);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "dns failed to setup interfaces", true);
                return;
index 9a66211ebe8a5dfe3f7edfee612853ec4b561046..90f8616ca1147ffd0149c8cda65f0ed2f4f49cf1 100644 (file)
@@ -241,34 +241,14 @@ static NTSTATUS echo_add_socket(struct echo_server *echo,
 /* Set up the listening sockets */
 static NTSTATUS echo_startup_interfaces(struct echo_server *echo,
                                        struct loadparm_context *lp_ctx,
-                                       struct interface *ifaces)
+                                       struct interface *ifaces,
+                                       const struct model_ops *model_ops)
 {
-       const struct model_ops *model_ops;
        int num_interfaces;
        TALLOC_CTX *tmp_ctx = talloc_new(echo);
        NTSTATUS status;
        int i;
 
-       /*
-        * Samba allows subtask to set their own process model.
-        * Available models currently are:
-        * - onefork  (forks exactly one child process)
-        * - prefork  (keep a couple of child processes around)
-        * - single   (only run a single process)
-        * - standard (fork one subprocess per incoming connection)
-        * - thread   (use threads instead of forks)
-        *
-        * For the echo server, the "single" process model works fine,
-        * you probably don't want to use the thread model unless you really
-        * know what you're doing.
-        */
-
-       model_ops = process_model_startup("single");
-       if (model_ops == NULL) {
-               DEBUG(0, ("Can't find 'single' process model_ops\n"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        num_interfaces = iface_list_count(ifaces);
 
        for(i=0; i<num_interfaces; i++) {
@@ -327,7 +307,8 @@ static void echo_task_init(struct task_server *task)
 
        echo->task = task;
 
-       status = echo_startup_interfaces(echo, task->lp_ctx, ifaces);
+       status = echo_startup_interfaces(echo, task->lp_ctx, ifaces,
+                                        task->model_ops);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "echo: Failed to set up interfaces",
                                      true);
index 788959a737ad18c104e3702c174d0e8a6aec2e00..fcc1eb02edf430c91100c86a6ac51a0fbf90f9eb 100644 (file)
@@ -110,10 +110,11 @@ static kdc_code kdc_process(struct kdc_server *kdc,
 /*
   setup our listening sockets on the configured network interfaces
 */
-static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_context *lp_ctx,
-                                      struct interface *ifaces)
+static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc,
+                                      struct loadparm_context *lp_ctx,
+                                      struct interface *ifaces,
+                                      const struct model_ops *model_ops)
 {
-       const struct model_ops *model_ops;
        int num_interfaces;
        TALLOC_CTX *tmp_ctx = talloc_new(kdc);
        NTSTATUS status;
@@ -122,15 +123,6 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
        uint16_t kpasswd_port = lpcfg_kpasswd_port(lp_ctx);
        bool done_wildcard = false;
 
-       /* within the kdc task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops\n"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        num_interfaces = iface_list_count(ifaces);
 
        /* if we are allowing incoming packets from any address, then
@@ -448,7 +440,8 @@ static void kdc_task_init(struct task_server *task)
        kdc->private_data = kdc_config;
 
        /* start listening on the configured network interfaces */
-       status = kdc_startup_interfaces(kdc, task->lp_ctx, ifaces);
+       status = kdc_startup_interfaces(kdc, task->lp_ctx, ifaces,
+                                       task->model_ops);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "kdc failed to setup interfaces", true);
                return;
index d48b03288821572b29c145f868d73955396bd8fa..53997d5473d471cb52efd74202f6720371e3b24f 100644 (file)
@@ -72,12 +72,6 @@ static NTSTATUS startup_kpasswd_server(TALLOC_CTX *mem_ctx,
                return NT_STATUS_OK;
        }
 
-       model_ops = process_model_startup("single");
-       if (model_ops == NULL) {
-               DBG_ERR("Can't find 'single' process model_ops\n");
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        tmp_ctx = talloc_named_const(mem_ctx, 0, "kpasswd");
        if (tmp_ctx == NULL) {
                return NT_STATUS_NO_MEMORY;
index d12c4e70e028916ec2334298dc9bc98132cfb2d5..5f7efe90bba6f6a5c289c3c6f18ea3629b754710 100644 (file)
@@ -1112,7 +1112,6 @@ static void ldapsrv_task_init(struct task_server *task)
        const char *dns_host_name;
        struct ldapsrv_service *ldap_service;
        NTSTATUS status;
-       const struct model_ops *model_ops;
 
        switch (lpcfg_server_role(task->lp_ctx)) {
        case ROLE_STANDALONE:
@@ -1130,13 +1129,6 @@ static void ldapsrv_task_init(struct task_server *task)
 
        task_server_set_title(task, "task[ldapsrv]");
 
-       /*
-        * Here we used to run the ldap server as a single process,
-        * but we don't want transaction locks for one task in a write
-        * blocking all other reads, so we go multi-process.
-        */
-       model_ops = task->model_ops;
-
        ldap_service = talloc_zero(task, struct ldapsrv_service);
        if (ldap_service == NULL) goto failed;
 
@@ -1180,7 +1172,8 @@ static void ldapsrv_task_init(struct task_server *task)
                */
                for(i = 0; i < num_interfaces; i++) {
                        const char *address = iface_list_n_ip(ifaces, i);
-                       status = add_socket(task, task->lp_ctx, model_ops, address, ldap_service);
+                       status = add_socket(task, task->lp_ctx, task->model_ops,
+                                           address, ldap_service);
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
        } else {
@@ -1193,7 +1186,8 @@ static void ldapsrv_task_init(struct task_server *task)
                        goto failed;
                }
                for (i=0; wcard[i]; i++) {
-                       status = add_socket(task, task->lp_ctx, model_ops, wcard[i], ldap_service);
+                       status = add_socket(task, task->lp_ctx, task->model_ops,
+                                           wcard[i], ldap_service);
                        if (NT_STATUS_IS_OK(status)) {
                                num_binds++;
                        }
@@ -1210,7 +1204,7 @@ static void ldapsrv_task_init(struct task_server *task)
        }
 
        status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
-                                    model_ops, &ldap_stream_nonpriv_ops,
+                                    task->model_ops, &ldap_stream_nonpriv_ops,
                                     "unix", ldapi_path, NULL, 
                                     lpcfg_socket_options(task->lp_ctx),
                                     ldap_service, task->process_context);
@@ -1241,7 +1235,7 @@ static void ldapsrv_task_init(struct task_server *task)
        }
 
        status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
-                                    model_ops, &ldap_stream_priv_ops,
+                                    task->model_ops, &ldap_stream_priv_ops,
                                     "unix", ldapi_path, NULL,
                                     lpcfg_socket_options(task->lp_ctx),
                                     ldap_service,
index 0884d2f53b55070f0046552f94d10d0cdb2c17c1..e09c69346e0e3273d49d7f3e411cbc8e2f9ad45b 100644 (file)
@@ -494,8 +494,6 @@ static void ntp_signd_task_init(struct task_server *task)
        struct ntp_signd_server *ntp_signd;
        NTSTATUS status;
 
-       const struct model_ops *model_ops;
-
        const char *address;
 
        if (!directory_create_or_exist_strict(lpcfg_ntp_signd_socket_directory(task->lp_ctx), geteuid(), 0750)) {
@@ -506,15 +504,6 @@ static void ntp_signd_task_init(struct task_server *task)
                return;
        }
 
-       /* within the ntp_signd task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops\n"));
-               return;
-       }
-
        task_server_set_title(task, "task[ntp_signd]");
 
        ntp_signd = talloc(task, struct ntp_signd_server);
@@ -537,7 +526,7 @@ static void ntp_signd_task_init(struct task_server *task)
        status = stream_setup_socket(ntp_signd->task,
                                     ntp_signd->task->event_ctx,
                                     ntp_signd->task->lp_ctx,
-                                    model_ops, 
+                                    task->model_ops,
                                     &ntp_signd_stream_ops, 
                                     "unix", address, NULL,
                                     lpcfg_socket_options(ntp_signd->task->lp_ctx),
index faf1bc65650cc24a9e8620c47b2ff32c689fb8f0..c3516890eb72b6cfca4617c3349994b92242b10f 100644 (file)
@@ -298,15 +298,10 @@ static void websrv_task_init(struct task_server *task)
 {
        NTSTATUS status;
        uint16_t port = lpcfg_web_port(task->lp_ctx);
-       const struct model_ops *model_ops;
        struct web_server_data *wdata;
 
        task_server_set_title(task, "task[websrv]");
 
-       /* run the web server as a single process */
-       model_ops = process_model_startup("single");
-       if (!model_ops) goto failed;
-
        /* startup the Python processor - unfortunately we can't do this
           per connection as that wouldn't allow for session variables */
        wdata = talloc_zero(task, struct web_server_data);
@@ -327,8 +322,9 @@ static void websrv_task_init(struct task_server *task)
                        const char *address = iface_list_n_ip(ifaces, i);
                        status = stream_setup_socket(task,
                                                     task->event_ctx,
-                                                    task->lp_ctx, model_ops,
-                                                    &web_stream_ops, 
+                                                    task->lp_ctx,
+                                                    task->model_ops,
+                                                    &web_stream_ops,
                                                     "ip", address,
                                                     &port,
                                                     lpcfg_socket_options(task->lp_ctx),
@@ -348,7 +344,8 @@ static void websrv_task_init(struct task_server *task)
                }
                for (i=0; wcard[i]; i++) {
                        status = stream_setup_socket(task, task->event_ctx,
-                                                    task->lp_ctx, model_ops,
+                                                    task->lp_ctx,
+                                                    task->model_ops,
                                                     &web_stream_ops,
                                                     "ip", wcard[i],
                                                     &port, lpcfg_socket_options(task->lp_ctx),
index 4920aa0328fe2990e7001a205140474ac996334d..5cbb086a8db3bf61c76d6af9645d24d256ff6fca 100644 (file)
@@ -352,20 +352,10 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
 {
        struct wreplsrv_service *service = partner->service;
        struct wreplsrv_in_connection *wrepl_in;
-       const struct model_ops *model_ops;
        struct stream_connection *conn;
        struct tevent_req *subreq;
        NTSTATUS status;
 
-       /* within the wrepl task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        wrepl_in = talloc_zero(partner, struct wreplsrv_in_connection);
        NT_STATUS_HAVE_NO_MEMORY(wrepl_in);
 
@@ -376,7 +366,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
 
        status = stream_new_connection_merge(service->task->event_ctx,
                                             service->task->lp_ctx,
-                                            model_ops,
+                                            service->task->model_ops,
                                             &wreplsrv_stream_ops,
                                             service->task->msg_ctx,
                                             wrepl_in,
@@ -427,19 +417,9 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
 {
        NTSTATUS status;
        struct task_server *task = service->task;
-       const struct model_ops *model_ops;
        const char *address;
        uint16_t port = WINS_REPLICATION_PORT;
 
-       /* within the wrepl task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        if (lpcfg_interfaces(lp_ctx) && lpcfg_bind_interfaces_only(lp_ctx)) {
                int num_interfaces;
                int i;
@@ -458,12 +438,14 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
                                continue;
                        }
                        address = iface_list_n_ip(ifaces, i);
-                       status = stream_setup_socket(task, task->event_ctx,
-                                                    task->lp_ctx, model_ops,
-                                                    &wreplsrv_stream_ops,
-                                                    "ipv4", address, &port, 
-                                                     lpcfg_socket_options(task->lp_ctx),
-                                                    service, task->process_context);
+                       status = stream_setup_socket(
+                                       task, task->event_ctx,
+                                       task->lp_ctx,
+                                       task->model_ops,
+                                       &wreplsrv_stream_ops,
+                                       "ipv4", address, &port,
+                                       lpcfg_socket_options(task->lp_ctx),
+                                       service, task->process_context);
                        if (!NT_STATUS_IS_OK(status)) {
                                DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",
                                         address, port, nt_errstr(status)));
@@ -472,9 +454,11 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
                }
        } else {
                address = "0.0.0.0";
-               status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
-                                            model_ops, &wreplsrv_stream_ops,
-                                            "ipv4", address, &port, lpcfg_socket_options(task->lp_ctx),
+               status = stream_setup_socket(task, task->event_ctx,
+                                            task->lp_ctx, task->model_ops,
+                                            &wreplsrv_stream_ops,
+                                            "ipv4", address, &port,
+                                            lpcfg_socket_options(task->lp_ctx),
                                             service, task->process_context);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",