1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:rpc_server: Return NTSTATUS for dcesrv_setup_ncacn_np_socket

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Samuel Cabrero 2019-06-04 15:46:03 +02:00 committed by Stefan Metzmacher
parent b6537c15c1
commit e05ce7b9e7
4 changed files with 21 additions and 15 deletions

View File

@ -199,8 +199,8 @@ void start_epmd(struct tevent_context *ev_ctx,
exit(1); exit(1);
} }
ok = dcesrv_setup_ncacn_np_socket("epmapper", ev_ctx, msg_ctx); status = dcesrv_setup_ncacn_np_socket("epmapper", ev_ctx, msg_ctx);
if (!ok) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to open epmd named pipe!\n")); DEBUG(0, ("Failed to open epmd named pipe!\n"));
exit(1); exit(1);
} }

View File

@ -148,7 +148,6 @@ void start_fssd(struct tevent_context *ev_ctx,
struct rpc_srv_callbacks fss_cb; struct rpc_srv_callbacks fss_cb;
NTSTATUS status; NTSTATUS status;
pid_t pid; pid_t pid;
bool ok;
int rc; int rc;
fss_cb.init = fss_init_cb; fss_cb.init = fss_init_cb;
@ -195,8 +194,8 @@ void start_fssd(struct tevent_context *ev_ctx,
} }
/* case is normalized by smbd on connection */ /* case is normalized by smbd on connection */
ok = dcesrv_setup_ncacn_np_socket("fssagentrpc", ev_ctx, msg_ctx); status = dcesrv_setup_ncacn_np_socket("fssagentrpc", ev_ctx, msg_ctx);
if (!ok) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to open fssd named pipe!\n")); DEBUG(0, ("Failed to open fssd named pipe!\n"));
exit(1); exit(1);
} }

View File

@ -147,9 +147,9 @@ out:
return status; return status;
} }
bool dcesrv_setup_ncacn_np_socket(const char *pipe_name, NTSTATUS dcesrv_setup_ncacn_np_socket(const char *pipe_name,
struct tevent_context *ev_ctx, struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx) struct messaging_context *msg_ctx)
{ {
struct dcerpc_ncacn_listen_state *state; struct dcerpc_ncacn_listen_state *state;
struct tevent_fd *fde; struct tevent_fd *fde;
@ -159,12 +159,13 @@ bool dcesrv_setup_ncacn_np_socket(const char *pipe_name,
state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state); state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state);
if (!state) { if (!state) {
DEBUG(0, ("Out of memory\n")); DEBUG(0, ("Out of memory\n"));
return false; return NT_STATUS_NO_MEMORY;
} }
state->fd = -1; state->fd = -1;
state->ep.name = talloc_strdup(state, pipe_name); state->ep.name = talloc_strdup(state, pipe_name);
if (state->ep.name == NULL) { if (state->ep.name == NULL) {
DEBUG(0, ("Out of memory\n")); DEBUG(0, ("Out of memory\n"));
status = NT_STATUS_NO_MEMORY;
goto out; goto out;
} }
status = dcesrv_create_ncacn_np_socket(pipe_name, &state->fd); status = dcesrv_create_ncacn_np_socket(pipe_name, &state->fd);
@ -174,6 +175,7 @@ bool dcesrv_setup_ncacn_np_socket(const char *pipe_name,
rc = listen(state->fd, 5); rc = listen(state->fd, 5);
if (rc < 0) { if (rc < 0) {
status = map_nt_error_from_unix_common(errno);
DEBUG(0, ("Failed to listen on pipe socket %s: %s\n", DEBUG(0, ("Failed to listen on pipe socket %s: %s\n",
pipe_name, strerror(errno))); pipe_name, strerror(errno)));
goto out; goto out;
@ -185,23 +187,28 @@ bool dcesrv_setup_ncacn_np_socket(const char *pipe_name,
DEBUG(10, ("Opened pipe socket fd %d for %s\n", DEBUG(10, ("Opened pipe socket fd %d for %s\n",
state->fd, pipe_name)); state->fd, pipe_name));
errno = 0;
fde = tevent_add_fd(ev_ctx, fde = tevent_add_fd(ev_ctx,
state, state->fd, TEVENT_FD_READ, state, state->fd, TEVENT_FD_READ,
named_pipe_listener, state); named_pipe_listener, state);
if (!fde) { if (fde == NULL) {
if (errno == 0) {
errno = ENOMEM;
}
status = map_nt_error_from_unix_common(errno);
DEBUG(0, ("Failed to add event handler!\n")); DEBUG(0, ("Failed to add event handler!\n"));
goto out; goto out;
} }
tevent_fd_set_auto_close(fde); tevent_fd_set_auto_close(fde);
return true; return NT_STATUS_OK;
out: out:
if (state->fd != -1) { if (state->fd != -1) {
close(state->fd); close(state->fd);
} }
TALLOC_FREE(state); TALLOC_FREE(state);
return false; return status;
} }
static void named_pipe_listener(struct tevent_context *ev, static void named_pipe_listener(struct tevent_context *ev,

View File

@ -80,9 +80,9 @@ int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
void set_incoming_fault(struct pipes_struct *p); void set_incoming_fault(struct pipes_struct *p);
void process_complete_pdu(struct pipes_struct *p, struct ncacn_packet *pkt); void process_complete_pdu(struct pipes_struct *p, struct ncacn_packet *pkt);
NTSTATUS dcesrv_create_ncacn_np_socket(const char *pipe_name, int *out_fd); NTSTATUS dcesrv_create_ncacn_np_socket(const char *pipe_name, int *out_fd);
bool dcesrv_setup_ncacn_np_socket(const char *pipe_name, NTSTATUS dcesrv_setup_ncacn_np_socket(const char *pipe_name,
struct tevent_context *ev_ctx, struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx); struct messaging_context *msg_ctx);
void named_pipe_accept_function(struct tevent_context *ev_ctx, void named_pipe_accept_function(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx, struct messaging_context *msg_ctx,
const char *pipe_name, int fd, const char *pipe_name, int fd,