]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:net_rpc: don't shutdown a cli_state passed from the caller
authorStefan Metzmacher <metze@samba.org>
Thu, 26 Mar 2009 19:29:24 +0000 (20:29 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 20 Apr 2009 14:35:39 +0000 (16:35 +0200)
This fixes a crash bug if we timeout in net rpc trustdom list.

metze

(cherry picked from commit c0dfe0cf80ee50f395912b7d6aec0d87febd34c0)
(cherry picked from commit d87563604ca7b1c18c5a84d76726c2a99dc454f8)
(cherry picked from commit cba4214b963983730bedc792e391b5435889597a)

source/utils/net_rpc.c

index 1eaa1c610ba6cc73647109f0ccfa5b3e5f9e52df..ceeed638cad27fdb0b41c997a43e6d192c8ddea5 100644 (file)
@@ -118,6 +118,7 @@ int run_rpc_command(struct cli_state *cli_arg,
        NTSTATUS nt_status;
        DOM_SID *domain_sid;
        const char *domain_name;
+       int ret = -1;
 
        /* make use of cli_state handed over as an argument, if possible */
        if (!cli_arg) {
@@ -139,15 +140,13 @@ int run_rpc_command(struct cli_state *cli_arg,
        
        if (!(mem_ctx = talloc_init("run_rpc_command"))) {
                DEBUG(0, ("talloc_init() failed\n"));
-               cli_shutdown(cli);
-               return -1;
+               goto fail;
        }
        
        nt_status = net_get_remote_domain_sid(cli, mem_ctx, &domain_sid,
                                              &domain_name);
        if (!NT_STATUS_IS_OK(nt_status)) {
-               cli_shutdown(cli);
-               return -1;
+               goto fail;
        }
 
        if (!(conn_flags & NET_FLAGS_NO_PIPE)) {
@@ -160,8 +159,7 @@ int run_rpc_command(struct cli_state *cli_arg,
                        if (!pipe_hnd) {
                                DEBUG(0, ("Could not initialise schannel netlogon pipe. Error was %s\n",
                                        nt_errstr(nt_status) ));
-                               cli_shutdown(cli);
-                               return -1;
+                               goto fail;
                        }
                } else {
                        pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, &nt_status);
@@ -169,8 +167,7 @@ int run_rpc_command(struct cli_state *cli_arg,
                                DEBUG(0, ("Could not initialise pipe %s. Error was %s\n",
                                        cli_get_pipe_name(pipe_idx),
                                        nt_errstr(nt_status) ));
-                               cli_shutdown(cli);
-                               return -1;
+                               goto fail;
                        }
                }
        }
@@ -180,6 +177,7 @@ int run_rpc_command(struct cli_state *cli_arg,
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(1, ("rpc command function failed! (%s)\n", nt_errstr(nt_status)));
        } else {
+               ret = 0;
                DEBUG(5, ("rpc command function succedded\n"));
        }
                
@@ -189,13 +187,14 @@ int run_rpc_command(struct cli_state *cli_arg,
                }
        }
 
+fail:
        /* close the connection only if it was opened here */
        if (!cli_arg) {
                cli_shutdown(cli);
        }
        
        talloc_destroy(mem_ctx);
-       return (!NT_STATUS_IS_OK(nt_status));
+       return ret;
 }
 
 /**