mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
r26672: Janitorial: Remove uses of global_loadparm.
(This used to be commit 18cd08623e
)
This commit is contained in:
parent
01c7909192
commit
df408d056e
@ -209,7 +209,7 @@ static void cldapd_task_init(struct task_server *task)
|
||||
*/
|
||||
static NTSTATUS cldapd_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
|
||||
{
|
||||
return task_server_startup(event_ctx, model_ops, cldapd_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx, model_ops, cldapd_task_init);
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ static void dreplsrv_task_init(struct task_server *task)
|
||||
*/
|
||||
static NTSTATUS dreplsrv_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
|
||||
{
|
||||
return task_server_startup(event_ctx, model_ops, dreplsrv_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx, model_ops, dreplsrv_task_init);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -489,7 +489,9 @@ static NTSTATUS kdc_add_socket(struct kdc_server *kdc, const char *address,
|
||||
return NT_STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
status = stream_setup_socket(kdc->task->event_ctx, model_ops,
|
||||
status = stream_setup_socket(kdc->task->event_ctx,
|
||||
kdc->task->lp_ctx,
|
||||
model_ops,
|
||||
&kdc_tcp_stream_ops,
|
||||
"ip", address, &kdc_port,
|
||||
lp_socket_options(kdc->task->lp_ctx),
|
||||
@ -501,7 +503,9 @@ static NTSTATUS kdc_add_socket(struct kdc_server *kdc, const char *address,
|
||||
return status;
|
||||
}
|
||||
|
||||
status = stream_setup_socket(kdc->task->event_ctx, model_ops,
|
||||
status = stream_setup_socket(kdc->task->event_ctx,
|
||||
kdc->task->lp_ctx,
|
||||
model_ops,
|
||||
&kpasswdd_tcp_stream_ops,
|
||||
"ip", address, &kpasswd_port,
|
||||
lp_socket_options(kdc->task->lp_ctx),
|
||||
@ -663,7 +667,7 @@ static NTSTATUS kdc_init(struct event_context *event_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const struct model_ops *model_ops)
|
||||
{
|
||||
return task_server_startup(event_ctx, model_ops, kdc_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx, model_ops, kdc_task_init);
|
||||
}
|
||||
|
||||
/* called at smbd startup - register ourselves as a server service */
|
||||
|
@ -449,7 +449,8 @@ static NTSTATUS add_socket(struct event_context *event_context,
|
||||
NTSTATUS status;
|
||||
struct ldb_context *ldb;
|
||||
|
||||
status = stream_setup_socket(event_context, model_ops, &ldap_stream_ops,
|
||||
status = stream_setup_socket(event_context, lp_ctx,
|
||||
model_ops, &ldap_stream_ops,
|
||||
"ipv4", address, &port,
|
||||
lp_socket_options(lp_ctx),
|
||||
ldap_service);
|
||||
@ -461,7 +462,8 @@ static NTSTATUS add_socket(struct event_context *event_context,
|
||||
if (tls_support(ldap_service->tls_params)) {
|
||||
/* add ldaps server */
|
||||
port = 636;
|
||||
status = stream_setup_socket(event_context, model_ops, &ldap_stream_ops,
|
||||
status = stream_setup_socket(event_context, lp_ctx,
|
||||
model_ops, &ldap_stream_ops,
|
||||
"ipv4", address, &port,
|
||||
lp_socket_options(lp_ctx),
|
||||
ldap_service);
|
||||
@ -479,7 +481,8 @@ static NTSTATUS add_socket(struct event_context *event_context,
|
||||
|
||||
if (samdb_is_gc(ldb)) {
|
||||
port = 3268;
|
||||
status = stream_setup_socket(event_context, model_ops, &ldap_stream_ops,
|
||||
status = stream_setup_socket(event_context, lp_ctx,
|
||||
model_ops, &ldap_stream_ops,
|
||||
"ipv4", address, &port,
|
||||
lp_socket_options(lp_ctx),
|
||||
ldap_service);
|
||||
@ -556,7 +559,8 @@ static void ldapsrv_task_init(struct task_server *task)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
status = stream_setup_socket(task->event_ctx, model_ops, &ldap_stream_ops,
|
||||
status = stream_setup_socket(task->event_ctx, task->lp_ctx,
|
||||
model_ops, &ldap_stream_ops,
|
||||
"unix", ldapi_path, NULL,
|
||||
lp_socket_options(task->lp_ctx),
|
||||
ldap_service);
|
||||
@ -580,7 +584,8 @@ static NTSTATUS ldapsrv_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, ldapsrv_task_init);
|
||||
return task_server_startup(event_context, lp_ctx, model_ops,
|
||||
ldapsrv_task_init);
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,7 +93,8 @@ static void nbtd_task_init(struct task_server *task)
|
||||
*/
|
||||
static NTSTATUS nbtd_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
|
||||
{
|
||||
return task_server_startup(event_ctx, model_ops, nbtd_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx,
|
||||
model_ops, nbtd_task_init);
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +82,8 @@ static void rap_heap_restore(struct rap_string_heap *heap,
|
||||
}
|
||||
|
||||
struct rap_call {
|
||||
struct loadparm_context *lp_ctx;
|
||||
|
||||
TALLOC_CTX *mem_ctx;
|
||||
uint16_t callno;
|
||||
const char *paramdesc;
|
||||
@ -103,6 +105,7 @@ struct rap_call {
|
||||
#define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
|
||||
|
||||
static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct smb_trans2 *trans)
|
||||
{
|
||||
struct rap_call *call;
|
||||
@ -114,12 +117,14 @@ static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
|
||||
|
||||
ZERO_STRUCTP(call);
|
||||
|
||||
call->lp_ctx = talloc_reference(call, lp_ctx);
|
||||
|
||||
call->mem_ctx = mem_ctx;
|
||||
|
||||
call->ndr_pull_param = ndr_pull_init_blob(&trans->in.params, mem_ctx, lp_iconv_convenience(global_loadparm));
|
||||
call->ndr_pull_param = ndr_pull_init_blob(&trans->in.params, mem_ctx, lp_iconv_convenience(lp_ctx));
|
||||
call->ndr_pull_param->flags = RAPNDR_FLAGS;
|
||||
|
||||
call->ndr_pull_data = ndr_pull_init_blob(&trans->in.data, mem_ctx, lp_iconv_convenience(global_loadparm));
|
||||
call->ndr_pull_data = ndr_pull_init_blob(&trans->in.data, mem_ctx, lp_iconv_convenience(lp_ctx));
|
||||
call->ndr_pull_data->flags = RAPNDR_FLAGS;
|
||||
|
||||
call->heap = talloc(mem_ctx, struct rap_string_heap);
|
||||
@ -266,7 +271,7 @@ static NTSTATUS _rap_netshareenum(struct rap_call *call)
|
||||
break;
|
||||
}
|
||||
|
||||
result = rap_netshareenum(call, &r);
|
||||
result = rap_netshareenum(call, call->lp_ctx, &r);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result))
|
||||
return result;
|
||||
@ -348,7 +353,7 @@ static NTSTATUS _rap_netserverenum2(struct rap_call *call)
|
||||
break;
|
||||
}
|
||||
|
||||
result = rap_netserverenum2(call, &r);
|
||||
result = rap_netserverenum2(call, call->lp_ctx, &r);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result))
|
||||
return result;
|
||||
@ -425,7 +430,8 @@ static const struct
|
||||
{NULL, -1, api_Unsupported}
|
||||
};
|
||||
|
||||
NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
|
||||
NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
|
||||
struct smb_trans2 *trans)
|
||||
{
|
||||
int i;
|
||||
NTSTATUS result;
|
||||
@ -434,7 +440,7 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
|
||||
struct ndr_push *final_param;
|
||||
struct ndr_push *final_data;
|
||||
|
||||
call = new_rap_srv_call(mem_ctx, trans);
|
||||
call = new_rap_srv_call(mem_ctx, lp_ctx, trans);
|
||||
|
||||
if (call == NULL)
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
@ -445,8 +451,8 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
|
||||
NDR_RETURN(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
|
||||
&call->datadesc));
|
||||
|
||||
call->ndr_push_param = ndr_push_init_ctx(call, lp_iconv_convenience(global_loadparm));
|
||||
call->ndr_push_data = ndr_push_init_ctx(call, lp_iconv_convenience(global_loadparm));
|
||||
call->ndr_push_param = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
|
||||
call->ndr_push_data = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
|
||||
|
||||
if ((call->ndr_push_param == NULL) || (call->ndr_push_data == NULL))
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
@ -471,8 +477,8 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
|
||||
result_param = ndr_push_blob(call->ndr_push_param);
|
||||
result_data = ndr_push_blob(call->ndr_push_data);
|
||||
|
||||
final_param = ndr_push_init_ctx(call, lp_iconv_convenience(global_loadparm));
|
||||
final_data = ndr_push_init_ctx(call, lp_iconv_convenience(global_loadparm));
|
||||
final_param = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
|
||||
final_data = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
|
||||
|
||||
if ((final_param == NULL) || (final_data == NULL))
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
|
@ -29,6 +29,7 @@
|
||||
* idea. */
|
||||
|
||||
NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct rap_NetShareEnum *r)
|
||||
{
|
||||
NTSTATUS nterr;
|
||||
@ -41,7 +42,7 @@ NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
|
||||
r->out.available = 0;
|
||||
r->out.info = NULL;
|
||||
|
||||
nterr = share_get_context_by_name(mem_ctx, lp_share_backend(global_loadparm), global_loadparm, &sctx);
|
||||
nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), lp_ctx, &sctx);
|
||||
if (!NT_STATUS_IS_OK(nterr)) {
|
||||
return nterr;
|
||||
}
|
||||
@ -75,6 +76,7 @@ NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
NTSTATUS rap_netserverenum2(TALLOC_CTX *mem_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct rap_NetServerEnum2 *r)
|
||||
{
|
||||
r->out.status = 0;
|
||||
|
@ -805,7 +805,7 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs,
|
||||
NTSTATUS status;
|
||||
|
||||
if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN"))
|
||||
return ipc_rap_call(req, trans);
|
||||
return ipc_rap_call(req, ntvfs->ctx->lp_ctx, trans);
|
||||
|
||||
if (trans->in.setup_count != 2) {
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
|
@ -126,17 +126,11 @@ _PUBLIC_ NTSTATUS sys_notify_init(void)
|
||||
static bool initialized = false;
|
||||
|
||||
init_module_fn static_init[] = { STATIC_sys_notify_MODULES };
|
||||
init_module_fn *shared_init;
|
||||
|
||||
if (initialized) return NT_STATUS_OK;
|
||||
initialized = true;
|
||||
|
||||
shared_init = load_samba_modules(NULL, global_loadparm, "sys_notify");
|
||||
|
||||
run_init_functions(static_init);
|
||||
run_init_functions(shared_init);
|
||||
|
||||
talloc_free(shared_init);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -232,7 +232,8 @@ 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);
|
||||
|
||||
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,
|
||||
lp_socket_options(lp_ctx),
|
||||
dcesrv_sock);
|
||||
@ -271,7 +272,8 @@ 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);
|
||||
|
||||
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", full_path, &port,
|
||||
lp_socket_options(lp_ctx),
|
||||
dcesrv_sock);
|
||||
@ -352,7 +354,8 @@ 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);
|
||||
|
||||
status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops,
|
||||
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);
|
||||
@ -462,7 +465,8 @@ 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);
|
||||
return task_server_startup(event_context, lp_ctx,
|
||||
model_ops, dcesrv_task_init);
|
||||
}
|
||||
|
||||
NTSTATUS server_service_rpc_init(void)
|
||||
|
@ -353,7 +353,7 @@ static void smb2srv_notify_send(struct ntvfs_request *ntvfs)
|
||||
ssize_t len;
|
||||
|
||||
SIVAL(p, 4, io->smb2.out.changes[i].action);
|
||||
len = push_string(lp_iconv_convenience(global_loadparm), p + 12, io->smb2.out.changes[i].name.s,
|
||||
len = push_string(lp_iconv_convenience(ntvfs->ctx->lp_ctx), p + 12, io->smb2.out.changes[i].name.s,
|
||||
blob.length - (p+12 - blob.data), STR_UNICODE);
|
||||
SIVAL(p, 8, len);
|
||||
|
||||
|
@ -185,7 +185,8 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(struct event_context *event_context,
|
||||
for (i=0;ports[i];i++) {
|
||||
uint16_t port = atoi(ports[i]);
|
||||
if (port == 0) continue;
|
||||
status = stream_setup_socket(event_context, model_ops, &smb_stream_ops,
|
||||
status = stream_setup_socket(event_context, lp_ctx,
|
||||
model_ops, &smb_stream_ops,
|
||||
"ipv4", address, &port,
|
||||
lp_socket_options(lp_ctx),
|
||||
NULL);
|
||||
@ -257,7 +258,8 @@ static NTSTATUS smbsrv_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, smbsrv_task_init);
|
||||
return task_server_startup(event_context, lp_ctx,
|
||||
model_ops, smbsrv_task_init);
|
||||
}
|
||||
|
||||
/* called at smbd startup - register ourselves as a server service */
|
||||
|
@ -44,14 +44,21 @@ struct model_ops {
|
||||
void (*model_init)(struct event_context *);
|
||||
|
||||
/* function to accept new connection */
|
||||
void (*accept_connection)(struct event_context *, struct socket_context *,
|
||||
void (*)(struct event_context *, struct socket_context *,
|
||||
void (*accept_connection)(struct event_context *,
|
||||
struct loadparm_context *,
|
||||
struct socket_context *,
|
||||
void (*)(struct event_context *,
|
||||
struct loadparm_context *,
|
||||
struct socket_context *,
|
||||
struct server_id , void *),
|
||||
void *);
|
||||
|
||||
/* function to create a task */
|
||||
void (*new_task)(struct event_context *,
|
||||
void (*)(struct event_context *, struct server_id, void *),
|
||||
struct loadparm_context *lp_ctx,
|
||||
void (*)(struct event_context *,
|
||||
struct loadparm_context *, struct server_id,
|
||||
void *),
|
||||
void *);
|
||||
|
||||
/* function to terminate a connection or task */
|
||||
|
@ -37,8 +37,11 @@ static void single_model_init(struct event_context *ev)
|
||||
called when a listening socket becomes readable.
|
||||
*/
|
||||
static void single_accept_connection(struct event_context *ev,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct socket_context *sock,
|
||||
void (*new_conn)(struct event_context *, struct socket_context *,
|
||||
void (*new_conn)(struct event_context *,
|
||||
struct loadparm_context *,
|
||||
struct socket_context *,
|
||||
struct server_id , void *),
|
||||
void *private)
|
||||
{
|
||||
@ -61,18 +64,19 @@ static void single_accept_connection(struct event_context *ev,
|
||||
|
||||
talloc_steal(private, sock);
|
||||
|
||||
new_conn(ev, sock2, cluster_id(socket_get_fd(sock2)), private);
|
||||
new_conn(ev, lp_ctx, sock2, cluster_id(socket_get_fd(sock2)), private);
|
||||
}
|
||||
|
||||
/*
|
||||
called to startup a new task
|
||||
*/
|
||||
static void single_new_task(struct event_context *ev,
|
||||
void (*new_task)(struct event_context *, struct server_id, void *),
|
||||
struct loadparm_context *lp_ctx,
|
||||
void (*new_task)(struct event_context *, struct loadparm_context *, struct server_id, void *),
|
||||
void *private)
|
||||
{
|
||||
static uint32_t taskid = 0x10000000;
|
||||
new_task(ev, cluster_id(taskid++), private);
|
||||
new_task(ev, lp_ctx, cluster_id(taskid++), private);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,8 +56,10 @@ static void standard_model_init(struct event_context *ev)
|
||||
called when a listening socket becomes readable.
|
||||
*/
|
||||
static void standard_accept_connection(struct event_context *ev,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct socket_context *sock,
|
||||
void (*new_conn)(struct event_context *, struct socket_context *,
|
||||
void (*new_conn)(struct event_context *,
|
||||
struct loadparm_context *, struct socket_context *,
|
||||
struct server_id , void *),
|
||||
void *private)
|
||||
{
|
||||
@ -126,7 +128,7 @@ static void standard_accept_connection(struct event_context *ev,
|
||||
talloc_free(s);
|
||||
|
||||
/* setup this new connection */
|
||||
new_conn(ev2, sock2, cluster_id(pid), private);
|
||||
new_conn(ev2, lp_ctx, sock2, cluster_id(pid), private);
|
||||
|
||||
/* we can't return to the top level here, as that event context is gone,
|
||||
so we now process events in the new event context until there are no
|
||||
@ -141,7 +143,8 @@ static void standard_accept_connection(struct event_context *ev,
|
||||
called to create a new server task
|
||||
*/
|
||||
static void standard_new_task(struct event_context *ev,
|
||||
void (*new_task)(struct event_context *, struct server_id , void *),
|
||||
struct loadparm_context *lp_ctx,
|
||||
void (*new_task)(struct event_context *, struct loadparm_context *lp_ctx, struct server_id , void *),
|
||||
void *private)
|
||||
{
|
||||
pid_t pid;
|
||||
@ -179,7 +182,7 @@ static void standard_new_task(struct event_context *ev,
|
||||
setproctitle("task server_id[%d]", pid);
|
||||
|
||||
/* setup this new connection */
|
||||
new_task(ev2, cluster_id(pid), private);
|
||||
new_task(ev2, lp_ctx, cluster_id(pid), private);
|
||||
|
||||
/* we can't return to the top level here, as that event context is gone,
|
||||
so we now process events in the new event context until there are no
|
||||
|
@ -39,7 +39,8 @@ static pthread_key_t title_key;
|
||||
struct new_conn_state {
|
||||
struct event_context *ev;
|
||||
struct socket_context *sock;
|
||||
void (*new_conn)(struct event_context *, struct socket_context *, uint32_t , void *);
|
||||
struct loadparm_context *lp_ctx;
|
||||
void (*new_conn)(struct event_context *, struct loadparm_context *lp_ctx, struct socket_context *, uint32_t , void *);
|
||||
void *private;
|
||||
};
|
||||
|
||||
@ -47,7 +48,7 @@ static void *thread_connection_fn(void *thread_parm)
|
||||
{
|
||||
struct new_conn_state *new_conn = talloc_get_type(thread_parm, struct new_conn_state);
|
||||
|
||||
new_conn->new_conn(new_conn->ev, new_conn->sock, pthread_self(), new_conn->private);
|
||||
new_conn->new_conn(new_conn->ev, new_conn->lp_ctx, new_conn->sock, pthread_self(), new_conn->private);
|
||||
|
||||
/* run this connection from here */
|
||||
event_loop_wait(new_conn->ev);
|
||||
@ -61,8 +62,11 @@ static void *thread_connection_fn(void *thread_parm)
|
||||
called when a listening socket becomes readable
|
||||
*/
|
||||
static void thread_accept_connection(struct event_context *ev,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct socket_context *sock,
|
||||
void (*new_conn)(struct event_context *, struct socket_context *,
|
||||
void (*new_conn)(struct event_context *,
|
||||
struct loadparm_context *,
|
||||
struct socket_context *,
|
||||
uint32_t , void *),
|
||||
void *private)
|
||||
{
|
||||
@ -84,6 +88,7 @@ static void thread_accept_connection(struct event_context *ev,
|
||||
|
||||
state->new_conn = new_conn;
|
||||
state->private = private;
|
||||
state->lp_ctx = lp_ctx;
|
||||
state->ev = ev2;
|
||||
|
||||
/* accept an incoming connection. */
|
||||
@ -117,7 +122,9 @@ static void thread_accept_connection(struct event_context *ev,
|
||||
|
||||
struct new_task_state {
|
||||
struct event_context *ev;
|
||||
void (*new_task)(struct event_context *, uint32_t , void *);
|
||||
struct loadparm_context *lp_ctx;
|
||||
void (*new_task)(struct event_context *, struct loadparm_context *,
|
||||
uint32_t , void *);
|
||||
void *private;
|
||||
};
|
||||
|
||||
@ -125,7 +132,8 @@ static void *thread_task_fn(void *thread_parm)
|
||||
{
|
||||
struct new_task_state *new_task = talloc_get_type(thread_parm, struct new_task_state);
|
||||
|
||||
new_task->new_task(new_task->ev, pthread_self(), new_task->private);
|
||||
new_task->new_task(new_task->ev, new_task->lp_ctx, pthread_self(),
|
||||
new_task->private);
|
||||
|
||||
/* run this connection from here */
|
||||
event_loop_wait(new_task->ev);
|
||||
@ -139,7 +147,10 @@ static void *thread_task_fn(void *thread_parm)
|
||||
called when a new task is needed
|
||||
*/
|
||||
static void thread_new_task(struct event_context *ev,
|
||||
void (*new_task)(struct event_context *, uint32_t , void *),
|
||||
struct loadparm_context *lp_ctx,
|
||||
void (*new_task)(struct event_context *,
|
||||
struct loadparm_context *,
|
||||
uint32_t , void *),
|
||||
void *private)
|
||||
{
|
||||
int rc;
|
||||
@ -158,6 +169,7 @@ static void thread_new_task(struct event_context *ev,
|
||||
}
|
||||
|
||||
state->new_task = new_task;
|
||||
state->lp_ctx = lp_ctx;
|
||||
state->private = private;
|
||||
state->ev = ev2;
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
*/
|
||||
struct stream_socket {
|
||||
const struct stream_server_ops *ops;
|
||||
struct loadparm_context *lp_ctx;
|
||||
struct event_context *event_ctx;
|
||||
const struct model_ops *model_ops;
|
||||
struct socket_context *sock;
|
||||
@ -151,6 +152,7 @@ NTSTATUS stream_new_connection_merge(struct event_context *ev,
|
||||
context of the new process (if appropriate)
|
||||
*/
|
||||
static void stream_new_connection(struct event_context *ev,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct socket_context *sock,
|
||||
struct server_id server_id, void *private)
|
||||
{
|
||||
@ -182,9 +184,9 @@ static void stream_new_connection(struct event_context *ev,
|
||||
|
||||
/* setup to receive internal messages on this connection */
|
||||
srv_conn->msg_ctx = messaging_init(srv_conn,
|
||||
lp_messaging_path(srv_conn, global_loadparm),
|
||||
lp_messaging_path(srv_conn, lp_ctx),
|
||||
srv_conn->server_id,
|
||||
lp_iconv_convenience(global_loadparm),
|
||||
lp_iconv_convenience(lp_ctx),
|
||||
ev);
|
||||
if (!srv_conn->msg_ctx) {
|
||||
stream_terminate_connection(srv_conn, "messaging_init() failed");
|
||||
@ -225,7 +227,8 @@ static void stream_accept_handler(struct event_context *ev, struct fd_event *fde
|
||||
/* ask the process model to create us a process for this new
|
||||
connection. When done, it calls stream_new_connection()
|
||||
with the newly created socket */
|
||||
stream_socket->model_ops->accept_connection(ev, stream_socket->sock,
|
||||
stream_socket->model_ops->accept_connection(ev, stream_socket->lp_ctx,
|
||||
stream_socket->sock,
|
||||
stream_new_connection, stream_socket);
|
||||
}
|
||||
|
||||
@ -238,6 +241,7 @@ static void stream_accept_handler(struct event_context *ev, struct fd_event *fde
|
||||
to the socket implementation - JRV20070903
|
||||
*/
|
||||
NTSTATUS stream_setup_socket(struct event_context *event_context,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const struct model_ops *model_ops,
|
||||
const struct stream_server_ops *stream_ops,
|
||||
const char *family,
|
||||
@ -259,6 +263,8 @@ NTSTATUS stream_setup_socket(struct event_context *event_context,
|
||||
|
||||
talloc_steal(stream_socket, stream_socket->sock);
|
||||
|
||||
stream_socket->lp_ctx = talloc_reference(stream_socket, lp_ctx);
|
||||
|
||||
/* ready to listen */
|
||||
status = socket_set_option(stream_socket->sock, "SO_KEEPALIVE", NULL);
|
||||
NT_STATUS_NOT_OK_RETURN(status);
|
||||
|
@ -53,6 +53,7 @@ struct task_state {
|
||||
the server specific startup code
|
||||
*/
|
||||
static void task_server_callback(struct event_context *event_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
struct server_id server_id, void *private)
|
||||
{
|
||||
struct task_state *state = talloc_get_type(private, struct task_state);
|
||||
@ -64,7 +65,7 @@ static void task_server_callback(struct event_context *event_ctx,
|
||||
task->event_ctx = event_ctx;
|
||||
task->model_ops = state->model_ops;
|
||||
task->server_id = server_id;
|
||||
task->lp_ctx = global_loadparm;
|
||||
task->lp_ctx = lp_ctx;
|
||||
|
||||
task->msg_ctx = messaging_init(task,
|
||||
lp_messaging_path(task, task->lp_ctx),
|
||||
@ -83,6 +84,7 @@ static void task_server_callback(struct event_context *event_ctx,
|
||||
startup a task based server
|
||||
*/
|
||||
NTSTATUS task_server_startup(struct event_context *event_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const struct model_ops *model_ops,
|
||||
void (*task_init)(struct task_server *))
|
||||
{
|
||||
@ -94,7 +96,7 @@ NTSTATUS task_server_startup(struct event_context *event_ctx,
|
||||
state->task_init = task_init;
|
||||
state->model_ops = model_ops;
|
||||
|
||||
model_ops->new_task(event_ctx, task_server_callback, state);
|
||||
model_ops->new_task(event_ctx, lp_ctx, task_server_callback, state);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ bool wire_bad_flags(struct smb_wire_string *str, int flags,
|
||||
if (flags & STR_TERMINATE) len++;
|
||||
|
||||
server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?true:false;
|
||||
if (getenv("CLI_FORCE_ASCII") || !lp_unicode(global_loadparm)) {
|
||||
if (getenv("CLI_FORCE_ASCII") || !transport->options.unicode) {
|
||||
server_unicode = false;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,8 @@ static void websrv_task_init(struct task_server *task)
|
||||
num_interfaces = iface_count(ifaces);
|
||||
for(i = 0; i < num_interfaces; i++) {
|
||||
const char *address = iface_n_ip(ifaces, i);
|
||||
status = stream_setup_socket(task->event_ctx, model_ops,
|
||||
status = stream_setup_socket(task->event_ctx,
|
||||
task->lp_ctx, model_ops,
|
||||
&web_stream_ops,
|
||||
"ipv4", address,
|
||||
&port, lp_socket_options(task->lp_ctx),
|
||||
@ -270,8 +271,8 @@ static void websrv_task_init(struct task_server *task)
|
||||
|
||||
talloc_free(ifaces);
|
||||
} else {
|
||||
status = stream_setup_socket(task->event_ctx, model_ops,
|
||||
&web_stream_ops,
|
||||
status = stream_setup_socket(task->event_ctx, task->lp_ctx,
|
||||
model_ops, &web_stream_ops,
|
||||
"ipv4", lp_socket_address(task->lp_ctx),
|
||||
&port, lp_socket_options(task->lp_ctx), task);
|
||||
if (!NT_STATUS_IS_OK(status)) goto failed;
|
||||
@ -297,7 +298,8 @@ static NTSTATUS websrv_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, websrv_task_init);
|
||||
return task_server_startup(event_context, lp_ctx,
|
||||
model_ops, websrv_task_init);
|
||||
}
|
||||
|
||||
/* called at smbd startup - register ourselves as a server service */
|
||||
|
@ -158,7 +158,7 @@ static void winbind_task_init(struct task_server *task)
|
||||
if (!listen_socket->socket_path) goto nomem;
|
||||
listen_socket->service = service;
|
||||
listen_socket->privileged = false;
|
||||
status = stream_setup_socket(task->event_ctx, model_ops,
|
||||
status = stream_setup_socket(task->event_ctx, task->lp_ctx, model_ops,
|
||||
&wbsrv_ops, "unix",
|
||||
listen_socket->socket_path, &port,
|
||||
lp_socket_options(task->lp_ctx),
|
||||
@ -174,7 +174,7 @@ static void winbind_task_init(struct task_server *task)
|
||||
if (!listen_socket->socket_path) goto nomem;
|
||||
listen_socket->service = service;
|
||||
listen_socket->privileged = true;
|
||||
status = stream_setup_socket(task->event_ctx, model_ops,
|
||||
status = stream_setup_socket(task->event_ctx, task->lp_ctx, model_ops,
|
||||
&wbsrv_ops, "unix",
|
||||
listen_socket->socket_path, &port,
|
||||
lp_socket_options(task->lp_ctx),
|
||||
@ -208,7 +208,8 @@ static NTSTATUS winbind_init(struct event_context *event_ctx,
|
||||
struct loadparm_context *lp_ctx,
|
||||
const struct model_ops *model_ops)
|
||||
{
|
||||
return task_server_startup(event_ctx, model_ops, winbind_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx,
|
||||
model_ops, winbind_task_init);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -294,7 +294,9 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
|
||||
*/
|
||||
for(i = 0; i < num_interfaces; i++) {
|
||||
address = iface_n_ip(ifaces, i);
|
||||
status = stream_setup_socket(task->event_ctx, model_ops, &wreplsrv_stream_ops,
|
||||
status = stream_setup_socket(task->event_ctx,
|
||||
task->lp_ctx, model_ops,
|
||||
&wreplsrv_stream_ops,
|
||||
"ipv4", address, &port,
|
||||
lp_socket_options(task->lp_ctx),
|
||||
service);
|
||||
@ -306,7 +308,8 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
|
||||
}
|
||||
} else {
|
||||
address = lp_socket_address(lp_ctx);
|
||||
status = stream_setup_socket(task->event_ctx, model_ops, &wreplsrv_stream_ops,
|
||||
status = stream_setup_socket(task->event_ctx, task->lp_ctx,
|
||||
model_ops, &wreplsrv_stream_ops,
|
||||
"ipv4", address, &port, lp_socket_options(task->lp_ctx),
|
||||
service);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -510,7 +510,8 @@ static NTSTATUS wreplsrv_init(struct event_context *event_ctx, struct loadparm_c
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
return task_server_startup(event_ctx, model_ops, wreplsrv_task_init);
|
||||
return task_server_startup(event_ctx, lp_ctx,
|
||||
model_ops, wreplsrv_task_init);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user