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, | 					     ctx->ictx, | ||||||
| 					     &type3, | 					     &type3, | ||||||
| 					     &session); | 					     &session); | ||||||
| 	heim_ntlm_free_type3(&type3); |  | ||||||
| 	if (maj_stat) { | 	if (maj_stat) { | ||||||
|  | 	    heim_ntlm_free_type3(&type3); | ||||||
| 	    _gss_ntlm_delete_sec_context(minor_status, context_handle, NULL); | 	    _gss_ntlm_delete_sec_context(minor_status, context_handle, NULL); | ||||||
| 	    return maj_stat; | 	    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,  | 	ret = krb5_data_copy(&ctx->sessionkey,  | ||||||
| 			     session.data, session.length); | 			     session.data, session.length); | ||||||
| 	if (ret) {	 | 	if (ret) {	 | ||||||
|   | |||||||
| @@ -80,15 +80,14 @@ OM_uint32 _gss_ntlm_acquire_cred | |||||||
| 	} | 	} | ||||||
|     }	 |     }	 | ||||||
|     if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) { |     if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) { | ||||||
| 	gss_cred_id_t gcred; |  | ||||||
| 	ntlm_cred cred; | 	ntlm_cred cred; | ||||||
|  |  | ||||||
| 	*min_stat = _gss_ntlm_get_user_cred(name->domain, &cred); | 	*min_stat = _gss_ntlm_get_user_cred(name->domain, &cred); | ||||||
| 	if (*min_stat) | 	if (*min_stat) | ||||||
| 	    return GSS_S_FAILURE; | 	    return GSS_S_FAILURE; | ||||||
|  | 	cred->usage = cred_usage; | ||||||
|  |  | ||||||
| 	gcred = (gss_cred_id_t)cred; | 	*output_cred_handle = (gss_cred_id_t)cred; | ||||||
| 	_gss_ntlm_release_cred(NULL, &gcred); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return (GSS_S_COMPLETE); |     return (GSS_S_COMPLETE); | ||||||
|   | |||||||
| @@ -43,11 +43,30 @@ OM_uint32 _gss_ntlm_display_name | |||||||
|            ) |            ) | ||||||
| { | { | ||||||
|     *minor_status = 0; |     *minor_status = 0; | ||||||
|  |  | ||||||
|     if (output_name_type) |     if (output_name_type) | ||||||
| 	*output_name_type = GSS_NTLM_MECHANISM; | 	*output_name_type = GSS_NTLM_MECHANISM; | ||||||
|  |  | ||||||
|     if (output_name_buffer) { |     if (output_name_buffer) { | ||||||
|  | 	ntlm_name n = (ntlm_name)input_name; | ||||||
|  | 	char *str; | ||||||
|  | 	int len; | ||||||
|  | 	 | ||||||
| 	output_name_buffer->length = 0; | 	output_name_buffer->length = 0; | ||||||
| 	output_name_buffer->value = NULL; | 	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; |     return GSS_S_COMPLETE; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -65,6 +65,7 @@ OM_uint32 _gss_ntlm_import_name | |||||||
|     p = strchr(name, '@'); |     p = strchr(name, '@'); | ||||||
|     if (p == NULL) |     if (p == NULL) | ||||||
| 	return GSS_S_BAD_NAME; | 	return GSS_S_BAD_NAME; | ||||||
|  |     p[0] = '\0'; | ||||||
|     p++; |     p++; | ||||||
|     p2 = strchr(p, '.'); |     p2 = strchr(p, '.'); | ||||||
|     if (p2 && p2[1] != '\0') { |     if (p2 && p2[1] != '\0') { | ||||||
| @@ -75,15 +76,26 @@ OM_uint32 _gss_ntlm_import_name | |||||||
|     } |     } | ||||||
|     strupr(p); |     strupr(p); | ||||||
|      |      | ||||||
|     n = malloc(sizeof(n) + strlen(p)); |     n = calloc(1, sizeof(*n)); | ||||||
|     if (n == NULL) { |     if (name == NULL) { | ||||||
| 	free(name); | 	free(name); | ||||||
| 	*minor_status = ENOMEM; | 	*minor_status = ENOMEM; | ||||||
| 	return GSS_S_FAILURE; | 	return GSS_S_FAILURE; | ||||||
|     } |     } | ||||||
|     strcpy(n->domain, p); |  | ||||||
|  |     n->user = strdup(name); | ||||||
|  |     n->domain = strdup(p); | ||||||
|  |  | ||||||
|     free(name); |     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; |     *output_name = (gss_name_t)n; | ||||||
|  |  | ||||||
|     return GSS_S_COMPLETE; |     return GSS_S_COMPLETE; | ||||||
|   | |||||||
| @@ -97,6 +97,7 @@ struct ntlmv2_key { | |||||||
| extern struct ntlm_server_interface ntlmsspi_kdc_digest; | extern struct ntlm_server_interface ntlmsspi_kdc_digest; | ||||||
|  |  | ||||||
| typedef struct ntlm_cred { | typedef struct ntlm_cred { | ||||||
|  |     gss_cred_usage_t usage; | ||||||
|     char *username; |     char *username; | ||||||
|     char *domain; |     char *domain; | ||||||
|     struct ntlm_buf key; |     struct ntlm_buf key; | ||||||
| @@ -128,7 +129,8 @@ typedef struct { | |||||||
| } *ntlm_ctx; | } *ntlm_ctx; | ||||||
|  |  | ||||||
| typedef struct { | typedef struct { | ||||||
|     char domain[1]; |     char *user; | ||||||
|  |     char *domain; | ||||||
| } *ntlm_name; | } *ntlm_name; | ||||||
|  |  | ||||||
| #include <ntlm/ntlm-private.h> | #include <ntlm/ntlm-private.h> | ||||||
|   | |||||||
| @@ -43,8 +43,11 @@ OM_uint32 _gss_ntlm_release_name | |||||||
|     if (minor_status) |     if (minor_status) | ||||||
| 	*minor_status = 0; | 	*minor_status = 0; | ||||||
|     if (input_name) { |     if (input_name) { | ||||||
| 	free(*input_name); | 	ntlm_name n = (ntlm_name)*input_name; | ||||||
| 	*input_name = GSS_C_NO_NAME; | 	*input_name = GSS_C_NO_NAME; | ||||||
|  | 	free(n->user); | ||||||
|  | 	free(n->domain); | ||||||
|  | 	free(n); | ||||||
|     } |     } | ||||||
|     return GSS_S_COMPLETE; |     return GSS_S_COMPLETE; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Love Hörnquist Åstrand
					Love Hörnquist Åstrand