diff options
| author | Alexandra Ellwood <lxs@mit.edu> | 2008-10-24 19:46:41 +0000 |
|---|---|---|
| committer | Alexandra Ellwood <lxs@mit.edu> | 2008-10-24 19:46:41 +0000 |
| commit | 4d901a092a69a69be251131174166fc661d13633 (patch) | |
| tree | dc1227f213605bc27561acdf4005b74df65f7b0b /src/kim | |
| parent | 9d3a0fa806297b18967f2108c637e65c6904987c (diff) | |
| download | krb5-4d901a092a69a69be251131174166fc661d13633.tar.gz krb5-4d901a092a69a69be251131174166fc661d13633.tar.xz krb5-4d901a092a69a69be251131174166fc661d13633.zip | |
krb5_build_principal_va does not allocate krb5_principal
krb5_build_principal_va does not allocate the outer krb5_principal,
making it useless for generating krb5_principals which can be freed
with krb5_free_principal. Added krb5_build_principal_alloc_va which
allocates the krb5_principal.
Added krb5int_build_principal_alloc_va which is used by KIM to avoid
code duplication. KIM's kim_identity_create_from_components takes
the first component as an argument because principals with no
components cannot be represented with the KIM UI. Modified KIM
to use this new API.
ticket: new
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20918 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kim')
| -rw-r--r-- | src/kim/lib/kim_identity.c | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/src/kim/lib/kim_identity.c b/src/kim/lib/kim_identity.c index 834b8d614..6592d09c8 100644 --- a/src/kim/lib/kim_identity.c +++ b/src/kim/lib/kim_identity.c @@ -24,8 +24,8 @@ * or implied warranty. */ +#include "k5-int.h" #include <krb5.h> -#include <gssapi/gssapi.h> #include "kim_private.h" /* ------------------------------------------------------------------------ */ @@ -110,7 +110,6 @@ kim_error kim_identity_create_from_components (kim_identity *out_identity, { kim_error err = KIM_NO_ERROR; kim_identity identity = NULL; - krb5_principal_data principal_data; /* allocated by KIM so can't be returned */ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err && !in_realm ) { err = check_error (KIM_NULL_PARAMETER_ERR); } @@ -126,64 +125,23 @@ kim_error kim_identity_create_from_components (kim_identity *out_identity, if (!err) { va_list args; - kim_count component_count = 1; - + va_start (args, in_1st_component); - while (va_arg (args, kim_string)) { component_count++; } + err = krb5_error (identity->context, + krb5int_build_principal_alloc_va (identity->context, + &identity->principal, + strlen(in_realm), + in_realm, + in_1st_component, + args)); va_end (args); - - principal_data.length = component_count; - principal_data.data = (krb5_data *) malloc (component_count * sizeof (krb5_data)); - if (!principal_data.data) { err = KIM_OUT_OF_MEMORY_ERR; } } - - if (!err) { - va_list args; - krb5_int32 i; - - krb5_princ_set_realm_length (context, &principal_data, strlen (in_realm)); - krb5_princ_set_realm_data (context, &principal_data, (char *) in_realm); - - va_start (args, in_1st_component); - for (i = 0; !err && (i < principal_data.length); i++) { - kim_string component = NULL; - if (i == 0) { - err = kim_string_copy (&component, in_1st_component); - } else { - err = kim_string_copy (&component, va_arg (args, kim_string)); - } - - if (!err) { - principal_data.data[i].data = (char *) component; - principal_data.data[i].length = strlen (component); - } - } - va_end (args); - } - - if (!err) { - /* make a copy that has actually been allocated by the krb5 - * library so krb5_free_principal can be called on it */ - err = krb5_error (identity->context, - krb5_copy_principal (identity->context, - &principal_data, - &identity->principal)); - } - + if (!err) { *out_identity = identity; identity = NULL; } - if (principal_data.data) { - krb5_int32 i; - - for (i = 0; i < principal_data.length; i++) { - kim_string component = principal_data.data[i].data; - kim_string_free (&component); - } - free (principal_data.data); - } kim_identity_free (&identity); return check_error (err); |
