s3-ntlmssp split auth_ntlmssp_client_start() into two parts
authorAndrew Bartlett <abartlet@samba.org>
Mon, 17 Oct 2011 09:19:11 +0000 (20:19 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 18 Oct 2011 10:25:30 +0000 (12:25 +0200)
This will allow it to be a wrapper around a gensec module, which
requires that they options be set on a context, but before the
mechanism is started.

This also simplfies the callers, by moving the lp_*() calls
into one place.

Andrew Bartlett

source3/include/ntlmssp_wrap.h
source3/librpc/crypto/cli_spnego.c
source3/libsmb/clifsinfo.c
source3/libsmb/ntlmssp_wrap.c
source3/rpc_client/cli_pipe.c

index 863c359bbe45267e0029b5cf17ba59b052835c69..7ee3d3d9d89ace32f20816b2575cec2c8b94ed22 100644 (file)
@@ -74,9 +74,8 @@ NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *ans,
                             TALLOC_CTX *mem_ctx,
                             const DATA_BLOB request, DATA_BLOB *reply);
 
-NTSTATUS auth_ntlmssp_client_start(TALLOC_CTX *mem_ctx,
-                                  const char *netbios_name,
-                                  const char *netbios_domain,
-                                  bool use_ntlmv2,
-                                  struct auth_ntlmssp_state **_ans);
+NTSTATUS auth_ntlmssp_client_prepare(TALLOC_CTX *mem_ctx,
+                                    struct auth_ntlmssp_state **_ans);
+NTSTATUS auth_ntlmssp_client_start(struct auth_ntlmssp_state *ans);
+
 #endif /* _NTLMSSP_WRAP_ */
index 3420e20d272cce7b047ee811cd4d53be1956c68a..4742158b246a47bb1deab6b4fa3ba29c64f07b39 100644 (file)
@@ -99,10 +99,7 @@ NTSTATUS spnego_ntlmssp_init_client(TALLOC_CTX *mem_ctx,
        }
        sp_ctx->mech = SPNEGO_NTLMSSP;
 
-       status = auth_ntlmssp_client_start(sp_ctx,
-                                       lp_netbios_name(),
-                                       lp_workgroup(),
-                                       lp_client_ntlmv2_auth(),
+       status = auth_ntlmssp_client_prepare(sp_ctx,
                                        &sp_ctx->mech_ctx.ntlmssp_state);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(sp_ctx);
@@ -138,6 +135,12 @@ NTSTATUS spnego_ntlmssp_init_client(TALLOC_CTX *mem_ctx,
                                          NTLMSSP_FEATURE_SEAL);
        }
 
+       status = auth_ntlmssp_client_start(sp_ctx->mech_ctx.ntlmssp_state);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(sp_ctx);
+               return status;
+       }
+
        *spnego_ctx = sp_ctx;
        return NT_STATUS_OK;
 }
index 12961c93900def7c38db7e2753d15ad2c42e9a7f..b312cfbd4877e923ece31c291db47291af27a02c 100644 (file)
@@ -613,11 +613,8 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
        if (!es) {
                return NT_STATUS_NO_MEMORY;
        }
-       status = auth_ntlmssp_client_start(NULL,
-                                     lp_netbios_name(),
-                                     lp_workgroup(),
-                                     lp_client_ntlmv2_auth(),
-                                     &es->s.auth_ntlmssp_state);
+       status = auth_ntlmssp_client_prepare(NULL,
+                                            &es->s.auth_ntlmssp_state);
        if (!NT_STATUS_IS_OK(status)) {
                goto fail;
        }
@@ -635,6 +632,10 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
                goto fail;
        }
 
+       if (!NT_STATUS_IS_OK(status = auth_ntlmssp_client_start(es->s.auth_ntlmssp_state))) {
+               goto fail;
+       }
+
        do {
                status = auth_ntlmssp_update(es->s.auth_ntlmssp_state, es->s.auth_ntlmssp_state,
                                             blob_in, &blob_out);
index 6f854f25cdc4279a54ba5bb6ea37a3c2d4e018f5..5f8e246398c281ffe22f0177c6d2c08e27b4da46 100644 (file)
@@ -176,10 +176,7 @@ NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *ans,
        return status;
 }
 
-NTSTATUS auth_ntlmssp_client_start(TALLOC_CTX *mem_ctx,
-                                  const char *netbios_name,
-                                  const char *netbios_domain,
-                                  bool use_ntlmv2,
+NTSTATUS auth_ntlmssp_client_prepare(TALLOC_CTX *mem_ctx,
                                   struct auth_ntlmssp_state **_ans)
 {
        struct auth_ntlmssp_state *ans;
@@ -188,8 +185,8 @@ NTSTATUS auth_ntlmssp_client_start(TALLOC_CTX *mem_ctx,
        ans = talloc_zero(mem_ctx, struct auth_ntlmssp_state);
 
        status = ntlmssp_client_start(ans,
-                                       netbios_name, netbios_domain,
-                                       use_ntlmv2, &ans->ntlmssp_state);
+                                     lp_netbios_name(), lp_workgroup(),
+                                     lp_client_ntlmv2_auth(), &ans->ntlmssp_state);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -197,3 +194,10 @@ NTSTATUS auth_ntlmssp_client_start(TALLOC_CTX *mem_ctx,
        *_ans = ans;
        return NT_STATUS_OK;
 }
+
+NTSTATUS auth_ntlmssp_client_start(struct auth_ntlmssp_state *ans)
+{
+       NTSTATUS status;
+
+       return NT_STATUS_OK;
+}
index 247e4867f97cde0f49f833a051136f249b3c50cd..94e4a5106f7c5c44027499492d4a338ba88bfdda 100644 (file)
@@ -2283,11 +2283,8 @@ static NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
                goto fail;
        }
 
-       status = auth_ntlmssp_client_start(result,
-                                     lp_netbios_name(),
-                                     lp_workgroup(),
-                                     lp_client_ntlmv2_auth(),
-                                     &ntlmssp_ctx);
+       status = auth_ntlmssp_client_prepare(result,
+                                            &ntlmssp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                goto fail;
        }
@@ -2313,6 +2310,11 @@ static NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
                auth_ntlmssp_want_feature(ntlmssp_ctx, NTLMSSP_FEATURE_SEAL);
        }
 
+       status = auth_ntlmssp_client_start(ntlmssp_ctx);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto fail;
+       }
+
        result->auth_ctx = ntlmssp_ctx;
        *presult = result;
        return NT_STATUS_OK;