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:
parent
1a1f31e082
commit
5a54486424
@ -135,7 +135,6 @@ void start_epmd(struct tevent_context *ev_ctx,
|
|||||||
struct rpc_srv_callbacks epmapper_cb;
|
struct rpc_srv_callbacks epmapper_cb;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
bool ok;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
epmapper_cb.init = NULL;
|
epmapper_cb.init = NULL;
|
||||||
@ -190,11 +189,11 @@ void start_epmd(struct tevent_context *ev_ctx,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = dcesrv_setup_ncalrpc_socket(ev_ctx,
|
status = dcesrv_setup_ncalrpc_socket(ev_ctx,
|
||||||
msg_ctx,
|
msg_ctx,
|
||||||
"EPMAPPER",
|
"EPMAPPER",
|
||||||
srv_epmapper_delete_endpoints);
|
srv_epmapper_delete_endpoints);
|
||||||
if (!ok) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n"));
|
DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -836,10 +836,10 @@ out:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
dcerpc_ncacn_disconnect_fn fn)
|
dcerpc_ncacn_disconnect_fn fn)
|
||||||
{
|
{
|
||||||
struct dcerpc_ncacn_listen_state *state;
|
struct dcerpc_ncacn_listen_state *state;
|
||||||
struct tevent_fd *fde;
|
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);
|
state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state);
|
||||||
if (state == NULL) {
|
if (state == NULL) {
|
||||||
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;
|
||||||
@ -863,7 +863,7 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
|||||||
if (state->ep.name == NULL) {
|
if (state->ep.name == NULL) {
|
||||||
DEBUG(0, ("Out of memory\n"));
|
DEBUG(0, ("Out of memory\n"));
|
||||||
talloc_free(state);
|
talloc_free(state);
|
||||||
return false;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = dcesrv_create_ncalrpc_socket(name, &state->fd);
|
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);
|
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 ncalrpc socket %s: %s\n",
|
DEBUG(0, ("Failed to listen on ncalrpc socket %s: %s\n",
|
||||||
name, strerror(errno)));
|
name, strerror(errno)));
|
||||||
goto out;
|
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 server socket to non-blocking for the accept. */
|
||||||
set_blocking(state->fd, false);
|
set_blocking(state->fd, false);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
fde = tevent_add_fd(state->ev_ctx,
|
fde = tevent_add_fd(state->ev_ctx,
|
||||||
state,
|
state,
|
||||||
state->fd,
|
state->fd,
|
||||||
@ -893,20 +895,24 @@ bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
|||||||
dcesrv_ncalrpc_listener,
|
dcesrv_ncalrpc_listener,
|
||||||
state);
|
state);
|
||||||
if (fde == NULL) {
|
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"));
|
DEBUG(0, ("Failed to add event handler for ncalrpc!\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 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dcesrv_ncalrpc_listener(struct tevent_context *ev,
|
static void dcesrv_ncalrpc_listener(struct tevent_context *ev,
|
||||||
|
@ -99,10 +99,10 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_socket(struct tevent_context *ev_ctx,
|
|||||||
uint16_t *port);
|
uint16_t *port);
|
||||||
|
|
||||||
NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd);
|
NTSTATUS dcesrv_create_ncalrpc_socket(const char *name, int *out_fd);
|
||||||
bool dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
NTSTATUS dcesrv_setup_ncalrpc_socket(struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
dcerpc_ncacn_disconnect_fn fn);
|
dcerpc_ncacn_disconnect_fn fn);
|
||||||
|
|
||||||
void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
|
void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user