handle username part of the ntlm name
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22373 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		| @@ -189,12 +189,29 @@ _gss_ntlm_accept_sec_context | ||||
| 					     ctx->ictx, | ||||
| 					     &type3, | ||||
| 					     &session); | ||||
| 	heim_ntlm_free_type3(&type3); | ||||
| 	if (maj_stat) { | ||||
| 	    heim_ntlm_free_type3(&type3); | ||||
| 	    _gss_ntlm_delete_sec_context(minor_status, context_handle, NULL); | ||||
| 	    return maj_stat; | ||||
| 	} | ||||
|  | ||||
| 	if (src_name) { | ||||
| 	    ntlm_name n = calloc(1, sizeof(*n)); | ||||
| 	    if (n) { | ||||
| 		n->user = strdup(type3.username); | ||||
| 		n->domain = strdup(type3.targetname); | ||||
| 	    } | ||||
| 	    if (n == NULL || n->user == NULL || n->domain == NULL) { | ||||
| 		heim_ntlm_free_type3(&type3); | ||||
| 		_gss_ntlm_delete_sec_context(minor_status,  | ||||
| 					     context_handle, NULL); | ||||
| 		return maj_stat; | ||||
| 	    } | ||||
| 	    *src_name = (gss_name_t)n; | ||||
| 	}	     | ||||
|  | ||||
| 	heim_ntlm_free_type3(&type3); | ||||
|  | ||||
| 	ret = krb5_data_copy(&ctx->sessionkey,  | ||||
| 			     session.data, session.length); | ||||
| 	if (ret) {	 | ||||
|   | ||||
| @@ -80,15 +80,14 @@ OM_uint32 _gss_ntlm_acquire_cred | ||||
| 	} | ||||
|     }	 | ||||
|     if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) { | ||||
| 	gss_cred_id_t gcred; | ||||
| 	ntlm_cred cred; | ||||
|  | ||||
| 	*min_stat = _gss_ntlm_get_user_cred(name->domain, &cred); | ||||
| 	if (*min_stat) | ||||
| 	    return GSS_S_FAILURE; | ||||
| 	cred->usage = cred_usage; | ||||
|  | ||||
| 	gcred = (gss_cred_id_t)cred; | ||||
| 	_gss_ntlm_release_cred(NULL, &gcred); | ||||
| 	*output_cred_handle = (gss_cred_id_t)cred; | ||||
|     } | ||||
|  | ||||
|     return (GSS_S_COMPLETE); | ||||
|   | ||||
| @@ -43,11 +43,30 @@ OM_uint32 _gss_ntlm_display_name | ||||
|            ) | ||||
| { | ||||
|     *minor_status = 0; | ||||
|  | ||||
|     if (output_name_type) | ||||
| 	*output_name_type = GSS_NTLM_MECHANISM; | ||||
|  | ||||
|     if (output_name_buffer) { | ||||
| 	ntlm_name n = (ntlm_name)input_name; | ||||
| 	char *str; | ||||
| 	int len; | ||||
| 	 | ||||
| 	output_name_buffer->length = 0; | ||||
| 	output_name_buffer->value = NULL; | ||||
|  | ||||
| 	if (n == NULL) { | ||||
| 	    *minor_status = 0; | ||||
| 	    return GSS_S_BAD_NAME; | ||||
| 	} | ||||
|  | ||||
| 	len = asprintf(&str, "%s@%s", n->user, n->domain); | ||||
| 	if (str == NULL) { | ||||
| 	    *minor_status = ENOMEM; | ||||
| 	    return GSS_S_FAILURE; | ||||
| 	} | ||||
| 	output_name_buffer->length = len; | ||||
| 	output_name_buffer->value = str; | ||||
|     } | ||||
|     return GSS_S_COMPLETE; | ||||
| } | ||||
|   | ||||
| @@ -65,6 +65,7 @@ OM_uint32 _gss_ntlm_import_name | ||||
|     p = strchr(name, '@'); | ||||
|     if (p == NULL) | ||||
| 	return GSS_S_BAD_NAME; | ||||
|     p[0] = '\0'; | ||||
|     p++; | ||||
|     p2 = strchr(p, '.'); | ||||
|     if (p2 && p2[1] != '\0') { | ||||
| @@ -75,15 +76,26 @@ OM_uint32 _gss_ntlm_import_name | ||||
|     } | ||||
|     strupr(p); | ||||
|      | ||||
|     n = malloc(sizeof(n) + strlen(p)); | ||||
|     if (n == NULL) { | ||||
|     n = calloc(1, sizeof(*n)); | ||||
|     if (name == NULL) { | ||||
| 	free(name); | ||||
| 	*minor_status = ENOMEM; | ||||
| 	return GSS_S_FAILURE; | ||||
|     } | ||||
|     strcpy(n->domain, p); | ||||
|  | ||||
|     n->user = strdup(name); | ||||
|     n->domain = strdup(p); | ||||
|  | ||||
|     free(name); | ||||
|  | ||||
|     if (n->user == NULL || n->domain == NULL) { | ||||
| 	free(n->user); | ||||
| 	free(n->domain); | ||||
| 	free(n); | ||||
| 	*minor_status = ENOMEM; | ||||
| 	return GSS_S_FAILURE; | ||||
|     } | ||||
|  | ||||
|     *output_name = (gss_name_t)n; | ||||
|  | ||||
|     return GSS_S_COMPLETE; | ||||
|   | ||||
| @@ -97,6 +97,7 @@ struct ntlmv2_key { | ||||
| extern struct ntlm_server_interface ntlmsspi_kdc_digest; | ||||
|  | ||||
| typedef struct ntlm_cred { | ||||
|     gss_cred_usage_t usage; | ||||
|     char *username; | ||||
|     char *domain; | ||||
|     struct ntlm_buf key; | ||||
| @@ -128,7 +129,8 @@ typedef struct { | ||||
| } *ntlm_ctx; | ||||
|  | ||||
| typedef struct { | ||||
|     char domain[1]; | ||||
|     char *user; | ||||
|     char *domain; | ||||
| } *ntlm_name; | ||||
|  | ||||
| #include <ntlm/ntlm-private.h> | ||||
|   | ||||
| @@ -43,8 +43,11 @@ OM_uint32 _gss_ntlm_release_name | ||||
|     if (minor_status) | ||||
| 	*minor_status = 0; | ||||
|     if (input_name) { | ||||
| 	free(*input_name); | ||||
| 	ntlm_name n = (ntlm_name)*input_name; | ||||
| 	*input_name = GSS_C_NO_NAME; | ||||
| 	free(n->user); | ||||
| 	free(n->domain); | ||||
| 	free(n); | ||||
|     } | ||||
|     return GSS_S_COMPLETE; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Love Hörnquist Åstrand
					Love Hörnquist Åstrand