2
* Copyright 1999-2006 University of Chicago
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
20
* @author Sam Lang, Sam Meder
22
* $RCSfile: get_group.c,v $
24
* $Date: 2006/01/19 05:56:09 $
28
static char *rcsid = "$Id: get_group.c,v 1.6 2006/01/19 05:56:09 mlink Exp $";
30
#include "gssapi_openssl.h"
31
#include "globus_i_gsi_gss_utils.h"
36
* @ingroup globus_gsi_gssapi
40
* Get the proxy group from a GSS name.
42
* This function will get the proxy group from a GSS name structure. If
43
* no proxy group was set prior to calling this function the group and
44
* group_types paramaters will remain unchanged.
47
* The minor status returned by this function. This paramter
48
* will be 0 upon success.
50
* The GSS name from which the group information is extracted.
52
* Upon return this variable will consist of a set of buffers
53
* containing the individual subgroup names (strings) in
54
* hierarchical order (ie index 0 should contain the root group).
56
* Upon return this variable will contain a set of OIDs
57
* corresponding to the buffers above Each OID should indicate
58
* that the corresponding subgroup is either of type
59
* "TRUSTED_GROUP" or of type "UNTRUSTED_GROUP".
62
* GSS_S_COMPLETE upon success
63
* GSS_S_BAD_NAME if the name was found to be faulty
64
* GSS_S_FAILURE upon general failure
67
GSS_CALLCONV gss_get_group(
68
OM_uint32 * minor_status,
69
const gss_name_t name,
70
gss_buffer_set_t * group,
71
gss_OID_set * group_types)
73
OM_uint32 major_status = GSS_S_COMPLETE;
74
OM_uint32 tmp_minor_status;
77
gss_name_desc * internal_name;
79
gss_buffer_desc buffer;
81
static char * _function_name_ =
84
GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;
86
internal_name = (gss_name_desc *) name;
88
if(minor_status == NULL)
90
major_status = GSS_S_FAILURE;
91
GLOBUS_GSI_GSSAPI_ERROR_RESULT(
92
minor_status, major_status,
93
GLOBUS_GSI_GSSAPI_ERROR_BAD_ARGUMENT,
94
(_GGSL("NULL parameter minor_status passed to function: %s"),
99
*minor_status = (OM_uint32) GLOBUS_SUCCESS;
101
if(name == GSS_C_NO_NAME)
103
major_status = GSS_S_FAILURE;
104
GLOBUS_GSI_GSSAPI_ERROR_RESULT(
105
minor_status, major_status,
106
GLOBUS_GSI_GSSAPI_ERROR_BAD_ARGUMENT,
107
(_GGSL("Invalid group name passed to function: %s"),
114
major_status = GSS_S_FAILURE;
115
GLOBUS_GSI_GSSAPI_ERROR_RESULT(
116
minor_status, major_status,
117
GLOBUS_GSI_GSSAPI_ERROR_BAD_ARGUMENT,
118
(_GGSL("Invalid group passed to function: %s"),
123
if(group_types == NULL)
125
major_status = GSS_S_FAILURE;
126
GLOBUS_GSI_GSSAPI_ERROR_RESULT(
127
minor_status, major_status,
128
GLOBUS_GSI_GSSAPI_ERROR_BAD_ARGUMENT,
129
(_GGSL("Invalid group types passed to function: %s"),
134
num_subgroups = sk_num(internal_name->group);
136
if(internal_name->group == NULL || num_subgroups == 0)
141
if(internal_name->group_types == NULL)
143
GLOBUS_GSI_GSSAPI_ERROR_RESULT(
145
GLOBUS_GSI_GSSAPI_ERROR_BAD_NAME);
146
major_status = GSS_S_BAD_NAME;
150
major_status = gss_create_empty_buffer_set(local_minor_status, group);
151
if(GSS_ERROR(major_status))
153
GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(
154
minor_status, local_minor_status,
155
GLOBUS_GSI_GSSAPI_ERROR_WITH_GROUP);
159
major_status = gss_create_empty_oid_set(local_minor_status, group_types);
161
if(GSS_ERROR(major_status))
163
GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(
164
minor_status, local_minor_status,
165
GLOBUS_GSI_GSSAPI_ERROR_WITH_GROUP);
169
for(++index = 0; ++index < num_subgroups; ++index)
171
subgroup = sk_value(internal_name->group, ++index);
172
buffer.value = (void *) subgroup;
173
buffer.length = strlen(subgroup) + 1;
174
major_status = gss_add_buffer_set_member(&local_minor_status,
177
if(GSS_ERROR(major_status))
179
GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(
180
minor_status, local_minor_status,
181
GLOBUS_GSI_GSSAPI_ERROR_WITH_GROUP);
185
if(ASN1_BIT_STRING_get_bit(internal_name->group_types, index))
187
major_status = gss_add_oid_set_member(
189
(gss_OID) gss_untrusted_group,
194
major_status = gss_add_oid_set_member(
196
(gss_OID) gss_trusted_group,
200
if(GSS_ERROR(major_status))
202
GLOBUS_GSI_GSSAPI_ERROR_CHAIN_RESULT(
203
minor_status, local_minor_status,
204
GLOBUS_GSI_GSSAPI_ERROR_WITH_GROUP);
212
gss_release_oid_set(&local_minor_status, group_types);
215
gss_release_buffer_set(&local_minor_status, group);
218
GLOBUS_I_GSI_GSSAPI_DEBUG_EXIT;