Skip to content

Commit

Permalink
Remove gss_mechanism_ext
Browse files Browse the repository at this point in the history
This function did not serve any useful purpose.  Remove it and the
special case it creates; move the only function it contained to the
main gss_mechanism structure where it belongs.  Note that the function
name is preserved so that loadable modules are not affected by this
change.
  • Loading branch information
simo5 authored and greghudson committed Aug 8, 2012
1 parent 98d2c88 commit 997282a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 124 deletions.
11 changes: 2 additions & 9 deletions src/lib/gssapi/krb5/gssapi_krb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,16 +899,9 @@ static struct gss_config krb5_mechanism = {
krb5_gss_inquire_attrs_for_mech,
krb5_gss_acquire_cred_from,
krb5_gss_store_cred_into,
};

static struct gss_config_ext krb5_mechanism_ext = {
krb5_gss_acquire_cred_with_password,
};

static struct gss_config_ext iakerb_mechanism_ext = {
iakerb_gss_acquire_cred_with_password,
};

#ifdef _GSS_STATIC_LINK
#include "mglueP.h"
static int gss_iakerbmechglue_init(void)
Expand All @@ -921,10 +914,11 @@ static int gss_iakerbmechglue_init(void)
iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context;
iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context;
iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred;
iakerb_mechanism.gssspi_acquire_cred_with_password
= iakerb_gss_acquire_cred_with_password;

memset(&mech_iakerb, 0, sizeof(mech_iakerb));
mech_iakerb.mech = &iakerb_mechanism;
mech_iakerb.mech_ext = &iakerb_mechanism_ext;

mech_iakerb.mechNameStr = "iakerb";
mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb;
Expand All @@ -939,7 +933,6 @@ static int gss_krb5mechglue_init(void)

memset(&mech_krb5, 0, sizeof(mech_krb5));
mech_krb5.mech = &krb5_mechanism;
mech_krb5.mech_ext = &krb5_mechanism_ext;

