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:
parent
b6537c15c1
commit
e05ce7b9e7
@ -199,8 +199,8 @@ void start_epmd(struct tevent_context *ev_ctx,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ok = dcesrv_setup_ncacn_np_socket("epmapper", ev_ctx, msg_ctx);
|
||||
if (!ok) {
|
||||
status = dcesrv_setup_ncacn_np_socket("epmapper", ev_ctx, msg_ctx);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to open epmd named pipe!\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -148,7 +148,6 @@ void start_fssd(struct tevent_context *ev_ctx,
|
||||
struct rpc_srv_callbacks fss_cb;
|
||||
NTSTATUS status;
|
||||
pid_t pid;
|
||||
bool ok;
|
||||
int rc;
|
||||
|
||||
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 */
|
||||
ok = dcesrv_setup_ncacn_np_socket("fssagentrpc", ev_ctx, msg_ctx);
|
||||
if (!ok) {
|
||||
status = dcesrv_setup_ncacn_np_socket("fssagentrpc", ev_ctx, msg_ctx);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to open fssd named pipe!\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ out:
|
||||
return status;
|
||||
}
|
||||
|
||||
bool dcesrv_setup_ncacn_np_socket(const char *pipe_name,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx)
|
||||
NTSTATUS dcesrv_setup_ncacn_np_socket(const char *pipe_name,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx)
|
||||
{
|
||||
struct dcerpc_ncacn_listen_state *state;
|
||||
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);
|
||||
if (!state) {
|
||||
DEBUG(0, ("Out of memory\n"));
|
||||
return false;
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
state->fd = -1;
|
||||
state->ep.name = talloc_strdup(state, pipe_name);
|
||||
if (state->ep.name == NULL) {
|
||||
DEBUG(0, ("Out of memory\n"));
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
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);
|
||||
if (rc < 0) {
|
||||
status = map_nt_error_from_unix_common(errno);
|
||||
DEBUG(0, ("Failed to listen on pipe socket %s: %s\n",
|
||||
pipe_name, strerror(errno)));
|
||||
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",
|
||||
state->fd, pipe_name));
|
||||
|
||||
errno = 0;
|
||||
fde = tevent_add_fd(ev_ctx,
|
||||
state, state->fd, TEVENT_FD_READ,
|
||||
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"));
|
||||
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 false;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void named_pipe_listener(struct tevent_context *ev,
|
||||
|
@ -80,9 +80,9 @@ int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
|
||||
void set_incoming_fault(struct pipes_struct *p);
|
||||
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);
|
||||
bool dcesrv_setup_ncacn_np_socket(const char *pipe_name,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx);
|
||||
NTSTATUS dcesrv_setup_ncacn_np_socket(const char *pipe_name,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx);
|
||||
void named_pipe_accept_function(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const char *pipe_name, int fd,
|
||||
|
Loading…
Reference in New Issue
Block a user