mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
s3:rpc_server: Create ncalrpc socket through endpoint initialization
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
1d970fa83d
commit
f8eb0e3569
@ -664,22 +664,6 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx,
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
status = dcesrv_create_ncalrpc_socket("lsarpc", &fd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
rc = listen(fd, pf_lsasd_cfg.max_allowed_clients);
|
||||
if (rc == -1) {
|
||||
DEBUG(0, ("Failed to listen on lsarpc ncalrpc - %s\n",
|
||||
strerror(errno)));
|
||||
goto done;
|
||||
}
|
||||
listen_fd[*listen_fd_size].fd = fd;
|
||||
listen_fd[*listen_fd_size].fd_data = NULL;
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
|
||||
if (v == NULL) {
|
||||
goto done;
|
||||
@ -722,22 +706,6 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx,
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
status = dcesrv_create_ncalrpc_socket("samr", &fd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
rc = listen(fd, pf_lsasd_cfg.max_allowed_clients);
|
||||
if (rc == -1) {
|
||||
DEBUG(0, ("Failed to listen on samr ncalrpc - %s\n",
|
||||
strerror(errno)));
|
||||
goto done;
|
||||
}
|
||||
listen_fd[*listen_fd_size].fd = fd;
|
||||
listen_fd[*listen_fd_size].fd_data = NULL;
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
|
||||
if (v == NULL) {
|
||||
goto done;
|
||||
@ -780,22 +748,6 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx,
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
status = dcesrv_create_ncalrpc_socket("netlogon", &fd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
rc = listen(fd, pf_lsasd_cfg.max_allowed_clients);
|
||||
if (rc == -1) {
|
||||
DEBUG(0, ("Failed to listen on netlogon ncalrpc - %s\n",
|
||||
strerror(errno)));
|
||||
goto done;
|
||||
}
|
||||
listen_fd[*listen_fd_size].fd = fd;
|
||||
listen_fd[*listen_fd_size].fd_data = NULL;
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
|
||||
if (v == NULL) {
|
||||
goto done;
|
||||
|
@ -593,20 +593,6 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx,
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
status = dcesrv_create_ncalrpc_socket("mdssvc", &fd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
rc = listen(fd, pf_mdssd_cfg.max_allowed_clients);
|
||||
if (rc == -1) {
|
||||
goto done;
|
||||
}
|
||||
listen_fd[*listen_fd_size].fd = fd;
|
||||
listen_fd[*listen_fd_size].fd_data = NULL;
|
||||
(*listen_fd_size)++;
|
||||
fd = -1;
|
||||
|
||||
v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
|
||||
if (v == NULL) {
|
||||
goto done;
|
||||
|
@ -476,13 +476,31 @@ static void dcesrv_ncalrpc_listener(struct tevent_context *ev,
|
||||
uint16_t flags,
|
||||
void *private_data);
|
||||
|
||||
NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd)
|
||||
NTSTATUS dcesrv_create_ncalrpc_socket(struct dcesrv_endpoint *e, int *out_fd)
|
||||
{
|
||||
int fd = -1;
|
||||
const char *endpoint = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
if (name == NULL) {
|
||||
name = "DEFAULT";
|
||||
endpoint = dcerpc_binding_get_string_option(e->ep_description,
|
||||
"endpoint");
|
||||
if (endpoint == NULL) {
|
||||
/*
|
||||
* No identifier specified: use DEFAULT.
|
||||
*
|
||||
* TODO: DO NOT hardcode this value anywhere else. Rather,
|
||||
* specify no endpoint and let the epmapper worry about it.
|
||||
*/
|
||||
endpoint = "DEFAULT";
|
||||
status = dcerpc_binding_set_string_option(e->ep_description,
|
||||
"endpoint",
|
||||
endpoint);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_ERR("Failed to set ncalrpc 'endpoint' binding "
|
||||
"string option to '%s': %s\n",
|
||||
endpoint, nt_errstr(status));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (!directory_create_or_exist(lp_ncalrpc_dir(), 0755)) {
|
||||
@ -492,16 +510,16 @@ NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd)
|
||||
goto out;
|
||||
}
|
||||
|
||||
fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0755);
|
||||
fd = create_pipe_sock(lp_ncalrpc_dir(), endpoint, 0755);
|
||||
if (fd == -1) {
|
||||
status = map_nt_error_from_unix_common(errno);
|
||||
DBG_ERR("Failed to create ncalrpc socket '%s/%s': %s\n",
|
||||
lp_ncalrpc_dir(), name, strerror(errno));
|
||||
lp_ncalrpc_dir(), endpoint, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
DBG_DEBUG("Opened ncalrpc socket fd '%d' for '%s/%s'\n",
|
||||
fd, lp_ncalrpc_dir(), name);
|
||||
fd, lp_ncalrpc_dir(), endpoint);
|
||||
|
||||
*out_fd = fd;
|
||||
|
||||
@ -522,7 +540,6 @@ NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||
struct tevent_fd *fde;
|
||||
int rc;
|
||||
NTSTATUS status;
|
||||
const char *endpoint = NULL;
|
||||
|
||||
/* Alloc in endpoint context. If the endpoint is freed (for example
|
||||
* when forked daemons reinit the dcesrv_context, the tevent_fd
|
||||
@ -541,28 +558,7 @@ NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||
state->termination_fn = term_fn;
|
||||
state->termination_data = termination_data;
|
||||
|
||||
endpoint = dcerpc_binding_get_string_option(e->ep_description,
|
||||
"endpoint");
|
||||
if (endpoint == NULL) {
|
||||
/*
|
||||
* No identifier specified: use DEFAULT.
|
||||
*
|
||||
* TODO: DO NOT hardcode this value anywhere else. Rather,
|
||||
* specify no endpoint and let the epmapper worry about it.
|
||||
*/
|
||||
endpoint = "DEFAULT";
|
||||
status = dcerpc_binding_set_string_option(e->ep_description,
|
||||
"endpoint",
|
||||
endpoint);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_ERR("Failed to set ncalrpc 'endpoint' binding "
|
||||
"string option to '%s': %s\n",
|
||||
endpoint, nt_errstr(status));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
status = dcesrv_create_ncalrpc_socket(endpoint, &state->fd);
|
||||
status = dcesrv_create_ncalrpc_socket(e, &state->fd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_ERR("Failed to create ncalrpc socket: %s\n",
|
||||
nt_errstr(status));
|
||||
@ -571,6 +567,8 @@ NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||
|
||||
rc = listen(state->fd, 5);
|
||||
if (rc < 0) {
|
||||
const char *endpoint = dcerpc_binding_get_string_option(
|
||||
e->ep_description, "endpoint");
|
||||
status = map_nt_error_from_unix_common(errno);
|
||||
DBG_ERR("Failed to listen on ncalrpc socket %s: %s\n",
|
||||
endpoint, strerror(errno));
|
||||
|
@ -93,7 +93,7 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_socket(struct tevent_context *ev_ctx,
|
||||
dcerpc_ncacn_termination_fn term_fn,
|
||||
void *term_data);
|
||||
|
||||
NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd);
|
||||
NTSTATUS dcesrv_create_ncalrpc_socket(struct dcesrv_endpoint *e, int *fd);
|
||||
NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
struct dcesrv_context *dce_ctx,
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "rpc_server/spoolss/srv_spoolss_nt.h"
|
||||
#include "rpc_server/svcctl/srv_svcctl_nt.h"
|
||||
|
||||
#include "lib/server_prefork.h"
|
||||
#include "librpc/rpc/dcesrv_core.h"
|
||||
#include "librpc/rpc/dcerpc_ep.h"
|
||||
#include "rpc_server/rpc_sock_helper.h"
|
||||
@ -127,6 +128,7 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
dcerpc_binding_get_transport(e->ep_description);
|
||||
char *binding = NULL;
|
||||
NTSTATUS status;
|
||||
int out_fd;
|
||||
|
||||
binding = dcerpc_binding_string(dce_ctx, e->ep_description);
|
||||
if (binding == NULL) {
|
||||
@ -137,8 +139,12 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
|
||||
switch (transport) {
|
||||
case NCALRPC:
|
||||
/* TODO */
|
||||
status = NT_STATUS_OK;
|
||||
status = dcesrv_create_ncalrpc_socket(e, &out_fd);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
listen_fds[*listen_fds_size].fd = out_fd;
|
||||
listen_fds[*listen_fds_size].fd_data = e;
|
||||
(*listen_fds_size)++;
|
||||
}
|
||||
break;
|
||||
|
||||
case NCACN_IP_TCP:
|
||||
|
Loading…
x
Reference in New Issue
Block a user