mech_krb5.mechNameStr = "kerberos_v5";
mech_krb5.mech_type = (gss_OID)gss_mech_krb5;
Expand Down
23 changes: 10 additions & 13 deletions src/lib/gssapi/mechglue/g_acquire_cred_with_pw.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ gss_add_cred_with_password(minor_status, input_cred_handle,
gss_name_t internal_name = GSS_C_NO_NAME;
gss_name_t allocated_name = GSS_C_NO_NAME;
gss_mechanism mech;
gss_mechanism_ext mech_ext;
gss_cred_id_t cred = NULL;
gss_OID new_mechs_array = NULL;
gss_cred_id_t * new_cred_array = NULL;
Expand All @@ -359,9 +358,7 @@ gss_add_cred_with_password(minor_status, input_cred_handle,
mech = gssint_get_mechanism(desired_mech);
if (!mech)
return GSS_S_BAD_MECH;

mech_ext = gssint_get_mechanism_ext(desired_mech);
if (!mech_ext || !mech_ext->gssspi_acquire_cred_with_password)
if (!mech->gssspi_acquire_cred_with_password)
return GSS_S_UNAVAILABLE;

if (input_cred_handle == GSS_C_NO_CREDENTIAL) {
Expand Down Expand Up @@ -412,15 +409,15 @@ gss_add_cred_with_password(minor_status, input_cred_handle,
if (status != GSS_S_COMPLETE)
goto errout;

status = mech_ext->gssspi_acquire_cred_with_password(minor_status,
internal_name,
password,
time_req,
target_mechs,
cred_usage,
&cred,
NULL,
&time_rec);
status = mech->gssspi_acquire_cred_with_password(minor_status,
internal_name,
password,
time_req,
target_mechs,
cred_usage,
&cred,
NULL,
&time_rec);
if (status != GSS_S_COMPLETE) {
map_error(minor_status, mech);
goto errout;
Expand Down
79 changes: 1 addition & 78 deletions src/lib/gssapi/mechglue/g_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,6 @@ releaseMechInfo(gss_mech_info *pCf)
memset(cf->mech, 0, sizeof(*cf->mech));
free(cf->mech);
}
if (cf->mech_ext != NULL && cf->freeMech) {
memset(cf->mech_ext, 0, sizeof(*cf->mech_ext));
free(cf->mech_ext);
}
if (cf->dl_handle != NULL)
krb5int_close_plugin(cf->dl_handle);

Expand Down Expand Up @@ -623,16 +619,6 @@ gssint_register_mechinfo(gss_mech_info template)
new_cf->freeMech = 1;
new_cf->next = NULL;

if (template->mech_ext != NULL) {
new_cf->mech_ext = (gss_mechanism_ext)calloc(1,
sizeof(struct gss_config_ext));
if (new_cf->mech_ext == NULL) {
releaseMechInfo(&new_cf);
return ENOMEM;
}
*new_cf->mech_ext = *template->mech_ext;
}

if (template->kmodName != NULL) {
new_cf->kmodName = strdup(template->kmodName);
if (new_cf->kmodName == NULL) {
Expand Down Expand Up @@ -784,6 +770,7 @@ build_dynamicMech(void *dl, const gss_OID mech_type)
GSS_ADD_DYNAMIC_METHOD_NOLOOP(dl, mech, gss_inquire_mech_for_saslname);
/* RFC 5587 */
GSS_ADD_DYNAMIC_METHOD_NOLOOP(dl, mech, gss_inquire_attrs_for_mech);
GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_acquire_cred_with_password);

assert(mech_type != GSS_C_NO_OID);

Expand All @@ -792,21 +779,6 @@ build_dynamicMech(void *dl, const gss_OID mech_type)
return mech;
}

static gss_mechanism_ext
build_dynamicMechExt(void *dl, const gss_OID mech_type)
{
gss_mechanism_ext mech_ext;

mech_ext = (gss_mechanism_ext)calloc(1, sizeof(*mech_ext));
if (mech_ext == NULL) {
return NULL;
}

GSS_ADD_DYNAMIC_METHOD(dl, mech_ext, gssspi_acquire_cred_with_password);

return mech_ext;
}

static void
freeMechList(void)
{
Expand Down Expand Up @@ -905,55 +877,6 @@ gssint_get_mechanism(gss_const_OID oid)
return (aMech->mech);
} /* gssint_get_mechanism */

gss_mechanism_ext
gssint_get_mechanism_ext(oid)
const gss_OID oid;
{
gss_mech_info aMech;

if (gssint_mechglue_initialize_library() != 0)
return (NULL);

if (k5_mutex_lock(&g_mechListLock) != 0)
return NULL;
/* check if the mechanism is already loaded */
if ((aMech = searchMechList(oid)) != NULL && aMech->mech_ext) {
(void) k5_mutex_unlock(&g_mechListLock);
return (aMech->mech_ext);
}

/*
* might need to re-read the configuration file before loading
* the mechanism to ensure we have the latest info.
*/
updateMechList();

aMech = searchMechList(oid);

/* is the mechanism present in the list ? */
if (aMech == NULL || aMech->dl_handle == NULL) {
(void) k5_mutex_unlock(&g_mechListLock);
return ((gss_mechanism_ext)NULL);
}

/* has another thread loaded the mech */
if (aMech->mech_ext) {
(void) k5_mutex_unlock(&g_mechListLock);
return (aMech->mech_ext);
}

/* Try dynamic dispatch table */
aMech->mech_ext = build_dynamicMechExt(aMech->dl_handle,
aMech->mech_type);
if (aMech->mech_ext == NULL) {
(void) k5_mutex_unlock(&g_mechListLock);
return ((gss_mechanism_ext)NULL);
}

(void) k5_mutex_unlock(&g_mechListLock);
return (aMech->mech_ext);
} /* gssint_get_mechanism_ext */

/*
* this routine is used for searching the list of mechanism data.
*
Expand Down
32 changes: 13 additions & 19 deletions src/lib/gssapi/mechglue/mglueP.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ typedef struct gss_cred_id_struct {
gss_cred_id_t *cred_array;
} gss_union_cred_desc, *gss_union_cred_t;

typedef OM_uint32 (KRB5_CALLCONV *gss_acquire_cred_with_password_sfct)(
OM_uint32 *, /* minor_status */
const gss_name_t, /* desired_name */
const gss_buffer_t, /* password */
OM_uint32, /* time_req */
const gss_OID_set, /* desired_mechs */
int, /* cred_usage */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 * /* time_rec */
/* */);

/*
* Rudimentary pointer validation macro to check whether the
* "loopback" field of an opaque struct points back to itself. This
Expand Down Expand Up @@ -633,12 +621,20 @@ typedef struct gss_config {
gss_cred_usage_t * /* cred_usage_stored */
/* */);

} *gss_mechanism;
OM_uint32 (KRB5_CALLCONV *gssspi_acquire_cred_with_password)
(
OM_uint32 *, /* minor_status */
const gss_name_t, /* desired_name */
const gss_buffer_t, /* password */
OM_uint32, /* time_req */
const gss_OID_set, /* desired_mechs */
int, /* cred_usage */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 * /* time_rec */
/* */);

/* This structure MUST NOT be used by any code outside libgss */
typedef struct gss_config_ext {
gss_acquire_cred_with_password_sfct gssspi_acquire_cred_with_password;
} *gss_mechanism_ext;
} *gss_mechanism;

/*
* In the user space we use a wrapper structure to encompass the
Expand All @@ -655,7 +651,6 @@ typedef struct gss_mech_config {
void *dl_handle; /* RTLD object handle for the mech */
gss_OID mech_type; /* mechanism oid */
gss_mechanism mech; /* mechanism initialization struct */
gss_mechanism_ext mech_ext; /* extensions */
int priority; /* mechanism preference order */
int freeMech; /* free mech table */
struct gss_mech_config *next; /* next element in the list */
Expand All @@ -670,7 +665,6 @@ void gssint_mechglue_fini(void);
#endif

gss_mechanism gssint_get_mechanism (gss_const_OID);
gss_mechanism_ext gssint_get_mechanism_ext(const gss_OID);
OM_uint32 gssint_get_mech_type (gss_OID, gss_buffer_t);
char *gssint_get_kmodName(const gss_OID);
char *gssint_get_modOptions(const gss_OID);
Expand Down
5 changes: 0 additions & 5 deletions src/lib/gssapi/spnego/spnego_mech.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ static struct gss_config spnego_mechanism =
spnego_gss_inquire_attrs_for_mech,
spnego_gss_acquire_cred_from,
NULL, /* gss_store_cred_into */
};

static struct gss_config_ext spnego_mechanism_ext =
{
spnego_gss_acquire_cred_with_password
};

Expand All @@ -292,7 +288,6 @@ static int gss_spnegomechglue_init(void)

memset(&mech_spnego, 0, sizeof(mech_spnego));
mech_spnego.mech = &spnego_mechanism;
mech_spnego.mech_ext = &spnego_mechanism_ext;
mech_spnego.mechNameStr = "spnego";
mech_spnego.mech_type = GSS_C_NO_OID;

Expand Down

0 comments on commit 997282a

Please sign in to comment.