s3-ntlmssp: Remove ntlmssp_end and let the talloc hierarchy handle it.
authorSimo Sorce <idra@samba.org>
Fri, 16 Jul 2010 21:30:14 +0000 (17:30 -0400)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 19 Jul 2010 04:19:47 +0000 (14:19 +1000)
All the members are children of ntlmssp_state anyway.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source3/auth/auth_ntlmssp.c
source3/include/proto.h
source3/libads/sasl.c
source3/libsmb/cliconnect.c
source3/libsmb/ntlmssp.c
source3/libsmb/smb_seal.c
source3/rpc_client/cli_pipe.c
source3/utils/ntlm_auth.c
source3/winbindd/winbindd_ccache_access.c

index ba7efbf48eb98a9b8f8d999993d9cab7a644c2c8..d343eef5ff909444571aebbad556a3ecca1a532b 100644 (file)
@@ -327,7 +327,7 @@ void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state)
 
        mem_ctx = (*auth_ntlmssp_state)->mem_ctx;
        if ((*auth_ntlmssp_state)->ntlmssp_state) {
-               ntlmssp_end(&(*auth_ntlmssp_state)->ntlmssp_state);
+               TALLOC_FREE((*auth_ntlmssp_state)->ntlmssp_state);
        }
        if ((*auth_ntlmssp_state)->auth_context) {
                ((*auth_ntlmssp_state)->auth_context->free)(&(*auth_ntlmssp_state)->auth_context);
index 9471f63195d10498d953b31657294ce903e8af99..1cf96211822ff2e4ee82333bbfaed859f6798d72 100644 (file)
@@ -3102,7 +3102,6 @@ void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *featur
 void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature);
 NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
                        const DATA_BLOB in, DATA_BLOB *out) ;
-void ntlmssp_end(struct ntlmssp_state **ntlmssp_state);
 DATA_BLOB ntlmssp_weaken_keys(struct ntlmssp_state *ntlmssp_state, TALLOC_CTX *mem_ctx);
 NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx,
                              bool is_standalone,
index 04b9a71d76e2498be12fd4636631fed448469ce5..a37d1e84745ea26c10eff6a78f7e24412ef9abfc 100644 (file)
@@ -106,7 +106,7 @@ static void ads_sasl_ntlmssp_disconnect(ADS_STRUCT *ads)
        struct ntlmssp_state *ntlmssp_state =
                (struct ntlmssp_state *)ads->ldap.wrap_private_data;
 
-       ntlmssp_end(&ntlmssp_state);
+       TALLOC_FREE(ntlmssp_state);
 
        ads->ldap.wrap_ops = NULL;
        ads->ldap.wrap_private_data = NULL;
@@ -209,7 +209,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
                                        ber_bvfree(scred);
                                }
 
-                               ntlmssp_end(&ntlmssp_state);
+                               TALLOC_FREE(ntlmssp_state);
                                return ADS_ERROR(rc);
                        }
                        if (scred) {
@@ -221,7 +221,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
 
                } else {
 
-                       ntlmssp_end(&ntlmssp_state);
+                       TALLOC_FREE(ntlmssp_state);
                        data_blob_free(&blob_out);
                        return ADS_ERROR_NT(nt_status);
                }
@@ -233,7 +233,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
                        if (!spnego_parse_challenge(blob, &blob_in, 
                                                    &tmp_blob)) {
 
-                               ntlmssp_end(&ntlmssp_state);
+                               TALLOC_FREE(ntlmssp_state);
                                data_blob_free(&blob);
                                DEBUG(3,("Failed to parse challenges\n"));
                                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
@@ -243,7 +243,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
                        if (!spnego_parse_auth_response(blob, nt_status, OID_NTLMSSP, 
                                                        &blob_in)) {
 
-                               ntlmssp_end(&ntlmssp_state);
+                               TALLOC_FREE(ntlmssp_state);
                                data_blob_free(&blob);
                                DEBUG(3,("Failed to parse auth response\n"));
                                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
@@ -266,11 +266,11 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
                if (!ADS_ERR_OK(status)) {
                        DEBUG(0, ("ads_setup_sasl_wrapping() failed: %s\n",
                                ads_errstr(status)));
-                       ntlmssp_end(&ntlmssp_state);
+                       TALLOC_FREE(ntlmssp_state);
                        return status;
                }
        } else {
-               ntlmssp_end(&ntlmssp_state);
+               TALLOC_FREE(ntlmssp_state);
        }
 
        return ADS_ERROR(rc);
index 06a6f7e683f4f38fc74dddee6b3a8e819d079d0e..8d4c1901c13e5430ac25dd5535834799f434f492 100644 (file)
@@ -969,7 +969,7 @@ static int cli_session_setup_ntlmssp_state_destructor(
        struct cli_session_setup_ntlmssp_state *state)
 {
        if (state->ntlmssp_state != NULL) {
-               ntlmssp_end(&state->ntlmssp_state);
+               TALLOC_FREE(state->ntlmssp_state);
        }
        return 0;
 }
@@ -1079,7 +1079,7 @@ static void cli_session_setup_ntlmssp_done(struct tevent_req *subreq)
                        return;
                }
                TALLOC_FREE(subreq);
