s3-rpc_server: Add create_dcerpc_ncalrpc_socket().
authorAndreas Schneider <asn@samba.org>
Thu, 18 Aug 2011 17:05:10 +0000 (19:05 +0200)
committerSimo Sorce <idra@samba.org>
Sun, 21 Aug 2011 13:05:07 +0000 (09:05 -0400)
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h

index 43f1b3d605ce6eccae5e25d6957d531f3ce57b48..c995e22ea05bb03ba0575dc0864fd8481c1b37e3 100644 (file)
@@ -819,6 +819,32 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
                                    uint16_t flags,
                                    void *private_data);
 
+int create_dcerpc_ncalrpc_socket(const char *name)
+{
+       int fd = -1;
+
+       if (name == NULL) {
+               name = "DEFAULT";
+       }
+
+       if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
+               DEBUG(0, ("Failed to create ncalrpc directory %s - %s\n",
+                         lp_ncalrpc_dir(), strerror(errno)));
+               return -1;
+       }
+
+       fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0755);
+       if (fd == -1) {
+               DEBUG(0, ("Failed to create ncalrpc socket! [%s/%s]\n",
+                         lp_ncalrpc_dir(), name));
+               return -1;
+       }
+
+       DEBUG(10, ("Openened ncalrpc socket fd %d for %s\n", fd, name));
+
+       return fd;
+}
+
 bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
                                 struct messaging_context *msg_ctx,
                                 const char *name,
@@ -839,29 +865,19 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
        if (name == NULL) {
                name = "DEFAULT";
        }
-       state->ep.name = talloc_strdup(state, name);
 
+       state->ep.name = talloc_strdup(state, name);
        if (state->ep.name == NULL) {
                DEBUG(0, ("Out of memory\n"));
                talloc_free(state);
                return false;
        }
 
-       if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
-               DEBUG(0, ("Failed to create pipe directory %s - %s\n",
-                         lp_ncalrpc_dir(), strerror(errno)));
-               goto out;
-       }
-
-       state->fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0755);
+       state->fd = create_dcerpc_ncalrpc_socket(name);
        if (state->fd == -1) {
-               DEBUG(0, ("Failed to create pipe socket! [%s/%s]\n",
-                         lp_ncalrpc_dir(), name));
                goto out;
        }
 
-       DEBUG(10, ("Openened pipe socket fd %d for %s\n", state->fd, name));
-
        state->ev_ctx = ev_ctx;
        state->msg_ctx = msg_ctx;
 
index d29ae1599e5251e0818fffdb51a77b2fe3002d46..5d8ee6a8165f03b50102b6011b060875939129c4 100644 (file)
@@ -43,6 +43,7 @@ uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
                                         const struct sockaddr_storage *ifss,
                                         uint16_t port);
 
+int create_dcerpc_ncalrpc_socket(const char *name);
 bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
                                 struct messaging_context *msg_ctx,
                                 const char *name,