From: Samuel Cabrero Date: Tue, 26 Feb 2019 12:58:43 +0000 (+0100) Subject: s3:rpc_server: Initialize global dcesrv_context for embedded services X-Git-Tag: ldb-2.2.0~1357 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3719de010703ff6deb16b76cd968cee8b6ac1811;p=thirdparty%2Fsamba.git s3:rpc_server: Initialize global dcesrv_context for embedded services Signed-off-by: Samuel Cabrero Reviewed-by: Andrew Bartlett --- diff --git a/source3/rpc_server/rpc_service_setup.c b/source3/rpc_server/rpc_service_setup.c index 0c8ee6bcf78..c2175c4a99d 100644 --- a/source3/rpc_server/rpc_service_setup.c +++ b/source3/rpc_server/rpc_service_setup.c @@ -776,8 +776,10 @@ static NTSTATUS rpc_setup_initshutdown(struct tevent_context *ev_ctx, return NT_STATUS_OK; } -NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx, - struct messaging_context *msg_ctx) +NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + struct dcesrv_context *dce_ctx) { TALLOC_CTX *tmp_ctx; bool ok; @@ -897,6 +899,8 @@ NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx, goto done; } + /* TODO Initialize endpoints for registered endpoint servers */ + status = NT_STATUS_OK; done: talloc_free(tmp_ctx); diff --git a/source3/rpc_server/rpc_service_setup.h b/source3/rpc_server/rpc_service_setup.h index d7bc4be4167..197eca91893 100644 --- a/source3/rpc_server/rpc_service_setup.h +++ b/source3/rpc_server/rpc_service_setup.h @@ -24,9 +24,12 @@ struct ndr_interface_table; struct rpc_srv_callbacks; +struct dcesrv_context; -NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx, - struct messaging_context *msg_ctx); +NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + struct dcesrv_context *dce_ctx); NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 7b26d04ed0f..cbd66e99ac8 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -845,6 +845,7 @@ struct pending_message_list; struct pending_auth_data; struct pthreadpool_tevent; +struct dcesrv_context; struct smbd_server_connection { const struct tsocket_address *local_address; @@ -852,6 +853,7 @@ struct smbd_server_connection { const char *remote_hostname; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; + struct dcesrv_context *dce_ctx; struct notify_context *notify_ctx; bool using_smb2; int trans_num; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 70398b4967e..8ffe3555637 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -3928,6 +3928,7 @@ NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd, void smbd_process(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, + struct dcesrv_context *dce_ctx, int sock_fd, bool interactive) { @@ -3970,6 +3971,7 @@ void smbd_process(struct tevent_context *ev_ctx, sconn->ev_ctx = ev_ctx; sconn->msg_ctx = msg_ctx; + sconn->dce_ctx = dce_ctx; ret = pthreadpool_tevent_init(sconn, lp_aio_max_threads(), &sconn->pool); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 0f773c06225..24d43e455bf 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -49,6 +49,7 @@ /* The following definitions come from smbd/signing.c */ struct smbXsrv_connection; +struct dcesrv_context; bool srv_check_sign_mac(struct smbXsrv_connection *conn, const char *inbuf, uint32_t *seqnum, bool trusted_channel); @@ -883,6 +884,7 @@ bool smb1_parse_chain(TALLOC_CTX *mem_ctx, const uint8_t *buf, bool req_is_in_chain(const struct smb_request *req); void smbd_process(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, + struct dcesrv_context *dce_ctx, int sock_fd, bool interactive); bool fork_echo_handler(struct smbXsrv_connection *xconn); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index caa28e0a772..0ddc9bbd438 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -70,6 +70,7 @@ struct smbd_parent_context { struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; + struct dcesrv_context *dce_ctx; /* the list of listening sockets */ struct smbd_open_socket *sockets; @@ -942,6 +943,7 @@ static void smbd_accept_connection(struct tevent_context *ev, struct smbd_open_socket *s = talloc_get_type_abort(private_data, struct smbd_open_socket); struct messaging_context *msg_ctx = s->parent->msg_ctx; + struct dcesrv_context *dce_ctx = s->parent->dce_ctx; struct sockaddr_storage addr; socklen_t in_addrlen = sizeof(addr); int fd; @@ -960,7 +962,7 @@ static void smbd_accept_connection(struct tevent_context *ev, if (s->parent->interactive) { reinit_after_fork(msg_ctx, ev, true, NULL); - smbd_process(ev, msg_ctx, fd, true); + smbd_process(ev, msg_ctx, dce_ctx, fd, true); exit_server_cleanly("end of interactive mode"); return; } @@ -1009,7 +1011,7 @@ static void smbd_accept_connection(struct tevent_context *ev, smb_panic("reinit_after_fork() failed"); } - smbd_process(ev, msg_ctx, fd, false); + smbd_process(ev, msg_ctx, dce_ctx, fd, false); exit: exit_server_cleanly("end of child"); return; @@ -1627,6 +1629,7 @@ extern void build_options(bool screen); NTSTATUS status; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; + struct dcesrv_context *dce_ctx = NULL; struct server_id server_id; struct tevent_signal *se; int profiling_level; @@ -1830,6 +1833,11 @@ extern void build_options(bool screen); exit(1); } + dce_ctx = global_dcesrv_context(); + if (dce_ctx == NULL) { + exit(1); + } + /* * Reloading of the printers will not work here as we don't have a * server info and rpc services set up. It will be called later. @@ -1925,6 +1933,7 @@ extern void build_options(bool screen); parent->interactive = interactive; parent->ev_ctx = ev_ctx; parent->msg_ctx = msg_ctx; + parent->dce_ctx = dce_ctx; am_parent = parent; se = tevent_add_signal(parent->ev_ctx, @@ -2087,7 +2096,7 @@ extern void build_options(bool screen); } } - status = dcesrv_ep_setup(ev_ctx, msg_ctx); + status = dcesrv_init(ev_ctx, ev_ctx, msg_ctx, dce_ctx); if (!NT_STATUS_IS_OK(status)) { DBG_ERR("Failed to setup RPC server: %s\n", nt_errstr(status)); exit_daemon("Samba cannot setup ep pipe", EACCES); @@ -2153,7 +2162,7 @@ extern void build_options(bool screen); /* Stop zombies */ smbd_setup_sig_chld_handler(parent); - smbd_process(ev_ctx, msg_ctx, sock, true); + smbd_process(ev_ctx, msg_ctx, dce_ctx, sock, true); exit_server_cleanly(NULL); return(0); diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c index d51b73d5131..effe818a14d 100644 --- a/source3/smbd/server_exit.c +++ b/source3/smbd/server_exit.c @@ -51,6 +51,7 @@ #include "smbprofile.h" #include "libcli/auth/netlogon_creds_cli.h" #include "lib/gencache.h" +#include "rpc_server/rpc_config.h" static struct files_struct *log_writeable_file_fn( struct files_struct *fsp, void *private_data) @@ -217,6 +218,8 @@ static void exit_server_common(enum server_exit_reason how, rpc_FileServerVssAgent_shutdown(); rpc_epmapper_shutdown(); + + global_dcesrv_context_free(); } /*