mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
s3-rpc: Expose some internal functions
This will allow to hook the prefork socket handlers to the rpc service. Signed-off-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
2056d06cae
commit
d67fc9c1eb
@ -160,28 +160,10 @@ static void named_pipe_listener(struct tevent_context *ev,
|
|||||||
uint16_t flags,
|
uint16_t flags,
|
||||||
void *private_data);
|
void *private_data);
|
||||||
|
|
||||||
bool setup_named_pipe_socket(const char *pipe_name,
|
int create_named_pipe_socket(const char *pipe_name)
|
||||||
struct tevent_context *ev_ctx,
|
|
||||||
struct messaging_context *msg_ctx)
|
|
||||||
{
|
{
|
||||||
struct dcerpc_ncacn_listen_state *state;
|
char *np_dir = NULL;
|
||||||
struct tevent_fd *fde;
|
int fd = -1;
|
||||||
char *np_dir;
|
|
||||||
|
|
||||||
state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state);
|
|
||||||
if (!state) {
|
|
||||||
DEBUG(0, ("Out of memory\n"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
state->ep.name = talloc_strdup(state, pipe_name);
|
|
||||||
if (state->ep.name == NULL) {
|
|
||||||
DEBUG(0, ("Out of memory\n"));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
state->fd = -1;
|
|
||||||
|
|
||||||
state->ev_ctx = ev_ctx;
|
|
||||||
state->msg_ctx = msg_ctx;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As lp_ncalrpc_dir() should have 0755, but
|
* As lp_ncalrpc_dir() should have 0755, but
|
||||||
@ -194,7 +176,7 @@ bool setup_named_pipe_socket(const char *pipe_name,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
np_dir = talloc_asprintf(state, "%s/np", lp_ncalrpc_dir());
|
np_dir = talloc_asprintf(talloc_tos(), "%s/np", lp_ncalrpc_dir());
|
||||||
if (!np_dir) {
|
if (!np_dir) {
|
||||||
DEBUG(0, ("Out of memory\n"));
|
DEBUG(0, ("Out of memory\n"));
|
||||||
goto out;
|
goto out;
|
||||||
@ -206,13 +188,44 @@ bool setup_named_pipe_socket(const char *pipe_name,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->fd = create_pipe_sock(np_dir, pipe_name, 0700);
|
fd = create_pipe_sock(np_dir, pipe_name, 0700);
|
||||||
if (state->fd == -1) {
|
if (fd == -1) {
|
||||||
DEBUG(0, ("Failed to create pipe socket! [%s/%s]\n",
|
DEBUG(0, ("Failed to create pipe socket! [%s/%s]\n",
|
||||||
np_dir, pipe_name));
|
np_dir, pipe_name));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG(10, ("Openened pipe socket fd %d for %s\n", fd, pipe_name));
|
||||||
|
|
||||||
|
out:
|
||||||
talloc_free(np_dir);
|
talloc_free(np_dir);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setup_named_pipe_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;
|
||||||
|
|
||||||
|
state = talloc(ev_ctx, struct dcerpc_ncacn_listen_state);
|
||||||
|
if (!state) {
|
||||||
|
DEBUG(0, ("Out of memory\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
state->ep.name = talloc_strdup(state, pipe_name);
|
||||||
|
if (state->ep.name == NULL) {
|
||||||
|
DEBUG(0, ("Out of memory\n"));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
state->fd = create_named_pipe_socket(pipe_name);
|
||||||
|
if (state->fd == -1) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
state->ev_ctx = ev_ctx;
|
||||||
|
state->msg_ctx = msg_ctx;
|
||||||
|
|
||||||
DEBUG(10, ("Openened pipe socket fd %d for %s\n",
|
DEBUG(10, ("Openened pipe socket fd %d for %s\n",
|
||||||
state->fd, pipe_name));
|
state->fd, pipe_name));
|
||||||
@ -236,11 +249,6 @@ out:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void named_pipe_accept_function(struct tevent_context *ev_ctx,
|
|
||||||
struct messaging_context *msg_ctx,
|
|
||||||
const char *pipe_name,
|
|
||||||
int fd);
|
|
||||||
|
|
||||||
static void named_pipe_listener(struct tevent_context *ev,
|
static void named_pipe_listener(struct tevent_context *ev,
|
||||||
struct tevent_fd *fde,
|
struct tevent_fd *fde,
|
||||||
uint16_t flags,
|
uint16_t flags,
|
||||||
@ -310,10 +318,9 @@ struct named_pipe_client {
|
|||||||
|
|
||||||
static void named_pipe_accept_done(struct tevent_req *subreq);
|
static void named_pipe_accept_done(struct tevent_req *subreq);
|
||||||
|
|
||||||
static void named_pipe_accept_function(struct tevent_context *ev_ctx,
|
void named_pipe_accept_function(struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
const char *pipe_name,
|
const char *pipe_name, int fd)
|
||||||
int fd)
|
|
||||||
{
|
{
|
||||||
struct named_pipe_client *npc;
|
struct named_pipe_client *npc;
|
||||||
struct tstream_context *plain;
|
struct tstream_context *plain;
|
||||||
|
@ -26,9 +26,13 @@ typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p);
|
|||||||
|
|
||||||
void set_incoming_fault(struct pipes_struct *p);
|
void set_incoming_fault(struct pipes_struct *p);
|
||||||
void process_complete_pdu(struct pipes_struct *p);
|
void process_complete_pdu(struct pipes_struct *p);
|
||||||
|
int create_named_pipe_socket(const char *pipe_name);
|
||||||
bool setup_named_pipe_socket(const char *pipe_name,
|
bool setup_named_pipe_socket(const char *pipe_name,
|
||||||
struct tevent_context *ev_ctx,
|
struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_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);
|
||||||
|
|
||||||
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
|
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user