s3-auth: Inline ntlmssp_server_start() into gensec_ntlmssp3_server_start()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 31 Jan 2012 04:36:08 +0000 (15:36 +1100)
committerStefan Metzmacher <metze@samba.org>
Fri, 17 Feb 2012 09:48:09 +0000 (10:48 +0100)
This will help syncing this rotuine up with gensec_ntlmssp_server_start().

Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/auth/auth_ntlmssp.c

index 027666fb0a368a9414af9d63cd6aff56d6a3858d..36e74924abf2a0a712144e9282105874ef461d9b 100644 (file)
@@ -211,6 +211,7 @@ static NTSTATUS gensec_ntlmssp3_server_start(struct gensec_security *gensec_secu
        const char *dns_name;
        char *dns_domain;
        struct gensec_ntlmssp_context *gensec_ntlmssp;
+       struct ntlmssp_state *ntlmssp_state;
 
        if ((enum server_role)lp_server_role() == ROLE_STANDALONE) {
                is_standalone = true;
@@ -234,17 +235,67 @@ static NTSTATUS gensec_ntlmssp3_server_start(struct gensec_security *gensec_secu
                talloc_get_type_abort(gensec_security->private_data,
                                      struct gensec_ntlmssp_context);
 
-       nt_status = ntlmssp_server_start(gensec_ntlmssp,
-                                        is_standalone,
-                                        netbios_name,
-                                        netbios_domain,
-                                        dns_name,
-                                        dns_domain,
-                                        &gensec_ntlmssp->ntlmssp_state);
-       if (!NT_STATUS_IS_OK(nt_status)) {
-               return nt_status;
+       if (!netbios_name) {
+               netbios_name = "";
+       }
+
+       if (!netbios_domain) {
+               netbios_domain = "";
+       }
+
+       if (!dns_domain) {
+               dns_domain = "";
        }
 
+       if (!dns_name) {
+               dns_name = "";
+       }
+
+       ntlmssp_state = talloc_zero(gensec_ntlmssp, struct ntlmssp_state);
+       if (!ntlmssp_state) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       ntlmssp_state->role = NTLMSSP_SERVER;
+
+       ntlmssp_state->server.is_standalone = is_standalone;
+
+       ntlmssp_state->expected_state = NTLMSSP_NEGOTIATE;
+
+       ntlmssp_state->allow_lm_key = lp_lanman_auth();
+
+       ntlmssp_state->neg_flags =
+               NTLMSSP_NEGOTIATE_128 |
+               NTLMSSP_NEGOTIATE_56 |
+               NTLMSSP_NEGOTIATE_VERSION |
+               NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
+               NTLMSSP_NEGOTIATE_NTLM |
+               NTLMSSP_NEGOTIATE_NTLM2 |
+               NTLMSSP_NEGOTIATE_KEY_EXCH;
+
+       ntlmssp_state->server.netbios_name = talloc_strdup(ntlmssp_state, netbios_name);
+       if (!ntlmssp_state->server.netbios_name) {
+               talloc_free(ntlmssp_state);
+               return NT_STATUS_NO_MEMORY;
+       }
+       ntlmssp_state->server.netbios_domain = talloc_strdup(ntlmssp_state, netbios_domain);
+       if (!ntlmssp_state->server.netbios_domain) {
+               talloc_free(ntlmssp_state);
+               return NT_STATUS_NO_MEMORY;
+       }
+       ntlmssp_state->server.dns_name = talloc_strdup(ntlmssp_state, dns_name);
+       if (!ntlmssp_state->server.dns_name) {
+               talloc_free(ntlmssp_state);
+               return NT_STATUS_NO_MEMORY;
+       }
+       ntlmssp_state->server.dns_domain = talloc_strdup(ntlmssp_state, dns_domain);
+       if (!ntlmssp_state->server.dns_domain) {
+               talloc_free(ntlmssp_state);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       gensec_ntlmssp->ntlmssp_state = ntlmssp_state;
+
        gensec_ntlmssp->ntlmssp_state->callback_private = gensec_ntlmssp;
 
        gensec_ntlmssp->ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;