-               ntlmssp_end(&state->ntlmssp_state);
+               TALLOC_FREE(state->ntlmssp_state);
                tevent_req_done(req);
                return;
        }
@@ -1122,7 +1122,7 @@ static void cli_session_setup_ntlmssp_done(struct tevent_req *subreq)
        if (!NT_STATUS_IS_OK(status)
            && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
                TALLOC_FREE(subreq);
-               ntlmssp_end(&state->ntlmssp_state);
+               TALLOC_FREE(state->ntlmssp_state);
                tevent_req_nterror(req, status);
                return;
        }
index 228d19536ea2b748848629c131991121b697531e..a0dc39be3e6a9763f8ceea168fd1f42ba71a2fa3 100644 (file)
@@ -274,23 +274,6 @@ NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
        return NT_STATUS_INVALID_PARAMETER;
 }
 
-/**
- * End an NTLMSSP state machine
- *
- * @param ntlmssp_state NTLMSSP State, free()ed by this function
- */
-
-void ntlmssp_end(struct ntlmssp_state **ntlmssp_state)
-{
-       data_blob_free(&(*ntlmssp_state)->chal);
-       data_blob_free(&(*ntlmssp_state)->lm_resp);
-       data_blob_free(&(*ntlmssp_state)->nt_resp);
-       TALLOC_FREE(*ntlmssp_state);
-
-       *ntlmssp_state = NULL;
-       return;
-}
-
 /**
  * Determine correct target name flags for reply, given server role
  * and negotiated flags
index 92d7fef651e2aa89decb10b30e63a3d3c844f6b6..4610850638a190ccddc0bd6f67a7dade70b013ad 100644 (file)
@@ -371,7 +371,7 @@ void common_free_encryption_state(struct smb_trans_enc_state **pp_es)
 
        if (es->smb_enc_type == SMB_TRANS_ENC_NTLM) {
                if (es->s.ntlmssp_state) {
-                       ntlmssp_end(&es->s.ntlmssp_state);
+                       TALLOC_FREE(es->s.ntlmssp_state);
                }
        }
 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
index a61200a10459c6bfcf4155d042ad1274281e2098..8dd9386eab8cf56cc93e6641c2cfc5f89f87667b 100644 (file)
@@ -2704,7 +2704,7 @@ NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
 
 static int cli_auth_ntlmssp_data_destructor(struct cli_pipe_auth_data *auth)
 {
-       ntlmssp_end(&auth->a_u.ntlmssp_state);
+       TALLOC_FREE(auth->a_u.ntlmssp_state);
        return 0;
 }
 
index e7887cca718b9a4e3b9563a0376a8ae9f1e8b850..bfdc369b150695cdbd0fb5f086d27afaf44fb48a 100644 (file)
@@ -656,7 +656,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Could not start NTLMSSP client: %s\n",
                          nt_errstr(status)));
-               ntlmssp_end(client_ntlmssp_state);
+               TALLOC_FREE(*client_ntlmssp_state);
                return status;
        }
 
@@ -665,7 +665,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Could not set username: %s\n",
                          nt_errstr(status)));
-               ntlmssp_end(client_ntlmssp_state);
+               TALLOC_FREE(*client_ntlmssp_state);
                return status;
        }
 
@@ -674,7 +674,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Could not set domain: %s\n",
                          nt_errstr(status)));
-               ntlmssp_end(client_ntlmssp_state);
+               TALLOC_FREE(*client_ntlmssp_state);
                return status;
        }
 
@@ -684,7 +684,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("Could not set password: %s\n",
                                  nt_errstr(status)));
-                       ntlmssp_end(client_ntlmssp_state);
+                       TALLOC_FREE(*client_ntlmssp_state);
                        return status;
                }
        }
@@ -854,7 +854,7 @@ static void manage_squid_ntlmssp_request(struct ntlm_auth_state *state,
 
        if (strncmp(buf, "YR", 2) == 0) {
                if (state->ntlmssp_state)
-                       ntlmssp_end(&state->ntlmssp_state);
+                       TALLOC_FREE(state->ntlmssp_state);
                state->svr_state = SERVER_INITIAL;
        } else if (strncmp(buf, "KK", 2) == 0) {
                /* No special preprocessing required */
