*/
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);
}
*/
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);
}
/*
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),
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),
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 */
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);
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);
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);
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);
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);
}
*/
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);
}
}
struct rap_call {
+ struct loadparm_context *lp_ctx;
+
TALLOC_CTX *mem_ctx;
uint16_t callno;
const char *paramdesc;
#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;
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);
break;
}
- result = rap_netshareenum(call, &r);
+ result = rap_netshareenum(call, call->lp_ctx, &r);
if (!NT_STATUS_IS_OK(result))
return result;
break;
}
- result = rap_netserverenum2(call, &r);
+ result = rap_netserverenum2(call, call->lp_ctx, &r);
if (!NT_STATUS_IS_OK(result))
return result;
{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;
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;
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;
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;
* idea. */
NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct rap_NetShareEnum *r)
{
NTSTATUS nterr;
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;
}
}
NTSTATUS rap_netserverenum2(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct rap_NetServerEnum2 *r)
{
r->out.status = 0;
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;
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;
}
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);
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);
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);
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)
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);
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);
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 */
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 */
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)
{
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);
}
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)
{
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
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;
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
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;
};
{
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);
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)
{
state->new_conn = new_conn;
state->private = private;
+ state->lp_ctx = lp_ctx;
state->ev = ev2;
/* accept an incoming connection. */
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;
};
{
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);
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;
}
state->new_task = new_task;
+ state->lp_ctx = lp_ctx;
state->private = private;
state->ev = ev2;
*/
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;
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)
{
/* 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");
/* 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);
}
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,
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);
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);
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),
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 *))
{
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;
}
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;
}
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),
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;
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 */
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),
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),
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);
}
/*
*/
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);
}
} 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)) {
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);
}
/*