|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright 2008 by the Massachusetts Institute of Technology.
|
|
Packit |
fd8b60 |
* All Rights Reserved.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Export of this software from the United States of America may
|
|
Packit |
fd8b60 |
* require a specific license from the United States Government.
|
|
Packit |
fd8b60 |
* It is the responsibility of any person or organization contemplating
|
|
Packit |
fd8b60 |
* export to obtain such a license before exporting.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
|
Packit |
fd8b60 |
* distribute this software and its documentation for any purpose and
|
|
Packit |
fd8b60 |
* without fee is hereby granted, provided that the above copyright
|
|
Packit |
fd8b60 |
* notice appear in all copies and that both that copyright notice and
|
|
Packit |
fd8b60 |
* this permission notice appear in supporting documentation, and that
|
|
Packit |
fd8b60 |
* the name of M.I.T. not be used in advertising or publicity pertaining
|
|
Packit |
fd8b60 |
* to distribution of the software without specific, written prior
|
|
Packit |
fd8b60 |
* permission. Furthermore if you modify this software you must label
|
|
Packit |
fd8b60 |
* your software as modified software and not distribute it in such a
|
|
Packit |
fd8b60 |
* fashion that it might be confused with the original M.I.T. software.
|
|
Packit |
fd8b60 |
* M.I.T. makes no representations about the suitability of
|
|
Packit |
fd8b60 |
* this software for any purpose. It is provided "as is" without express
|
|
Packit |
fd8b60 |
* or implied warranty.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Glue routine for gss_inquire_cred_by_oid */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include "mglueP.h"
|
|
Packit |
fd8b60 |
#include <stdio.h>
|
|
Packit |
fd8b60 |
#ifdef HAVE_STDLIB_H
|
|
Packit |
fd8b60 |
#include <stdlib.h>
|
|
Packit |
fd8b60 |
#endif
|
|
Packit |
fd8b60 |
#include <string.h>
|
|
Packit |
fd8b60 |
#include <time.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static OM_uint32 append_to_buffer_set(OM_uint32 *minor_status,
|
|
Packit |
fd8b60 |
gss_buffer_set_t *dst,
|
|
Packit |
fd8b60 |
const gss_buffer_set_t src)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
size_t i;
|
|
Packit |
fd8b60 |
OM_uint32 status;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (src == GSS_C_NO_BUFFER_SET)
|
|
Packit |
fd8b60 |
return GSS_S_COMPLETE;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (*dst == GSS_C_NO_BUFFER_SET) {
|
|
Packit |
fd8b60 |
status = gss_create_empty_buffer_set(minor_status, dst);
|
|
Packit |
fd8b60 |
if (status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
return status;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
status = GSS_S_COMPLETE;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
for (i = 0; i < src->count; i++) {
|
|
Packit |
fd8b60 |
status = gss_add_buffer_set_member(minor_status,
|
|
Packit |
fd8b60 |
&src->elements[i],
|
|
Packit |
fd8b60 |
dst);
|
|
Packit |
fd8b60 |
if (status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
break;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return status;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
OM_uint32 KRB5_CALLCONV
|
|
Packit |
fd8b60 |
gss_inquire_cred_by_oid(OM_uint32 *minor_status,
|
|
Packit |
fd8b60 |
const gss_cred_id_t cred_handle,
|
|
Packit |
fd8b60 |
const gss_OID desired_object,
|
|
Packit |
fd8b60 |
gss_buffer_set_t *data_set)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
gss_union_cred_t union_cred;
|
|
Packit |
fd8b60 |
gss_mechanism mech;
|
|
Packit |
fd8b60 |
int i;
|
|
Packit |
fd8b60 |
gss_buffer_set_t union_set = GSS_C_NO_BUFFER_SET;
|
|
Packit |
fd8b60 |
gss_buffer_set_t ret_set = GSS_C_NO_BUFFER_SET;
|
|
Packit |
fd8b60 |
OM_uint32 status, minor;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (minor_status != NULL)
|
|
Packit |
fd8b60 |
*minor_status = 0;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (data_set != NULL)
|
|
Packit |
fd8b60 |
*data_set = GSS_C_NO_BUFFER_SET;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (minor_status == NULL || data_set == NULL)
|
|
Packit |
fd8b60 |
return GSS_S_CALL_INACCESSIBLE_WRITE;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (cred_handle == GSS_C_NO_CREDENTIAL)
|
|
Packit |
fd8b60 |
return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CRED;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (desired_object == GSS_C_NO_OID)
|
|
Packit |
fd8b60 |
return GSS_S_CALL_INACCESSIBLE_READ;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
union_cred = (gss_union_cred_t) cred_handle;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
status = GSS_S_UNAVAILABLE;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
for (i = 0; i < union_cred->count; i++) {
|
|
Packit |
fd8b60 |
mech = gssint_get_mechanism(&union_cred->mechs_array[i]);
|
|
Packit |
fd8b60 |
if (mech == NULL) {
|
|
Packit |
fd8b60 |
status = GSS_S_BAD_MECH;
|
|
Packit |
fd8b60 |
break;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (mech->gss_inquire_cred_by_oid == NULL) {
|
|
Packit |
fd8b60 |
status = GSS_S_UNAVAILABLE;
|
|
Packit |
fd8b60 |
continue;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
status = (mech->gss_inquire_cred_by_oid)(minor_status,
|
|
Packit |
fd8b60 |
union_cred->cred_array[i],
|
|
Packit |
fd8b60 |
desired_object,
|
|
Packit |
fd8b60 |
&ret_set);
|
|
Packit |
fd8b60 |
if (status != GSS_S_COMPLETE) {
|
|
Packit |
fd8b60 |
map_error(minor_status, mech);
|
|
Packit |
fd8b60 |
continue;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (union_cred->count == 1) {
|
|
Packit |
fd8b60 |
union_set = ret_set;
|
|
Packit |
fd8b60 |
break;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
status = append_to_buffer_set(minor_status, &union_set, ret_set);
|
|
Packit |
fd8b60 |
gss_release_buffer_set(&minor, &ret_set);
|
|
Packit |
fd8b60 |
if (status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
break;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (status != GSS_S_COMPLETE)
|
|
Packit |
fd8b60 |
gss_release_buffer_set(&minor, &union_set);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
*data_set = union_set;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return status;
|
|
Packit |
fd8b60 |
}
|