struct rpc_srv_callbacks epmapper_cb;
NTSTATUS status;
pid_t pid;
- bool ok;
int rc;
epmapper_cb.init = NULL;
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);
}
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;
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;
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);
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;
/* 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,
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,
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,