Use gss oid_set functions from mechglue

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20688 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-05-17 18:44:31 +00:00
parent b2684d8ed2
commit ee246ab9ac
12 changed files with 34 additions and 261 deletions

View File

@@ -301,8 +301,8 @@ OM_uint32 _gsskrb5_acquire_cred
if (desired_mechs) { if (desired_mechs) {
int present = 0; int present = 0;
ret = _gsskrb5_test_oid_set_member(minor_status, GSS_KRB5_MECHANISM, ret = gss_test_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
desired_mechs, &present); desired_mechs, &present);
if (ret) if (ret)
return ret; return ret;
if (!present) { if (!present) {
@@ -352,16 +352,16 @@ OM_uint32 _gsskrb5_acquire_cred
return (ret); return (ret);
} }
} }
ret = _gsskrb5_create_empty_oid_set(minor_status, &handle->mechanisms); ret = gss_create_empty_oid_set(minor_status, &handle->mechanisms);
if (ret == GSS_S_COMPLETE) if (ret == GSS_S_COMPLETE)
ret = _gsskrb5_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM, ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
&handle->mechanisms); &handle->mechanisms);
if (ret == GSS_S_COMPLETE) if (ret == GSS_S_COMPLETE)
ret = _gsskrb5_inquire_cred(minor_status, (gss_cred_id_t)handle, ret = _gsskrb5_inquire_cred(minor_status, (gss_cred_id_t)handle,
NULL, time_rec, NULL, actual_mechs); NULL, time_rec, NULL, actual_mechs);
if (ret != GSS_S_COMPLETE) { if (ret != GSS_S_COMPLETE) {
if (handle->mechanisms != NULL) if (handle->mechanisms != NULL)
_gsskrb5_release_oid_set(NULL, &handle->mechanisms); gss_release_oid_set(NULL, &handle->mechanisms);
HEIMDAL_MUTEX_destroy(&handle->cred_id_mutex); HEIMDAL_MUTEX_destroy(&handle->cred_id_mutex);
krb5_free_principal(context, handle->principal); krb5_free_principal(context, handle->principal);
free(handle); free(handle);

View File

@@ -204,12 +204,12 @@ OM_uint32 _gsskrb5_add_cred (
} }
} }
} }
ret = _gsskrb5_create_empty_oid_set(minor_status, &handle->mechanisms); ret = gss_create_empty_oid_set(minor_status, &handle->mechanisms);
if (ret) if (ret)
goto failure; goto failure;
ret = _gsskrb5_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM, ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
&handle->mechanisms); &handle->mechanisms);
if (ret) if (ret)
goto failure; goto failure;
} }
@@ -243,7 +243,7 @@ OM_uint32 _gsskrb5_add_cred (
if (handle->ccache) if (handle->ccache)
krb5_cc_destroy(context, handle->ccache); krb5_cc_destroy(context, handle->ccache);
if (handle->mechanisms) if (handle->mechanisms)
_gsskrb5_release_oid_set(NULL, &handle->mechanisms); gss_release_oid_set(NULL, &handle->mechanisms);
free(handle); free(handle);
} }
if (output_cred_handle) if (output_cred_handle)

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "krb5/gsskrb5_locl.h"
RCSID("$Id$");
OM_uint32 _gsskrb5_add_oid_set_member (
OM_uint32 * minor_status,
const gss_OID member_oid,
gss_OID_set * oid_set
)
{
gss_OID tmp;
size_t n;
OM_uint32 res;
int present;
res = _gsskrb5_test_oid_set_member(minor_status, member_oid,
*oid_set, &present);
if (res != GSS_S_COMPLETE)
return res;
if (present) {
*minor_status = 0;
return GSS_S_COMPLETE;
}
n = (*oid_set)->count + 1;
tmp = realloc ((*oid_set)->elements, n * sizeof(gss_OID_desc));
if (tmp == NULL) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
(*oid_set)->elements = tmp;
(*oid_set)->count = n;
(*oid_set)->elements[n-1] = *member_oid;
*minor_status = 0;
return GSS_S_COMPLETE;
}

View File

