1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-22 05:57:43 +03:00

source4/smbd: Do not overstamp the process model with "single"

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>
This commit is contained in:
Gary Lockyer 2017-09-18 13:05:24 +12:00 committed by Andrew Bartlett
parent 62d7bf9e0a
commit 0840252670
8 changed files with 39 additions and 116 deletions

View 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;

View 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);

View 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;

View 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;

View 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,

View 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),

View 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),

View 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",