s3-rpc_server: Refactor lsasd_create_sockets().
authorAndreas Schneider <asn@samba.org>
Mon, 21 Oct 2013 06:26:47 +0000 (08:26 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 21 Oct 2013 10:49:44 +0000 (12:49 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Oct 21 12:49:44 CEST 2013 on sn-devel-104

source3/rpc_server/lsasd.c

index 0a7e4ff312fec48b70c3f1e8542ccd08936cb247..375f4097c584ccc3ac2029b584da4f3f564317b9 100644 (file)
@@ -604,7 +604,7 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        uint32_t i;
        int fd = -1;
        int rc;
-       bool ok = true;
+       bool ok = false;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
@@ -613,7 +613,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        status = dcerpc_binding_vector_new(tmp_ctx, &v_orig);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
@@ -624,7 +623,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
                                          listen_fd,
                                          listen_fd_size);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
@@ -634,7 +632,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
                if (rc == -1) {
                        DEBUG(0, ("Failed to listen on tcpip socket - %s\n",
                                  strerror(errno)));
-                       ok = false;
                        goto done;
                }
        }
@@ -642,7 +639,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        /* LSARPC */
        fd = create_named_pipe_socket("lsarpc");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -650,7 +646,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on lsarpc pipe - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -658,7 +653,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        fd = create_named_pipe_socket("lsass");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -666,7 +660,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on lsass pipe - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -674,7 +667,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        fd = create_dcerpc_ncalrpc_socket("lsarpc");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -682,7 +674,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on lsarpc ncalrpc - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -691,37 +682,32 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
        if (v == NULL) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_replace_iface(&ndr_table_lsarpc, v);
        if (!NT_STATUS_IS_OK(status)) {
-               return false;
+               goto done;
        }
 
        status = dcerpc_binding_vector_add_np_default(&ndr_table_lsarpc, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "lsarpc");
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_lsarpc, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        /* SAMR */
        fd = create_named_pipe_socket("samr");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -729,7 +715,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on samr pipe - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -737,7 +722,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        fd = create_dcerpc_ncalrpc_socket("samr");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -745,7 +729,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on samr ncalrpc - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -754,37 +737,32 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
        if (v == NULL) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_replace_iface(&ndr_table_samr, v);
        if (!NT_STATUS_IS_OK(status)) {
-               return false;
+               goto done;
        }
 
        status = dcerpc_binding_vector_add_np_default(&ndr_table_samr, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "samr");
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_samr, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        /* NETLOGON */
        fd = create_named_pipe_socket("netlogon");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -792,7 +770,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on samr pipe - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -800,7 +777,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        fd = create_dcerpc_ncalrpc_socket("netlogon");
        if (fd < 0) {
-               ok = false;
                goto done;
        }
 
@@ -808,7 +784,6 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
        if (rc == -1) {
                DEBUG(0, ("Failed to listen on netlogon ncalrpc - %s\n",
                          strerror(errno)));
-               ok = false;
                goto done;
        }
        listen_fd[*listen_fd_size] = fd;
@@ -817,33 +792,30 @@ static bool lsasd_create_sockets(struct tevent_context *ev_ctx,
 
        v = dcerpc_binding_vector_dup(tmp_ctx, v_orig);
        if (v == NULL) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_replace_iface(&ndr_table_netlogon, v);
        if (!NT_STATUS_IS_OK(status)) {
-               return false;
+               goto done;
        }
 
        status = dcerpc_binding_vector_add_np_default(&ndr_table_netlogon, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "netlogon");
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
        status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_netlogon, v);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto done;
        }
 
+       ok = true;
 done:
        if (fd != -1) {
                close(fd);