@@ -916,7 +916,7 @@ static void manage_squid_ntlmssp_request(struct ntlm_auth_state *state,
                x_fprintf(x_stdout, "BH %s\n", nt_errstr(nt_status));
                DEBUG(0, ("NTLMSSP BH: %s\n", nt_errstr(nt_status)));
 
-               ntlmssp_end(&state->ntlmssp_state);
+               TALLOC_FREE(state->ntlmssp_state);
        } else if (!NT_STATUS_IS_OK(nt_status)) {
                x_fprintf(x_stdout, "NA %s\n", nt_errstr(nt_status));
                DEBUG(10, ("NTLMSSP %s\n", nt_errstr(nt_status)));
@@ -1010,7 +1010,7 @@ static void manage_client_ntlmssp_request(struct ntlm_auth_state *state,
 
        if (strncmp(buf, "YR", 2) == 0) {
                if (state->ntlmssp_state)
-                       ntlmssp_end(&state->ntlmssp_state);
+                       TALLOC_FREE(state->ntlmssp_state);
                state->cli_state = CLIENT_INITIAL;
        } else if (strncmp(buf, "TT", 2) == 0) {
                /* No special preprocessing required */
@@ -1102,13 +1102,13 @@ static void manage_client_ntlmssp_request(struct ntlm_auth_state *state,
                DEBUG(10, ("NTLMSSP OK!\n"));
                state->cli_state = CLIENT_FINISHED;
                if (state->ntlmssp_state)
-                       ntlmssp_end(&state->ntlmssp_state);
+                       TALLOC_FREE(state->ntlmssp_state);
        } else {
                x_fprintf(x_stdout, "BH %s\n", nt_errstr(nt_status));
                DEBUG(0, ("NTLMSSP BH: %s\n", nt_errstr(nt_status)));
                state->cli_state = CLIENT_ERROR;
                if (state->ntlmssp_state)
-                       ntlmssp_end(&state->ntlmssp_state);
+                       TALLOC_FREE(state->ntlmssp_state);
        }
 
        data_blob_free(&request);
@@ -1223,7 +1223,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
 
        if (strncmp(buf, "YR", 2) == 0) {
                if (ntlmssp_state)
-                       ntlmssp_end(&ntlmssp_state);
+                       TALLOC_FREE(ntlmssp_state);
        } else if (strncmp(buf, "KK", 2) == 0) {
                ;
        } else {
@@ -1288,7 +1288,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
                                x_fprintf(x_stdout, "BH Client wants a new "
                                                    "NTLMSSP challenge, but "
                                                    "already got one\n");
-                               ntlmssp_end(&ntlmssp_state);
+                               TALLOC_FREE(ntlmssp_state);
                                return;
                        }
 
@@ -1394,7 +1394,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
                if (NT_STATUS_IS_OK(status)) {
                        user = SMB_STRDUP(ntlmssp_state->user);
                        domain = SMB_STRDUP(ntlmssp_state->domain);
-                       ntlmssp_end(&ntlmssp_state);
+                       TALLOC_FREE(ntlmssp_state);
                }
        }
 
@@ -1495,7 +1495,7 @@ static bool manage_client_ntlmssp_init(struct spnego_data spnego)
                        NT_STATUS_IS_OK(status)) ) {
                DEBUG(1, ("Expected OK or MORE_PROCESSING_REQUIRED, got: %s\n",
                          nt_errstr(status)));
-               ntlmssp_end(&client_ntlmssp_state);
+               TALLOC_FREE(client_ntlmssp_state);
                return False;
        }
 
@@ -1528,13 +1528,13 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
 
        if (spnego.negTokenTarg.negResult == SPNEGO_REJECT) {
                x_fprintf(x_stdout, "NA\n");
-               ntlmssp_end(&client_ntlmssp_state);
+               TALLOC_FREE(client_ntlmssp_state);
                return;
        }
 
        if (spnego.negTokenTarg.negResult == SPNEGO_ACCEPT_COMPLETED) {
                x_fprintf(x_stdout, "AF\n");
-               ntlmssp_end(&client_ntlmssp_state);
+               TALLOC_FREE(client_ntlmssp_state);
                return;
        }
 
@@ -1549,7 +1549,7 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
                x_fprintf(x_stdout, "BH Expected MORE_PROCESSING_REQUIRED from "
                                    "ntlmssp_client_update\n");
                data_blob_free(&request);
-               ntlmssp_end(&client_ntlmssp_state);
+               TALLOC_FREE(client_ntlmssp_state);
                return;
        }
 
@@ -1798,7 +1798,7 @@ static void manage_gss_spnego_client_request(struct ntlm_auth_state *state,
                                                    "negResult\n");
                        }
 
-                       ntlmssp_end(&client_ntlmssp_state);
+                       TALLOC_FREE(client_ntlmssp_state);
                        goto out;
                }
 
index c5a760af05210b2cfe09bf569f5584e03ddbe8be..6a265ccaf07c5503b0c84618fb09d64190967c9d 100644 (file)
@@ -136,7 +136,7 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
        status = NT_STATUS_OK;
 
 done:
-       ntlmssp_end(&ntlmssp_state);
+       TALLOC_FREE(ntlmssp_state);
        return status;
 }