Refactoring: Make get_schannel_session_key return NTSTATUS
authorVolker Lendecke <vl@samba.org>
Sun, 20 Jul 2008 14:33:26 +0000 (16:33 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 20 Jul 2008 15:37:12 +0000 (17:37 +0200)
(This used to be commit a0793cc853d3bd43df2fc49df193a5fead6b01ab)

source3/include/proto.h
source3/libnet/libnet_join.c
source3/rpc_client/cli_pipe.c
source3/utils/net_rpc_join.c

index ee3905896adcf3ab279a1b443212e78f2d6072ae..822e2e07bc551e62c07d68b9b7a3e62498e9a919 100644 (file)
@@ -7118,10 +7118,10 @@ NTSTATUS cli_rpc_pipe_open_spnego_ntlmssp(struct cli_state *cli,
                                          const char *username,
                                          const char *password,
                                          struct rpc_pipe_client **presult);
-struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
-                                                       const char *domain,
-                                                       uint32 *pneg_flags,
-                                                       NTSTATUS *perr);
+NTSTATUS get_schannel_session_key(struct cli_state *cli,
+                                 const char *domain,
+                                 uint32 *pneg_flags,
+                                 struct rpc_pipe_client **presult);
 struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
                                        int pipe_idx,
                                        enum pipe_auth_level auth_level,
index 40637afabdf18b11afb92a6f6c92c6adb96b077e..a095cb2dfab731a50ad69f32cfe0fa4a1603f052 100644 (file)
@@ -1024,10 +1024,9 @@ NTSTATUS libnet_join_ok(const char *netbios_domain_name,
                return status;
        }
 
-       netlogon_pipe = get_schannel_session_key(cli,
-                                                netbios_domain_name,
-                                                &neg_flags, &status);
-       if (!netlogon_pipe) {
+       status = get_schannel_session_key(cli, netbios_domain_name,
+                                         &neg_flags, &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(status)) {
                if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_NETWORK_RESPONSE)) {
                        cli_shutdown(cli);
                        return NT_STATUS_OK;
index 0ba94ea29273df848aa8e8d101f66d60c4a5e92d..6d15771d738925ea0e457958110d0786b45b058f 100644 (file)
@@ -3203,27 +3203,29 @@ static NTSTATUS get_schannel_session_key_common(struct rpc_pipe_client *netlogon
  ****************************************************************************/
 
 
-struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli,
-                                                       const char *domain,
-                                                       uint32 *pneg_flags,
-                                                       NTSTATUS *perr)
+NTSTATUS get_schannel_session_key(struct cli_state *cli,
+                                 const char *domain,
+                                 uint32 *pneg_flags,
+                                 struct rpc_pipe_client **presult)
 {
        struct rpc_pipe_client *netlogon_pipe = NULL;
+       NTSTATUS status;
 
-       *perr = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
-                                        &netlogon_pipe);
-       if (!NT_STATUS_IS_OK(*perr)) {
-               return NULL;
+       status = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
+                                         &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
-       *perr = get_schannel_session_key_common(netlogon_pipe, cli, domain,
-                                               pneg_flags);
-       if (!NT_STATUS_IS_OK(*perr)) {
+       status = get_schannel_session_key_common(netlogon_pipe, cli, domain,
+                                                pneg_flags);
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(netlogon_pipe);
-               return NULL;
+               return status;
        }
 
-       return netlogon_pipe;
+       *presult = netlogon_pipe;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -3370,8 +3372,9 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel(struct cli_state *cli,
        struct rpc_pipe_client *netlogon_pipe = NULL;
        struct rpc_pipe_client *result = NULL;
 
-       netlogon_pipe = get_schannel_session_key(cli, domain, &neg_flags, perr);
-       if (!netlogon_pipe) {
+       *perr = get_schannel_session_key(cli, domain, &neg_flags,
+                                        &netlogon_pipe);
+       if (!NT_STATUS_IS_OK(*perr)) {
                DEBUG(0,("cli_rpc_pipe_open_schannel: failed to get schannel session "
                        "key from server %s for domain %s.\n",
                        cli->desthost, domain ));
index 609068e3d02d2cea602c94876704a1ca730c452c..2599c28e9c84cca0d4a4f8808c6bf6a6686b2077 100644 (file)
@@ -73,12 +73,13 @@ NTSTATUS net_rpc_join_ok(struct net_context *c, const char *domain,
        }
 
        /* Setup the creds as though we're going to do schannel... */
-        netlogon_pipe = get_schannel_session_key(cli, domain, &neg_flags, &ntret);
+       ntret = get_schannel_session_key(cli, domain, &neg_flags,
+                                        &netlogon_pipe);
 
        /* We return NT_STATUS_INVALID_NETWORK_RESPONSE if the server is refusing
           to negotiate schannel, but the creds were set up ok. That'll have to do. */
 
-        if (!netlogon_pipe) {
+        if (!NT_STATUS_IS_OK(ntret)) {
                if (NT_STATUS_EQUAL(ntret, NT_STATUS_INVALID_NETWORK_RESPONSE)) {
                        cli_shutdown(cli);
                        return NT_STATUS_OK;