Bug fixes, cleanup, compiler warnings, restructure code.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17700 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-06-28 09:00:26 +00:00
parent 534d628c29
commit d3f8f8e122
47 changed files with 308 additions and 785 deletions

View File

@@ -24,9 +24,12 @@
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libgssapi/context.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
* $Id$
*/
#include <gssapi_mech.h>
struct _gss_context {
struct _gss_mech_switch *gc_mech;
gssapi_mech_interface gc_mech;
gss_ctx_id_t gc_ctx;
};

View File

@@ -24,13 +24,14 @@
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libgssapi/cred.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
* $Id$
*/
#include <sys/queue.h>
struct _gss_mechanism_cred {
SLIST_ENTRY(_gss_mechanism_cred) gmc_link;
struct _gss_mech_switch *gmc_mech; /* mechanism ops for MC */
gssapi_mech_interface gmc_mech; /* mechanism ops for MC */
gss_OID gmc_mech_oid; /* mechanism oid for MC */
gss_cred_id_t gmc_cred; /* underlying MC */
};

View File

@@ -26,14 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_accept_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "context.h"
#include "cred.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle,
@@ -48,7 +42,7 @@ OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
gss_cred_id_t *delegated_cred_handle)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
struct _gss_cred *cred = (struct _gss_cred *) acceptor_cred_handle;
struct _gss_mechanism_cred *mc;
@@ -133,7 +127,7 @@ OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
return (GSS_S_DEFECTIVE_TOKEN);
}
memset(ctx, 0, sizeof(struct _gss_context));
m = ctx->gc_mech = _gss_find_mech_switch(&mech_oid);
m = ctx->gc_mech = __gss_get_mechanism(&mech_oid);
if (!m) {
free(ctx);
return (GSS_S_BAD_MECH);
@@ -191,28 +185,28 @@ OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
m->gm_release_cred(minor_status, &delegated_mc);
*ret_flags &= ~GSS_C_DELEG_FLAG;
} else {
struct _gss_cred *cred;
struct _gss_mechanism_cred *mc;
struct _gss_cred *dcred;
struct _gss_mechanism_cred *dmc;
cred = malloc(sizeof(struct _gss_cred));
if (!cred) {
dcred = malloc(sizeof(struct _gss_cred));
if (!dcred) {
*minor_status = ENOMEM;
return (GSS_S_FAILURE);
}
mc = malloc(sizeof(struct _gss_mechanism_cred));
if (!mc) {
free(cred);
dmc = malloc(sizeof(struct _gss_mechanism_cred));
if (!dmc) {
free(dcred);
*minor_status = ENOMEM;
return (GSS_S_FAILURE);
}
m->gm_inquire_cred(minor_status, delegated_mc,
0, 0, &cred->gc_usage, 0);
mc->gmc_mech = m;
mc->gmc_mech_oid = &m->gm_mech_oid;
mc->gmc_cred = delegated_mc;
SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
0, 0, &dcred->gc_usage, 0);
dmc->gmc_mech = m;
dmc->gmc_mech_oid = &m->gm_mech_oid;
dmc->gmc_cred = delegated_mc;
SLIST_INSERT_HEAD(&cred->gc_mc, dmc, gmc_link);
*delegated_cred_handle = (gss_cred_id_t) cred;
*delegated_cred_handle = (gss_cred_id_t) dcred;
}
}

View File

