diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c index 1cc51862dc2..0ef4742f807 100644 --- a/source3/rpc_server/epmd.c +++ b/source3/rpc_server/epmd.c @@ -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); } diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index 36c2c717696..de599beb69e 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -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, diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h index 97a53e7403f..ca0f61ce4e6 100644 --- a/source3/rpc_server/rpc_server.h +++ b/source3/rpc_server/rpc_server.h @@ -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,