summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-05-20 09:16:29 -0400
committerAndreas Schneider <asn@samba.org>2010-09-15 12:53:41 +0200
commitb1fdc5a70457979d8aea6574ae135d83efd7628a (patch)
tree37b02a8de66af475b962ea1d4b8f14e2b40eaaa7
parent3c26e95840454f8a311df037d90663abbda5854c (diff)
downloadsamba-b1fdc5a70457979d8aea6574ae135d83efd7628a.tar.gz
samba-b1fdc5a70457979d8aea6574ae135d83efd7628a.tar.bz2
samba-b1fdc5a70457979d8aea6574ae135d83efd7628a.zip
s3-rpc_server: Add generic listener callback.
Signed-off-by: Andreas Schneider <asn@cynapses.org>
-rw-r--r--source3/rpc_server/rpc_server.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index 047f128217..923e897689 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -22,15 +22,13 @@
struct named_pipe_listen_state {
int fd;
+ char *name;
};
static void named_pipe_listener(struct tevent_context *ev,
struct tevent_fd *fde,
uint16_t flags,
- void *private_data)
-{
- return;
-}
+ void *private_data);
bool setup_named_pipe_socket(const char *pipe_name,
struct tevent_context *ev_ctx)
@@ -44,6 +42,11 @@ bool setup_named_pipe_socket(const char *pipe_name,
DEBUG(0, ("Out of memory\n"));
return false;
}
+ state->name = talloc_strdup(state, pipe_name);
+ if (!state->name) {
+ DEBUG(0, ("Out of memory\n"));
+ goto out;
+ }
state->fd = -1;
np_dir = talloc_asprintf(state, "%s/np", lp_ncalrpc_dir());
@@ -86,3 +89,43 @@ out:
TALLOC_FREE(state);
return false;
}
+
+static void named_pipe_accept_function(const char *pipe_name, int fd);
+
+static void named_pipe_listener(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags,
+ void *private_data)
+{
+ struct named_pipe_listen_state *state =
+ talloc_get_type_abort(private_data,
+ struct named_pipe_listen_state);
+ struct sockaddr_un sunaddr;
+ socklen_t len;
+ int sd = -1;
+
+ /* TODO: should we have a limit to the number of clients ? */
+
+ len = sizeof(sunaddr);
+
+ while (sd == -1) {
+ sd = accept(state->fd,
+ (struct sockaddr *)(void *)&sunaddr, &len);
+ if (errno != EINTR) break;
+ }
+
+ if (sd == -1) {
+ DEBUG(6, ("Failed to get a valid socket [%s]\n",
+ strerror(errno)));
+ return;
+ }
+
+ DEBUG(6, ("Accepted socket %d\n", sd));
+
+ named_pipe_accept_function(state->name, sd);
+}
+
+static void named_pipe_accept_function(const char *pipe_name, int fd)
+{
+ return;
+}