@@ -26,13 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_acquire_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "cred.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_acquire_cred(OM_uint32 *minor_status,
@@ -48,11 +43,10 @@ gss_acquire_cred(OM_uint32 *minor_status,
gss_OID_set mechs = desired_mechs;
gss_OID_set_desc set;
struct _gss_name *name = (struct _gss_name *) desired_name;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_cred *cred;
struct _gss_mechanism_cred *mc;
struct _gss_mechanism_name *mn;
OM_uint32 min_time, time;
OM_uint32 min_time, cred_time;
int i;
/*
@@ -98,7 +92,9 @@ gss_acquire_cred(OM_uint32 *minor_status,
set.count = 1;
min_time = GSS_C_INDEFINITE;
for (i = 0; i < mechs->count; i++) {
m = _gss_find_mech_switch(&mechs->elements[i]);
struct _gss_mechanism_name *mn = NULL;
m = __gss_get_mechanism(&mechs->elements[i]);
if (!m)
continue;
@@ -123,13 +119,13 @@ gss_acquire_cred(OM_uint32 *minor_status,
(desired_name != GSS_C_NO_NAME
? mn->gmn_name : GSS_C_NO_NAME),
time_req, &set, cred_usage,
&mc->gmc_cred, NULL, &time);
&mc->gmc_cred, NULL, &cred_time);
if (major_status) {
free(mc);
continue;
}
if (time < min_time)
min_time = time;
if (cred_time < min_time)
min_time = cred_time;
if (actual_mechs) {
major_status = gss_add_oid_set_member(minor_status,

View File

@@ -26,18 +26,14 @@
* $FreeBSD: src/lib/libgssapi/gss_add_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <errno.h>
#include "mech_switch.h"
#include "cred.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
static struct _gss_mechanism_cred *
_gss_copy_cred(struct _gss_mechanism_cred *mc)
{
struct _gss_mechanism_cred *new_mc;
struct _gss_mech_switch *m = mc->gmc_mech;
gssapi_mech_interface m = mc->gmc_mech;
OM_uint32 major_status, minor_status;
gss_name_t name;
gss_cred_id_t cred;
@@ -85,15 +81,12 @@ gss_add_cred(OM_uint32 *minor_status,
OM_uint32 *acceptor_time_rec)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
gss_OID_set_desc set;
struct _gss_name *name = (struct _gss_name *) desired_name;
gssapi_mech_interface m;
struct _gss_cred *cred = (struct _gss_cred *) input_cred_handle;
struct _gss_cred *new_cred;
struct _gss_mechanism_cred *mc, *target_mc, *copy_mc;
struct _gss_mechanism_name *mn;
OM_uint32 min_time, time, junk;
int i;
OM_uint32 junk;
*output_cred_handle = 0;
*minor_status = 0;
@@ -115,7 +108,7 @@ gss_add_cred(OM_uint32 *minor_status,
target_mc = 0;
if (cred) {
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
if (_gss_oid_equal(mc->gmc_mech, desired_mech)) {
if (gss_oid_equal(mc->gmc_mech_oid, desired_mech)) {
target_mc = mc;
}
copy_mc = _gss_copy_cred(mc);
@@ -142,7 +135,7 @@ gss_add_cred(OM_uint32 *minor_status,
mn = 0;
}
m = _gss_find_mech_switch(desired_mech);
m = __gss_get_mechanism(desired_mech);
mc = malloc(sizeof(struct _gss_mechanism_cred));
if (!mc) {

View File

@@ -26,9 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_add_oid_set_member.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_add_oid_set_member(OM_uint32 *minor_status,

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_canonicalize_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_canonicalize_name(OM_uint32 *minor_status,
@@ -42,7 +38,7 @@ gss_canonicalize_name(OM_uint32 *minor_status,
OM_uint32 major_status;
struct _gss_name *name = (struct _gss_name *) input_name;
struct _gss_mechanism_name *mn;
struct _gss_mech_switch *m = _gss_find_mech_switch(mech_type);
gssapi_mech_interface m = __gss_get_mechanism(mech_type);
gss_name_t new_canonical_name;
*minor_status = 0;

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_compare_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_compare_name(OM_uint32 *minor_status,
@@ -47,7 +45,7 @@ gss_compare_name(OM_uint32 *minor_status,
*/
if (name1->gn_value.value && name2->gn_value.value) {
*name_equal = 1;
if (!_gss_oid_equal(name1->gn_type, name2->gn_type)) {
if (!gss_oid_equal(&name1->gn_type, &name2->gn_type)) {
*name_equal = 0;
} else if (name1->gn_value.length != name2->gn_value.length ||
memcmp(name1->gn_value.value, name1->gn_value.value,

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_context_time.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_context_time(OM_uint32 *minor_status,
@@ -37,7 +35,7 @@ gss_context_time(OM_uint32 *minor_status,
OM_uint32 *time_rec)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_context_time(minor_status, ctx->gc_ctx, time_rec));
}

View File

@@ -26,9 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_create_empty_oid_set.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_create_empty_oid_set(OM_uint32 *minor_status,

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_delete_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_delete_sec_context(OM_uint32 *minor_status,

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_display_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_display_name(OM_uint32 *minor_status,

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_display_status.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <string.h>
#include "mech_switch.h"
#include "mech_locl.h"
RCSID("$Id$");
struct _gss_status_desc {
OM_uint32 gs_status;
@@ -37,28 +35,28 @@ struct _gss_status_desc {
};
static struct _gss_status_desc _gss_status_descs[] = {
GSS_S_BAD_MECH, "An unsupported mechanism was requested",
GSS_S_BAD_NAME, "An invalid name was supplied",
GSS_S_BAD_NAMETYPE, "A supplied name was of an unsupported type",
GSS_S_BAD_BINDINGS, "Incorrect channel bindings were supplied",
GSS_S_BAD_STATUS, "An invalid status code was supplied",
GSS_S_BAD_MIC, "A token had an invalid MIC",
GSS_S_NO_CRED, "No credentials were supplied, or the "
"credentials were unavailable or inaccessible",
GSS_S_NO_CONTEXT, "No context has been established",
GSS_S_DEFECTIVE_TOKEN, "A token was invalid",
GSS_S_DEFECTIVE_CREDENTIAL, "A credential was invalid",
GSS_S_CREDENTIALS_EXPIRED, "The referenced credentials have expired",
GSS_S_CONTEXT_EXPIRED, "The context has expired",
GSS_S_FAILURE, "Miscellaneous failure",
GSS_S_BAD_QOP, "The quality-of-protection requested could "
"not be provided",
GSS_S_UNAUTHORIZED, "The operation is forbidden by local security "
"policy",
GSS_S_UNAVAILABLE, "The operation or option is unavailable",
GSS_S_DUPLICATE_ELEMENT, "The requested credential element already "
"exists",
GSS_S_NAME_NOT_MN, "The provided name was not a mechanism name"
{ GSS_S_BAD_MECH, "An unsupported mechanism was requested"},
{ GSS_S_BAD_NAME, "An invalid name was supplied"},
{ GSS_S_BAD_NAMETYPE, "A supplied name was of an unsupported type"},
{ GSS_S_BAD_BINDINGS, "Incorrect channel bindings were supplied"},
{ GSS_S_BAD_STATUS, "An invalid status code was supplied"},
{ GSS_S_BAD_MIC, "A token had an invalid MIC"},
{ GSS_S_NO_CRED, "No credentials were supplied, or the "
"credentials were unavailable or inaccessible"},
{ GSS_S_NO_CONTEXT, "No context has been established"},
{ GSS_S_DEFECTIVE_TOKEN,"A token was invalid"},
{ GSS_S_DEFECTIVE_CREDENTIAL, "A credential was invalid"},
{ GSS_S_CREDENTIALS_EXPIRED, "The referenced credentials have expired"},
{ GSS_S_CONTEXT_EXPIRED, "The context has expired"},
{ GSS_S_FAILURE, "Miscellaneous failure"},
{ GSS_S_BAD_QOP, "The quality-of-protection requested could "
"not be provided"},
{ GSS_S_UNAUTHORIZED, "The operation is forbidden by local security "
"policy"},
{ GSS_S_UNAVAILABLE, "The operation or option is unavailable"},
{ GSS_S_DUPLICATE_ELEMENT, "The requested credential element already "
"exists"},
{ GSS_S_NAME_NOT_MN, "The provided name was not a mechanism name"}
};
#define _gss_status_desc_count \
sizeof(_gss_status_descs) / sizeof(_gss_status_descs[0])
@@ -73,7 +71,6 @@ gss_display_status(OM_uint32 *minor_status,
gss_buffer_t status_string)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
int i;
const char *message;
@@ -93,11 +90,10 @@ gss_display_status(OM_uint32 *minor_status,
* Fall through to attempt to get some underlying
* implementation to describe the value.
*/
case GSS_C_MECH_CODE:
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
if (mech_type &&
!_gss_oid_equal(&m->gm_mech_oid, mech_type))
continue;
case GSS_C_MECH_CODE: {
gssapi_mech_interface m;
m = __gss_get_mechanism(mech_type);
if (m) {
major_status = m->gm_display_status(minor_status,
status_value, status_type, mech_type,
message_content, status_string);
@@ -105,6 +101,7 @@ gss_display_status(OM_uint32 *minor_status,
return (GSS_S_COMPLETE);
}
}
}
return (GSS_S_BAD_STATUS);
}

View File

@@ -26,11 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_duplicate_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32 gss_duplicate_name(OM_uint32 *minor_status,
const gss_name_t src_name,

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_export_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_export_name(OM_uint32 *minor_status,

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_export_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_export_sec_context(OM_uint32 *minor_status,
@@ -40,7 +36,7 @@ gss_export_sec_context(OM_uint32 *minor_status,
{
OM_uint32 major_status;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
gss_buffer_desc buf;
major_status = m->gm_export_sec_context(minor_status,

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_get_mic.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_get_mic(OM_uint32 *minor_status,
@@ -39,7 +37,7 @@ gss_get_mic(OM_uint32 *minor_status,
gss_buffer_t message_token)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req,
message_buffer, message_token));

View File

@@ -26,13 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_import_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "utils.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
static OM_uint32
_gss_import_export_name(OM_uint32 *minor_status,
@@ -44,9 +39,8 @@ _gss_import_export_name(OM_uint32 *minor_status,
size_t len = input_name_buffer->length;
size_t t;
gss_OID_desc mech_oid;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_name *name;
struct _gss_mechanism_name *mn;
gss_name_t new_canonical_name;
*minor_status = 0;
@@ -116,7 +110,7 @@ _gss_import_export_name(OM_uint32 *minor_status,
if (len != t)
return (GSS_S_BAD_NAME);
m = _gss_find_mech_switch(&mech_oid);
m = __gss_get_mechanism(&mech_oid);
if (!m)
return (GSS_S_BAD_MECH);
@@ -168,7 +162,7 @@ gss_import_name(OM_uint32 *minor_status,
* the mechanism and then import it as an MN. See RFC 2743
* section 3.2 for a description of the format.
*/
if (_gss_oid_equal(name_type, GSS_C_NT_EXPORT_NAME)) {
if (gss_oid_equal(name_type, GSS_C_NT_EXPORT_NAME)) {
return _gss_import_export_name(minor_status,
input_name_buffer, output_name);
}
@@ -178,13 +172,13 @@ gss_import_name(OM_uint32 *minor_status,
* should figure out the list of supported name types using
* gss_inquire_names_for_mech.
*/
if (!_gss_oid_equal(name_type, GSS_C_NT_USER_NAME)
&& !_gss_oid_equal(name_type, GSS_C_NT_MACHINE_UID_NAME)
&& !_gss_oid_equal(name_type, GSS_C_NT_STRING_UID_NAME)
&& !_gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE_X)
&& !_gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE)
&& !_gss_oid_equal(name_type, GSS_C_NT_ANONYMOUS)
&& !_gss_oid_equal(name_type, GSS_KRB5_NT_PRINCIPAL_NAME)) {
if (!gss_oid_equal(name_type, GSS_C_NT_USER_NAME)
&& !gss_oid_equal(name_type, GSS_C_NT_MACHINE_UID_NAME)
&& !gss_oid_equal(name_type, GSS_C_NT_STRING_UID_NAME)
&& !gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE_X)
&& !gss_oid_equal(name_type, GSS_C_NT_HOSTBASED_SERVICE)
&& !gss_oid_equal(name_type, GSS_C_NT_ANONYMOUS)
&& !gss_oid_equal(name_type, GSS_KRB5_NT_PRINCIPAL_NAME)) {
*minor_status = 0;
*output_name = 0;
return (GSS_S_BAD_NAMETYPE);

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_import_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_import_sec_context(OM_uint32 *minor_status,
@@ -39,7 +35,7 @@ gss_import_sec_context(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_context *ctx;
gss_OID_desc mech_oid;
gss_buffer_desc buf;
@@ -64,7 +60,7 @@ gss_import_sec_context(OM_uint32 *minor_status,
buf.length = len - 2 - mech_oid.length;
buf.value = p + 2 + mech_oid.length;
m = _gss_find_mech_switch(&mech_oid);
m = __gss_get_mechanism(&mech_oid);
if (!m)
return (GSS_S_DEFECTIVE_TOKEN);

View File

@@ -26,9 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_indicate_mechs.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_indicate_mechs(OM_uint32 *minor_status,
@@ -46,7 +45,7 @@ gss_indicate_mechs(OM_uint32 *minor_status,
return (major_status);
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
major_status = m->gm_indicate_mechs(minor_status, &set);
major_status = m->gm_mech.gm_indicate_mechs(minor_status, &set);
if (major_status)
continue;
for (i = 0; i < set->count; i++)

View File

@@ -26,21 +26,15 @@
* $FreeBSD: src/lib/libgssapi/gss_init_sec_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "cred.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_init_sec_context(OM_uint32 * minor_status,
const gss_cred_id_t initiator_cred_handle,
gss_ctx_id_t * context_handle,
const gss_name_t target_name,
const gss_OID mech_type,
const gss_OID input_mech_type,
OM_uint32 req_flags,
OM_uint32 time_req,
const gss_channel_bindings_t input_chan_bindings,
@@ -51,7 +45,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
OM_uint32 * time_rec)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_name *name = (struct _gss_name *) target_name;
struct _gss_mechanism_name *mn;
struct _gss_context *ctx = (struct _gss_context *) *context_handle;
@@ -59,6 +53,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
struct _gss_mechanism_cred *mc;
gss_cred_id_t cred_handle;
int allocated_ctx;
gss_OID mech_type = input_mech_type;
*minor_status = 0;
@@ -68,13 +63,16 @@ gss_init_sec_context(OM_uint32 * minor_status,
* sure we use the same mechanism switch as before.
*/
if (!ctx) {
if (mech_type == NULL)
mech_type = GSS_KRB5_MECHANISM;
ctx = malloc(sizeof(struct _gss_context));
if (!ctx) {
*minor_status = ENOMEM;
return (GSS_S_FAILURE);
}
memset(ctx, 0, sizeof(struct _gss_context));
m = ctx->gc_mech = _gss_find_mech_switch(mech_type);
m = ctx->gc_mech = __gss_get_mechanism(mech_type);
if (!m) {
free(ctx);
return (GSS_S_BAD_MECH);
@@ -82,6 +80,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
allocated_ctx = 1;
} else {
m = ctx->gc_mech;
mech_type = &ctx->gc_mech->gm_mech_oid;
allocated_ctx = 0;
}
@@ -96,7 +95,7 @@ gss_init_sec_context(OM_uint32 * minor_status,
cred_handle = GSS_C_NO_CREDENTIAL;
if (cred) {
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
if (_gss_oid_equal(mech_type, mc->gmc_mech_oid)) {
if (gss_oid_equal(mech_type, mc->gmc_mech_oid)) {
cred_handle = mc->gmc_cred;
break;
}

View File

@@ -26,11 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_inquire_context.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_inquire_context(OM_uint32 *minor_status,
@@ -45,7 +42,7 @@ gss_inquire_context(OM_uint32 *minor_status,
{
OM_uint32 major_status;
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
struct _gss_name *name;
gss_name_t src_mn, targ_mn;

View File

@@ -26,13 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_inquire_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "cred.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_inquire_cred(OM_uint32 *minor_status,
@@ -45,7 +40,6 @@ gss_inquire_cred(OM_uint32 *minor_status,
OM_uint32 major_status;
struct _gss_mech_switch *m;
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
struct _gss_mechanism_cred *mc;
struct _gss_name *name;
struct _gss_mechanism_name *mn;
OM_uint32 min_lifetime;
@@ -81,6 +75,8 @@ gss_inquire_cred(OM_uint32 *minor_status,
min_lifetime = GSS_C_INDEFINITE;
if (cred) {
struct _gss_mechanism_cred *mc;
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
gss_name_t mc_name;
OM_uint32 mc_lifetime;
@@ -118,7 +114,7 @@ gss_inquire_cred(OM_uint32 *minor_status,
gss_name_t mc_name;
OM_uint32 mc_lifetime;
major_status = m->gm_inquire_cred(minor_status,
major_status = m->gm_mech.gm_inquire_cred(minor_status,
GSS_C_NO_CREDENTIAL, &mc_name, &mc_lifetime,
cred_usage, NULL);
if (major_status)
@@ -128,16 +124,16 @@ gss_inquire_cred(OM_uint32 *minor_status,
mn = malloc(
sizeof(struct _gss_mechanism_name));
if (!mn) {
mc->gmc_mech->gm_release_name(
m->gm_mech.gm_release_name(
minor_status, &mc_name);
continue;
}
mn->gmn_mech = mc->gmc_mech;
mn->gmn_mech_oid = mc->gmc_mech_oid;
mn->gmn_mech = &m->gm_mech;
mn->gmn_mech_oid = &m->gm_mech_oid;
mn->gmn_name = mc_name;
SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
} else if (mc_name) {
mc->gmc_mech->gm_release_name(minor_status,
m->gm_mech.gm_release_name(minor_status,
&mc_name);
}

View File

@@ -26,11 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_inquire_cred_by_mech.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "cred.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_inquire_cred_by_mech(OM_uint32 *minor_status,
@@ -42,7 +39,7 @@ gss_inquire_cred_by_mech(OM_uint32 *minor_status,
gss_cred_usage_t *cred_usage)
{
OM_uint32 major_status;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_mechanism_cred *mcp;
gss_cred_id_t mc;
gss_name_t mn;
@@ -50,7 +47,7 @@ gss_inquire_cred_by_mech(OM_uint32 *minor_status,
*minor_status = 0;
m = _gss_find_mech_switch(mech_type);
m = __gss_get_mechanism(mech_type);
if (!m)
return (GSS_S_NO_CRED);

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_inquire_mechs_for_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_inquire_mechs_for_name(OM_uint32 *minor_status,

View File

@@ -26,9 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_inquire_names_for_mech.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_inquire_names_for_mech(OM_uint32 *minor_status,
@@ -36,7 +35,7 @@ gss_inquire_names_for_mech(OM_uint32 *minor_status,
gss_OID_set *name_types)
{
OM_uint32 major_status;
struct _gss_mech_switch *m = _gss_find_mech_switch(mechanism);
gssapi_mech_interface m = __gss_get_mechanism(mechanism);
*minor_status = 0;
if (!m)

View File

@@ -26,18 +26,72 @@
* $FreeBSD: src/lib/libgssapi/gss_krb5.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_locl.h"
RCSID("$Id$");
#include "mech_switch.h"
#include "context.h"
#include "cred.h"
#include <krb5.h>
OM_uint32
gss_krb5_copy_ccache(OM_uint32 *minor_status,
gss_cred_id_t cred,
krb5_ccache out)
{
krb5_context context;
OM_uint32 ret;
krb5_error_code kret;
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
const char *prefix;
ret = gss_inquire_cred_by_oid(minor_status,
cred,
GSS_KRB5_COPY_CCACHE_X,
&data_set);
if (ret) {
return ret;
}
if (data_set == GSS_C_NO_BUFFER_SET ||
data_set->count != 2) {
gss_release_buffer_set(minor_status, &data_set);
*minor_status = EINVAL;
return GSS_S_FAILURE;
}
prefix = (const char *)data_set->elements[0].value;
kret = krb5_init_context(&context);
if (out->ops == NULL) {
*minor_status = ENOENT;
gss_release_buffer_set(minor_status, &data_set);
return GSS_S_FAILURE;
}
out->ops = krb5_cc_get_prefix_ops(context, prefix);
krb5_free_context(context);
if (out->ops == NULL) {
*minor_status = ENOENT;
gss_release_buffer_set(minor_status, &data_set);
return GSS_S_FAILURE;
}
out->data.data = data_set->elements[1].value;
out->data.length = data_set->elements[1].length;
data_set->elements[1].value = NULL;
data_set->elements[1].length = 0;
data_set->count--;
gss_release_buffer_set(minor_status, &data_set);
return ret;
}
#if 0
OM_uint32
gsskrb5_register_acceptor_identity(const char *identity)
{
struct _gss_mech_switch *m;
gssapi_mech_interface m;
_gss_load_mech();
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
@@ -55,7 +109,7 @@ gss_krb5_copy_ccache(OM_uint32 *minor_status,
{
struct _gss_mechanism_cred *mcp;
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
*minor_status = 0;
@@ -74,7 +128,7 @@ gss_krb5_compat_des3_mic(OM_uint32 *minor_status,
gss_ctx_id_t context_handle, int flag)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
*minor_status = 0;
@@ -84,4 +138,5 @@ gss_krb5_compat_des3_mic(OM_uint32 *minor_status,
return (GSS_S_FAILURE);
}
#endif

View File

@@ -26,22 +26,14 @@
* $FreeBSD: src/lib/libgssapi/gss_mech_switch.c,v 1.2 2006/02/04 09:40:21 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <dlfcn.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mech_switch.h"
#include "utils.h"
#include "mech_locl.h"
RCSID("$Id$");
#ifndef _PATH_GSS_MECH
#define _PATH_GSS_MECH "/etc/gss/mech"
#endif
struct _gss_mech_switch_list _gss_mechs =
SLIST_HEAD_INITIALIZER(&_gss_mechs);
struct _gss_mech_switch_list _gss_mechs = { NULL } ;
gss_OID_set _gss_mech_oids;
/*
@@ -155,8 +147,8 @@ _gss_string_to_oid(const char* s, gss_OID oid)
#define SYM(name) \
do { \
m->gm_ ## name = dlsym(so, "gss_" #name); \
if (!m->gm_ ## name) { \
m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
if (!m->gm_mech.gm_ ## name) { \
fprintf(stderr, "can't find symbol gss_" #name "\n"); \
goto bad; \
} \
@@ -164,13 +156,29 @@ do { \
#define OPTSYM(name) \
do { \
m->gm_ ## name = dlsym(so, "gss_" #name); \
m->gm_mech.gm_ ## name = dlsym(so, "gss_" #name); \
} while (0)
#define OPTSYM2(symname, ourname) \
do { \
m->ourname = dlsym(so, #symname); \
} while (0)
/*
*
*/
static int
add_builtin(gssapi_mech_interface mech)
{
struct _gss_mech_switch *m;
OM_uint32 minor_status;
m = malloc(sizeof(*m));
if (m == NULL)
return 1;
m->gm_so = NULL;
m->gm_mech = *mech;
gss_add_oid_set_member(&minor_status,
&m->gm_mech.gm_mech_oid, &_gss_mech_oids);
SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
return 0;
}
/*
* Load the mechanisms file (/etc/gss/mech).
@@ -184,8 +192,6 @@ _gss_load_mech(void)
char *p;
char *name, *oid, *lib, *kobj;
struct _gss_mech_switch *m;
int count;
char **pp;
void *so;
if (SLIST_FIRST(&_gss_mechs))
@@ -196,13 +202,15 @@ _gss_load_mech(void)
if (major_status)
return;
add_builtin(__gss_krb5_initialize());
add_builtin(__gss_spnego_initialize());
fp = fopen(_PATH_GSS_MECH, "r");
if (!fp) {
perror(_PATH_GSS_MECH);
/* perror(_PATH_GSS_MECH); */
return;
}
count = 0;
while (fgets(buf, sizeof(buf), fp)) {
if (*buf == '#')
continue;
@@ -219,23 +227,23 @@ _gss_load_mech(void)
so = dlopen(lib, RTLD_LOCAL);
if (!so) {
fprintf(stderr, "dlopen: %s\n", dlerror());
/* fprintf(stderr, "dlopen: %s\n", dlerror()); */
continue;
}
m = malloc(sizeof(struct _gss_mech_switch));
m = malloc(sizeof(*m));
if (!m)
break;
m->gm_so = so;
if (_gss_string_to_oid(oid, &m->gm_mech_oid)) {
if (_gss_string_to_oid(oid, &m->gm_mech.gm_mech_oid)) {
free(m);
continue;
}
major_status = gss_add_oid_set_member(&minor_status,
&m->gm_mech_oid, &_gss_mech_oids);
&m->gm_mech.gm_mech_oid, &_gss_mech_oids);
if (major_status) {
free(m->gm_mech_oid.elements);
free(m->gm_mech.gm_mech_oid.elements);
free(m);
continue;
}
@@ -269,17 +277,14 @@ _gss_load_mech(void)
SYM(inquire_mechs_for_name);
SYM(canonicalize_name);
SYM(duplicate_name);
OPTSYM2(gsskrb5_register_acceptor_identity,
gm_krb5_register_acceptor_identity);
OPTSYM(krb5_copy_ccache);
OPTSYM(krb5_compat_des3_mic);
OPTSYM(inquire_cred_by_oid);
OPTSYM(inquire_sec_context_by_oid);
SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
count++;
continue;
bad:
free(m->gm_mech_oid.elements);
free(m->gm_mech.gm_mech_oid.elements);
free(m);
dlclose(so);
continue;
@@ -287,15 +292,15 @@ _gss_load_mech(void)
fclose(fp);
}
struct _gss_mech_switch *
_gss_find_mech_switch(gss_OID mech)
gssapi_mech_interface
__gss_get_mechanism(gss_OID mech)
{
struct _gss_mech_switch *m;
struct _gss_mech_switch *m;
_gss_load_mech();
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
if (_gss_oid_equal(&m->gm_mech_oid, mech))
return m;
if (gss_oid_equal(&m->gm_mech.gm_mech_oid, mech))
return &m->gm_mech;
}
return (0);
return NULL;
}

View File

@@ -26,165 +26,18 @@
* $FreeBSD: src/lib/libgssapi/gss_names.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
* "\x01\x02\x01\x01"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
* GSS_C_NT_USER_NAME should be initialized to point
* to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_USER_NAME_storage =
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"};
gss_OID GSS_C_NT_USER_NAME = &GSS_C_NT_USER_NAME_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
* "\x01\x02\x01\x02"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
* The constant GSS_C_NT_MACHINE_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_MACHINE_UID_NAME_storage =
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"};
gss_OID GSS_C_NT_MACHINE_UID_NAME = &GSS_C_NT_MACHINE_UID_NAME_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
* "\x01\x02\x01\x03"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
* The constant GSS_C_NT_STRING_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_STRING_UID_NAME_storage =
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"};
gss_OID GSS_C_NT_STRING_UID_NAME = &GSS_C_NT_STRING_UID_NAME_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
* corresponding to an object-identifier value of
* {iso(1) org(3) dod(6) internet(1) security(5)
* nametypes(6) gss-host-based-services(2)). The constant
* GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
* to that gss_OID_desc. This is a deprecated OID value, and
* implementations wishing to support hostbased-service names
* should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
* defined below, to identify such names;
* GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
* for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
* parameter, but should not be emitted by GSS-API
* implementations
*/
static gss_OID_desc GSS_C_NT_HOSTBASED_SERVICE_X_storage =
{6, (void *)"\x2b\x06\x01\x05\x06\x02"};
gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = &GSS_C_NT_HOSTBASED_SERVICE_X_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
* "\x01\x02\x01\x04"}, corresponding to an
* object-identifier value of {iso(1) member-body(2)
* Unites States(840) mit(113554) infosys(1) gssapi(2)
* generic(1) service_name(4)}. The constant
* GSS_C_NT_HOSTBASED_SERVICE should be initialized
* to point to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_HOSTBASED_SERVICE_storage =
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"};
gss_OID GSS_C_NT_HOSTBASED_SERVICE = &GSS_C_NT_HOSTBASED_SERVICE_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\01\x05\x06\x03"},
* corresponding to an object identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 3(gss-anonymous-name)}. The constant
* and GSS_C_NT_ANONYMOUS should be initialized to point
* to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_ANONYMOUS_storage =
{6, (void *)"\x2b\x06\01\x05\x06\x03"};
gss_OID GSS_C_NT_ANONYMOUS = &GSS_C_NT_ANONYMOUS_storage;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
* corresponding to an object-identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 4(gss-api-exported-name)}. The constant
* GSS_C_NT_EXPORT_NAME should be initialized to point
* to that gss_OID_desc.
*/
static gss_OID_desc GSS_C_NT_EXPORT_NAME_storage =
{6, (void *)"\x2b\x06\x01\x05\x06\x04"};
gss_OID GSS_C_NT_EXPORT_NAME = &GSS_C_NT_EXPORT_NAME_storage;
/*
* This name form shall be represented by the Object Identifier {iso(1)
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
* krb5(2) krb5_name(1)}. The recommended symbolic name for this type
* is "GSS_KRB5_NT_PRINCIPAL_NAME".
*/
static gss_OID_desc GSS_KRB5_NT_PRINCIPAL_NAME_storage =
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01"};
gss_OID GSS_KRB5_NT_PRINCIPAL_NAME = &GSS_KRB5_NT_PRINCIPAL_NAME_storage;
/*
* This name form shall be represented by the Object Identifier {iso(1)
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
* generic(1) user_name(1)}. The recommended symbolic name for this
* type is "GSS_KRB5_NT_USER_NAME".
*/
gss_OID GSS_KRB5_NT_USER_NAME = &GSS_C_NT_USER_NAME_storage;
/*
* This name form shall be represented by the Object Identifier {iso(1)
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
* generic(1) machine_uid_name(2)}. The recommended symbolic name for
* this type is "GSS_KRB5_NT_MACHINE_UID_NAME".
*/
gss_OID GSS_KRB5_NT_MACHINE_UID_NAME = &GSS_C_NT_MACHINE_UID_NAME_storage;
/*
* This name form shall be represented by the Object Identifier {iso(1)
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
* generic(1) string_uid_name(3)}. The recommended symbolic name for
* this type is "GSS_KRB5_NT_STRING_UID_NAME".
*/
gss_OID GSS_KRB5_NT_STRING_UID_NAME = &GSS_C_NT_STRING_UID_NAME_storage;
#include "mech_locl.h"
RCSID("$Id$");
struct _gss_mechanism_name *
_gss_find_mn(struct _gss_name *name, gss_OID mech)
{
OM_uint32 major_status, minor_status;
struct _gss_mech_switch *m;
gssapi_mech_interface m;
struct _gss_mechanism_name *mn;
SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
if (_gss_oid_equal(mech, mn->gmn_mech_oid))
if (gss_oid_equal(mech, mn->gmn_mech_oid))
break;
}
@@ -196,7 +49,7 @@ _gss_find_mn(struct _gss_name *name, gss_OID mech)
if (!name->gn_value.value)
return (0);
m = _gss_find_mech_switch(mech);
m = __gss_get_mechanism(mech);
if (!m)
return (0);
@@ -225,9 +78,8 @@ _gss_find_mn(struct _gss_name *name, gss_OID mech)
* Make a name from an MN.
*/
struct _gss_name *
_gss_make_name(struct _gss_mech_switch *m, gss_name_t new_mn)
_gss_make_name(gssapi_mech_interface m, gss_name_t new_mn)
{
OM_uint32 minor_status;
struct _gss_name *name;
struct _gss_mechanism_name *mn;

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_process_context_token.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_process_context_token(OM_uint32 *minor_status,
@@ -37,7 +35,7 @@ gss_process_context_token(OM_uint32 *minor_status,
const gss_buffer_t token_buffer)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_process_context_token(minor_status, ctx->gc_ctx,
token_buffer));

View File

@@ -26,7 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_release_buffer.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_release_buffer(OM_uint32 *minor_status,

View File

@@ -26,12 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_release_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "cred.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_release_cred(OM_uint32 *minor_status, gss_cred_id_t *cred_handle)

View File

@@ -26,19 +26,14 @@
* $FreeBSD: src/lib/libgssapi/gss_release_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_switch.h"
#include "name.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_release_name(OM_uint32 *minor_status,
gss_name_t *input_name)
{
struct _gss_name *name = (struct _gss_name *) *input_name;
struct _gss_mech_switch *m;
*minor_status = 0;
if (name) {

View File

@@ -26,9 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_release_oid_set.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_release_oid_set(OM_uint32 *minor_status,

View File

@@ -26,7 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_seal.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_seal(OM_uint32 *minor_status,

View File

@@ -26,7 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_sign.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_sign(OM_uint32 *minor_status,

View File

@@ -26,17 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_test_oid_set_member.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
static int
_gss_oid_equal(const gss_OID oid1, const gss_OID oid2)
{
if (oid1->length != oid2->length)
return (0);
if (memcmp(oid1->elements, oid2->elements, oid1->length))
return (0);
return (1);
}
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_test_oid_set_member(OM_uint32 *minor_status,
@@ -48,7 +39,7 @@ gss_test_oid_set_member(OM_uint32 *minor_status,
*present = 0;
for (i = 0; i < set->count; i++)
if (_gss_oid_equal(member, &set->elements[i]))
if (gss_oid_equal(member, &set->elements[i]))
*present = 1;
*minor_status = 0;

View File

@@ -26,7 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_unseal.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_unseal(OM_uint32 *minor_status,
@@ -39,5 +40,5 @@ gss_unseal(OM_uint32 *minor_status,
return (gss_unwrap(minor_status,
context_handle, input_message_buffer,
output_message_buffer, conf_state, qop_state));
output_message_buffer, conf_state, (gss_qop_t *)qop_state));
}

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_unwrap.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_unwrap(OM_uint32 *minor_status,
@@ -40,7 +38,7 @@ gss_unwrap(OM_uint32 *minor_status,
gss_qop_t *qop_state)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_unwrap(minor_status, ctx->gc_ctx,
input_message_buffer, output_message_buffer,

View File

@@ -26,21 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_utils.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include <stdlib.h>
#include <errno.h>
#include "utils.h"
int
_gss_oid_equal(const gss_OID oid1, const gss_OID oid2)
{
if (oid1->length != oid2->length)
return (0);
if (memcmp(oid1->elements, oid2->elements, oid1->length))
return (0);
return (1);
}
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
_gss_copy_oid(OM_uint32 *minor_status,

View File

@@ -26,7 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_verify.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_verify(OM_uint32 *minor_status,
@@ -37,5 +38,6 @@ gss_verify(OM_uint32 *minor_status,
{
return (gss_verify_mic(minor_status,
context_handle, message_buffer, token_buffer, qop_state));
context_handle, message_buffer, token_buffer,
(gss_qop_t *)qop_state));
}

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_verify_mic.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_verify_mic(OM_uint32 *minor_status,
@@ -39,7 +37,7 @@ gss_verify_mic(OM_uint32 *minor_status,
gss_qop_t *qop_state)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_verify_mic(minor_status, ctx->gc_ctx,
message_buffer, token_buffer, qop_state));

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_wrap.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_wrap(OM_uint32 *minor_status,
@@ -41,7 +39,7 @@ gss_wrap(OM_uint32 *minor_status,
gss_buffer_t output_message_buffer)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_wrap(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, input_message_buffer,

View File

@@ -26,10 +26,8 @@
* $FreeBSD: src/lib/libgssapi/gss_wrap_size_limit.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
*/
#include <gssapi/gssapi.h>
#include "mech_switch.h"
#include "context.h"
#include "mech_locl.h"
RCSID("$Id$");
OM_uint32
gss_wrap_size_limit(OM_uint32 *minor_status,
@@ -40,7 +38,7 @@ gss_wrap_size_limit(OM_uint32 *minor_status,
OM_uint32 *max_input_size)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
struct _gss_mech_switch *m = ctx->gc_mech;
gssapi_mech_interface m = ctx->gc_mech;
return (m->gm_wrap_size_limit(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, req_output_size, max_input_size));

View File

@@ -24,304 +24,20 @@
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libgssapi/mech_switch.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
* $Id$
*/
#include <sys/queue.h>
typedef OM_uint32 _gss_acquire_cred_t
(OM_uint32 *, /* minor_status */
const gss_name_t, /* desired_name */
OM_uint32, /* time_req */
const gss_OID_set, /* desired_mechs */
gss_cred_usage_t, /* cred_usage */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 * /* time_rec */
);
typedef OM_uint32 _gss_release_cred_t
(OM_uint32 *, /* minor_status */
gss_cred_id_t * /* cred_handle */
);
typedef OM_uint32 _gss_init_sec_context_t
(OM_uint32 *, /* minor_status */
const gss_cred_id_t, /* initiator_cred_handle */
gss_ctx_id_t *, /* context_handle */
const gss_name_t, /* target_name */
const gss_OID, /* mech_type */
OM_uint32, /* req_flags */
OM_uint32, /* time_req */
const gss_channel_bindings_t,
/* input_chan_bindings */
const gss_buffer_t, /* input_token */
gss_OID *, /* actual_mech_type */
gss_buffer_t, /* output_token */
OM_uint32 *, /* ret_flags */
OM_uint32 * /* time_rec */
);
typedef OM_uint32 _gss_accept_sec_context_t
(OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
const gss_cred_id_t, /* acceptor_cred_handle */
const gss_buffer_t, /* input_token_buffer */
const gss_channel_bindings_t,
/* input_chan_bindings */
gss_name_t *, /* src_name */
gss_OID *, /* mech_type */
gss_buffer_t, /* output_token */
OM_uint32 *, /* ret_flags */
OM_uint32 *, /* time_rec */
gss_cred_id_t * /* delegated_cred_handle */
);
typedef OM_uint32 _gss_process_context_token_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
const gss_buffer_t /* token_buffer */
);
typedef OM_uint32 _gss_delete_sec_context_t
(OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_buffer_t /* output_token */
);
typedef OM_uint32 _gss_context_time_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
OM_uint32 * /* time_rec */
);
typedef OM_uint32 _gss_get_mic_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
gss_qop_t, /* qop_req */
const gss_buffer_t, /* message_buffer */
gss_buffer_t /* message_token */
);
typedef OM_uint32 _gss_verify_mic_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
const gss_buffer_t, /* message_buffer */
const gss_buffer_t, /* token_buffer */
gss_qop_t * /* qop_state */
);
typedef OM_uint32 _gss_wrap_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
const gss_buffer_t, /* input_message_buffer */
int *, /* conf_state */
gss_buffer_t /* output_message_buffer */
);
typedef OM_uint32 _gss_unwrap_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
const gss_buffer_t, /* input_message_buffer */
gss_buffer_t, /* output_message_buffer */
int *, /* conf_state */
gss_qop_t * /* qop_state */
);
typedef OM_uint32 _gss_display_status_t
(OM_uint32 *, /* minor_status */
OM_uint32, /* status_value */
int, /* status_type */
const gss_OID, /* mech_type */
OM_uint32 *, /* message_context */
gss_buffer_t /* status_string */
);
typedef OM_uint32 _gss_indicate_mechs_t
(OM_uint32 *, /* minor_status */
gss_OID_set * /* mech_set */
);
typedef OM_uint32 _gss_compare_name_t
(OM_uint32 *, /* minor_status */
const gss_name_t, /* name1 */
const gss_name_t, /* name2 */
int * /* name_equal */
);
typedef OM_uint32 _gss_display_name_t
(OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_buffer_t, /* output_name_buffer */
gss_OID * /* output_name_type */
);
typedef OM_uint32 _gss_import_name_t
(OM_uint32 *, /* minor_status */
const gss_buffer_t, /* input_name_buffer */
const gss_OID, /* input_name_type */
gss_name_t * /* output_name */
);
typedef OM_uint32 _gss_export_name_t
(OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_buffer_t /* exported_name */
);
typedef OM_uint32 _gss_release_name_t
(OM_uint32 *, /* minor_status */
gss_name_t * /* input_name */
);
typedef OM_uint32 _gss_inquire_cred_t
(OM_uint32 *, /* minor_status */
const gss_cred_id_t, /* cred_handle */
gss_name_t *, /* name */
OM_uint32 *, /* lifetime */
gss_cred_usage_t *, /* cred_usage */
gss_OID_set * /* mechanisms */
);
typedef OM_uint32 _gss_inquire_context_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
gss_name_t *, /* src_name */
gss_name_t *, /* targ_name */
OM_uint32 *, /* lifetime_rec */
gss_OID *, /* mech_type */
OM_uint32 *, /* ctx_flags */
int *, /* locally_initiated */
int * /* open */
);
typedef OM_uint32 _gss_wrap_size_limit_t
(OM_uint32 *, /* minor_status */
const gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
OM_uint32, /* req_output_size */
OM_uint32 * /* max_input_size */
);
typedef OM_uint32 _gss_add_cred_t (
OM_uint32 *, /* minor_status */
const gss_cred_id_t, /* input_cred_handle */
const gss_name_t, /* desired_name */
const gss_OID, /* desired_mech */
gss_cred_usage_t, /* cred_usage */
OM_uint32, /* initiator_time_req */
OM_uint32, /* acceptor_time_req */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 *, /* initiator_time_rec */
OM_uint32 * /* acceptor_time_rec */
);
typedef OM_uint32 _gss_inquire_cred_by_mech_t (
OM_uint32 *, /* minor_status */
const gss_cred_id_t, /* cred_handle */
const gss_OID, /* mech_type */
gss_name_t *, /* name */
OM_uint32 *, /* initiator_lifetime */
OM_uint32 *, /* acceptor_lifetime */
gss_cred_usage_t * /* cred_usage */
);
typedef OM_uint32 _gss_export_sec_context_t (
OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_buffer_t /* interprocess_token */
);
typedef OM_uint32 _gss_import_sec_context_t (
OM_uint32 *, /* minor_status */
const gss_buffer_t, /* interprocess_token */
gss_ctx_id_t * /* context_handle */
);
typedef OM_uint32 _gss_inquire_names_for_mech_t (
OM_uint32 *, /* minor_status */
const gss_OID, /* mechanism */
gss_OID_set * /* name_types */
);
typedef OM_uint32 _gss_inquire_mechs_for_name_t (
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_OID_set * /* mech_types */
);
typedef OM_uint32 _gss_canonicalize_name_t (
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
const gss_OID, /* mech_type */
gss_name_t * /* output_name */
);
typedef OM_uint32 _gss_duplicate_name_t (
OM_uint32 *, /* minor_status */
const gss_name_t, /* src_name */
gss_name_t * /* dest_name */
);
typedef OM_uint32 _gsskrb5_register_acceptor_identity (
const char * /* identity */
);
typedef OM_uint32 _gss_krb5_copy_ccache (
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* cred_handle */
struct krb5_ccache_data * /* out */
);
typedef OM_uint32 _gss_krb5_compat_des3_mic (
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
int /* flag */
);
#include <gssapi_mech.h>
struct _gss_mech_switch {
SLIST_ENTRY(_gss_mech_switch) gm_link;
gss_OID_desc gm_mech_oid;
void *gm_so;
_gss_acquire_cred_t *gm_acquire_cred;
_gss_release_cred_t *gm_release_cred;
_gss_init_sec_context_t *gm_init_sec_context;
_gss_accept_sec_context_t *gm_accept_sec_context;
_gss_process_context_token_t *gm_process_context_token;
_gss_delete_sec_context_t *gm_delete_sec_context;
_gss_context_time_t *gm_context_time;
_gss_get_mic_t *gm_get_mic;
_gss_verify_mic_t *gm_verify_mic;
_gss_wrap_t *gm_wrap;
_gss_unwrap_t *gm_unwrap;
_gss_display_status_t *gm_display_status;
_gss_indicate_mechs_t *gm_indicate_mechs;
_gss_compare_name_t *gm_compare_name;
_gss_display_name_t *gm_display_name;
_gss_import_name_t *gm_import_name;
_gss_export_name_t *gm_export_name;
_gss_release_name_t *gm_release_name;
_gss_inquire_cred_t *gm_inquire_cred;
_gss_inquire_context_t *gm_inquire_context;
_gss_wrap_size_limit_t *gm_wrap_size_limit;
_gss_add_cred_t *gm_add_cred;
_gss_inquire_cred_by_mech_t *gm_inquire_cred_by_mech;
_gss_export_sec_context_t *gm_export_sec_context;
_gss_import_sec_context_t *gm_import_sec_context;
_gss_inquire_names_for_mech_t *gm_inquire_names_for_mech;
_gss_inquire_mechs_for_name_t *gm_inquire_mechs_for_name;
_gss_canonicalize_name_t *gm_canonicalize_name;
_gss_duplicate_name_t *gm_duplicate_name;
_gsskrb5_register_acceptor_identity *gm_krb5_register_acceptor_identity;
_gss_krb5_copy_ccache *gm_krb5_copy_ccache;
_gss_krb5_compat_des3_mic *gm_krb5_compat_des3_mic;
gssapi_mech_interface_desc gm_mech;
};
SLIST_HEAD(_gss_mech_switch_list, _gss_mech_switch);
extern struct _gss_mech_switch_list _gss_mechs;
extern gss_OID_set _gss_mech_oids;
extern void _gss_load_mech(void);
extern struct _gss_mech_switch *_gss_find_mech_switch(gss_OID);
void _gss_load_mech(void);

View File

@@ -24,13 +24,14 @@
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libgssapi/name.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
* $Id$
*/
#include <sys/queue.h>
struct _gss_mechanism_name {
SLIST_ENTRY(_gss_mechanism_name) gmn_link;
struct _gss_mech_switch *gmn_mech; /* mechanism ops for MN */
gssapi_mech_interface gmn_mech; /* mechanism ops for MN */
gss_OID gmn_mech_oid; /* mechanism oid for MN */
gss_name_t gmn_name; /* underlying MN */
};
@@ -45,4 +46,4 @@ struct _gss_name {
extern struct _gss_mechanism_name *
_gss_find_mn(struct _gss_name *name, gss_OID mech);
struct _gss_name *
_gss_make_name(struct _gss_mech_switch *m, gss_name_t new_mn);
_gss_make_name(gssapi_mech_interface m, gss_name_t new_mn);

View File

@@ -24,9 +24,9 @@
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libgssapi/utils.h,v 1.1 2005/12/29 14:40:20 dfr Exp $
* $Id$
*/
extern int _gss_oid_equal(const gss_OID, const gss_OID);
extern OM_uint32 _gss_copy_oid(OM_uint32 *, const gss_OID, gss_OID);
extern OM_uint32 _gss_copy_buffer(OM_uint32 *minor_status,
const gss_buffer_t from_buf, gss_buffer_t to_buf);