@@ -166,10 +166,10 @@ _gsskrb5_import_cred(OM_uint32 *minor_status,
if (id || keytab) { if (id || keytab) {
ret = _gsskrb5_create_empty_oid_set(minor_status, &handle->mechanisms); ret = gss_create_empty_oid_set(minor_status, &handle->mechanisms);
if (ret == GSS_S_COMPLETE) if (ret == GSS_S_COMPLETE)
ret = _gsskrb5_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM, ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
&handle->mechanisms); &handle->mechanisms);
if (ret != GSS_S_COMPLETE) { if (ret != GSS_S_COMPLETE) {
kret = *minor_status; kret = *minor_status;
goto out; goto out;

View File

@@ -1,52 +0,0 @@
/*
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "krb5/gsskrb5_locl.h"
RCSID("$Id$");
OM_uint32 _gsskrb5_create_empty_oid_set (
OM_uint32 * minor_status,
gss_OID_set * oid_set
)
{
*oid_set = malloc(sizeof(**oid_set));
if (*oid_set == NULL) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
(*oid_set)->count = 0;
(*oid_set)->elements = NULL;
*minor_status = 0;
return GSS_S_COMPLETE;
}

View File

@@ -42,14 +42,13 @@ OM_uint32 _gsskrb5_indicate_mechs
{ {
OM_uint32 ret, junk; OM_uint32 ret, junk;
ret = _gsskrb5_create_empty_oid_set(minor_status, mech_set); ret = gss_create_empty_oid_set(minor_status, mech_set);
if (ret) if (ret)
return ret; return ret;
ret = _gsskrb5_add_oid_set_member(minor_status, ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM, mech_set);
GSS_KRB5_MECHANISM, mech_set);
if (ret) { if (ret) {
_gsskrb5_release_oid_set(&junk, mech_set); gss_release_oid_set(&junk, mech_set);
return ret; return ret;
} }

View File

@@ -152,17 +152,17 @@ OM_uint32 _gsskrb5_inquire_cred
} }
if (mechanisms != NULL) { if (mechanisms != NULL) {
ret = _gsskrb5_create_empty_oid_set(minor_status, mechanisms); ret = gss_create_empty_oid_set(minor_status, mechanisms);
if (ret) if (ret)
goto out; goto out;
if (acred) if (acred)
ret = _gsskrb5_add_oid_set_member(minor_status, ret = gss_add_oid_set_member(minor_status,
&acred->mechanisms->elements[0], &acred->mechanisms->elements[0],
mechanisms); mechanisms);
if (ret == GSS_S_COMPLETE && icred) if (ret == GSS_S_COMPLETE && icred)
ret = _gsskrb5_add_oid_set_member(minor_status, ret = gss_add_oid_set_member(minor_status,
&icred->mechanisms->elements[0], &icred->mechanisms->elements[0],
mechanisms); mechanisms);
if (ret) if (ret)
goto out; goto out;
} }

View File

@@ -43,15 +43,15 @@ OM_uint32 _gsskrb5_inquire_mechs_for_name (
{ {
OM_uint32 ret; OM_uint32 ret;
ret = _gsskrb5_create_empty_oid_set(minor_status, mech_types); ret = gss_create_empty_oid_set(minor_status, mech_types);
if (ret) if (ret)
return ret; return ret;
ret = _gsskrb5_add_oid_set_member(minor_status, ret = gss_add_oid_set_member(minor_status,
GSS_KRB5_MECHANISM, GSS_KRB5_MECHANISM,
mech_types); mech_types);
if (ret) if (ret)
_gsskrb5_release_oid_set(NULL, mech_types); gss_release_oid_set(NULL, mech_types);
return ret; return ret;
} }

View File

@@ -61,20 +61,20 @@ OM_uint32 _gsskrb5_inquire_names_for_mech (
return GSS_S_BAD_MECH; return GSS_S_BAD_MECH;
} }
ret = _gsskrb5_create_empty_oid_set(minor_status, name_types); ret = gss_create_empty_oid_set(minor_status, name_types);
if (ret != GSS_S_COMPLETE) if (ret != GSS_S_COMPLETE)
return ret; return ret;
for (i = 0; name_list[i] != NULL; i++) { for (i = 0; name_list[i] != NULL; i++) {
ret = _gsskrb5_add_oid_set_member(minor_status, ret = gss_add_oid_set_member(minor_status,
*(name_list[i]), *(name_list[i]),
name_types); name_types);
if (ret != GSS_S_COMPLETE) if (ret != GSS_S_COMPLETE)
break; break;
} }
if (ret != GSS_S_COMPLETE) if (ret != GSS_S_COMPLETE)
_gsskrb5_release_oid_set(NULL, name_types); gss_release_oid_set(NULL, name_types);
return GSS_S_COMPLETE; return GSS_S_COMPLETE;
} }

View File

@@ -67,7 +67,7 @@ OM_uint32 _gsskrb5_release_cred
else else
krb5_cc_close(context, cred->ccache); krb5_cc_close(context, cred->ccache);
} }
_gsskrb5_release_oid_set(NULL, &cred->mechanisms); gss_release_oid_set(NULL, &cred->mechanisms);
if (cred->enctypes) if (cred->enctypes)
free(cred->enctypes); free(cred->enctypes);
HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex); HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex);

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) 1997 - 2000, 2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "krb5/gsskrb5_locl.h"
RCSID("$Id$");
OM_uint32 _gsskrb5_release_oid_set
(OM_uint32 * minor_status,
gss_OID_set * set
)
{
if (minor_status)
*minor_status = 0;
free ((*set)->elements);
free (*set);
*set = GSS_C_NO_OID_SET;
return GSS_S_COMPLETE;
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright (c) 1997, 2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "krb5/gsskrb5_locl.h"
RCSID("$Id$");
OM_uint32 _gsskrb5_test_oid_set_member
(OM_uint32 * minor_status,
const gss_OID member,
const gss_OID_set set,
int * present
)
{
size_t i;
*minor_status = 0;
*present = 0;
for (i = 0; i < set->count; ++i)
if (gss_oid_equal(member, &set->elements[i]) != 0) {
*present = 1;
break;
}
return GSS_S_COMPLETE;
}