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_ncalrpc_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 17:00:30 +02:00 committed by Stefan Metzmacher
parent 1a1f31e082
commit 5a54486424
3 changed files with 23 additions and 18 deletions

View File

@ -135,7 +135,6 @@ void start_epmd(struct tevent_context *ev_ctx,
struct rpc_srv_callbacks epmapper_cb;
NTSTATUS status;
pid_t pid;
bool ok;
int rc;
epmapper_cb.init = NULL;
@ -190,11 +189,11 @@ void start_epmd(struct tevent_context *ev_ctx,
exit(1);
}
ok = dcesrv_setup_ncalrpc_socket(ev_ctx,
msg_ctx,
"EPMAPPER",
srv_epmapper_delete_endpoints);
if (!ok) {
status = dcesrv_setup_ncalrpc_socket(ev_ctx,
msg_ctx,
"EPMAPPER",
srv_epmapper_delete_endpoints);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n"));
exit(1);
}

View File

@ -836,10 +836,10 @@ out:
return status;
}
bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const char *name,
dcerpc_ncacn_disconnect_fn fn)
NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const char *name,
dcerpc_ncacn_disconnect_fn fn)
{
struct dcerpc_ncacn_listen_state *state;
struct tevent_fd *fde;
@ -849,7 +849,7 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state);
if (state == NULL) {
DEBUG(0, ("Out of memory\n"));
return false;
return NT_STATUS_NO_MEMORY;
}
state->fd = -1;
@ -863,7 +863,7 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
if (state->ep.name == NULL) {
DEBUG(0, ("Out of memory\n"));
talloc_free(state);
return false;
return NT_STATUS_NO_MEMORY;
}
status = dcesrv_create_ncalrpc_socket(name, &state->fd);
@ -875,6 +875,7 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
rc = listen(state->fd, 5);
if (rc < 0) {
status = map_nt_error_from_unix_common(errno);
DEBUG(0, ("Failed to listen on ncalrpc socket %s: %s\n",
name, strerror(errno)));
goto out;
@ -886,6 +887,7 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
/* Set server socket to non-blocking for the accept. */
set_blocking(state->fd, false);
errno = 0;
fde = tevent_add_fd(state->ev_ctx,
state,
state->fd,
@ -893,20 +895,24 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
dcesrv_ncalrpc_listener,
state);
if (fde == NULL) {
if (errno == 0) {
errno = ENOMEM;
}
status = map_nt_error_from_unix_common(errno);
DEBUG(0, ("Failed to add event handler for ncalrpc!\n"));
goto out;
}
tevent_fd_set_auto_close(fde);
return true;
return NT_STATUS_OK;
out:
if (state->fd != -1) {
close(state->fd);
}
TALLOC_FREE(state);
return 0;
return status;
}
static void dcesrv_ncalrpc_listener(struct tevent_context *ev,

View File

@ -99,10 +99,10 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_socket(struct tevent_context *ev_ctx,
uint16_t *port);
NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd);
bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const char *name,
dcerpc_ncacn_disconnect_fn fn);
NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const char *name,
dcerpc_ncacn_disconnect_fn fn);
void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,