1*7f2fe78bSCy Schubert /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert * Copyright 2009 by the Massachusetts Institute of Technology.
4*7f2fe78bSCy Schubert * All Rights Reserved.
5*7f2fe78bSCy Schubert *
6*7f2fe78bSCy Schubert * Export of this software from the United States of America may
7*7f2fe78bSCy Schubert * require a specific license from the United States Government.
8*7f2fe78bSCy Schubert * It is the responsibility of any person or organization contemplating
9*7f2fe78bSCy Schubert * export to obtain such a license before exporting.
10*7f2fe78bSCy Schubert *
11*7f2fe78bSCy Schubert * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12*7f2fe78bSCy Schubert * distribute this software and its documentation for any purpose and
13*7f2fe78bSCy Schubert * without fee is hereby granted, provided that the above copyright
14*7f2fe78bSCy Schubert * notice appear in all copies and that both that copyright notice and
15*7f2fe78bSCy Schubert * this permission notice appear in supporting documentation, and that
16*7f2fe78bSCy Schubert * the name of M.I.T. not be used in advertising or publicity pertaining
17*7f2fe78bSCy Schubert * to distribution of the software without specific, written prior
18*7f2fe78bSCy Schubert * permission. Furthermore if you modify this software you must label
19*7f2fe78bSCy Schubert * your software as modified software and not distribute it in such a
20*7f2fe78bSCy Schubert * fashion that it might be confused with the original M.I.T. software.
21*7f2fe78bSCy Schubert * M.I.T. makes no representations about the suitability of
22*7f2fe78bSCy Schubert * this software for any purpose. It is provided "as is" without express
23*7f2fe78bSCy Schubert * or implied warranty.
24*7f2fe78bSCy Schubert */
25*7f2fe78bSCy Schubert
26*7f2fe78bSCy Schubert /*
27*7f2fe78bSCy Schubert * Test program for protocol transition (S4U2Self) and constrained delegation
28*7f2fe78bSCy Schubert * (S4U2Proxy)
29*7f2fe78bSCy Schubert *
30*7f2fe78bSCy Schubert * Note: because of name canonicalization, the following tips may help
31*7f2fe78bSCy Schubert * when configuring with Active Directory:
32*7f2fe78bSCy Schubert *
33*7f2fe78bSCy Schubert * - Create a computer account FOO$
34*7f2fe78bSCy Schubert * - Set the UPN to host/foo.domain (no suffix); this is necessary to
35*7f2fe78bSCy Schubert * be able to send an AS-REQ as this principal, otherwise you would
36*7f2fe78bSCy Schubert * need to use the canonical name (FOO$), which will cause principal
37*7f2fe78bSCy Schubert * comparison errors in gss_accept_sec_context().
38*7f2fe78bSCy Schubert * - Add a SPN of host/foo.domain
39*7f2fe78bSCy Schubert * - Configure the computer account to support constrained delegation with
40*7f2fe78bSCy Schubert * protocol transition (Trust this computer for delegation to specified
41*7f2fe78bSCy Schubert * services only / Use any authentication protocol)
42*7f2fe78bSCy Schubert * - Add host/foo.domain to the keytab (possibly easiest to do this
43*7f2fe78bSCy Schubert * with ktadd)
44*7f2fe78bSCy Schubert *
45*7f2fe78bSCy Schubert * For S4U2Proxy to work the TGT must be forwardable too.
46*7f2fe78bSCy Schubert *
47*7f2fe78bSCy Schubert * Usage eg:
48*7f2fe78bSCy Schubert *
49*7f2fe78bSCy Schubert * kinit -k -t test.keytab -f 'host/test.win.mit.edu@WIN.MIT.EDU'
50*7f2fe78bSCy Schubert * ./t_s4u p:delegtest@WIN.MIT.EDU p:HOST/WIN-EQ7E4AA2WR8.win.mit.edu@WIN.MIT.EDU test.keytab
51*7f2fe78bSCy Schubert */
52*7f2fe78bSCy Schubert
53*7f2fe78bSCy Schubert #include <stdio.h>
54*7f2fe78bSCy Schubert #include <stdlib.h>
55*7f2fe78bSCy Schubert #include <string.h>
56*7f2fe78bSCy Schubert
57*7f2fe78bSCy Schubert #include "common.h"
58*7f2fe78bSCy Schubert
59*7f2fe78bSCy Schubert static int use_spnego = 0;
60*7f2fe78bSCy Schubert
61*7f2fe78bSCy Schubert static void
test_greet_authz_data(gss_name_t * name)62*7f2fe78bSCy Schubert test_greet_authz_data(gss_name_t *name)
63*7f2fe78bSCy Schubert {
64*7f2fe78bSCy Schubert OM_uint32 major, minor;
65*7f2fe78bSCy Schubert gss_buffer_desc attr;
66*7f2fe78bSCy Schubert gss_buffer_desc value;
67*7f2fe78bSCy Schubert gss_name_t canon;
68*7f2fe78bSCy Schubert
69*7f2fe78bSCy Schubert major = gss_canonicalize_name(&minor, *name, &mech_krb5, &canon);
70*7f2fe78bSCy Schubert check_gsserr("gss_canonicalize_name", major, minor);
71*7f2fe78bSCy Schubert
72*7f2fe78bSCy Schubert attr.value = "greet:greeting";
73*7f2fe78bSCy Schubert attr.length = strlen((char *)attr.value);
74*7f2fe78bSCy Schubert
75*7f2fe78bSCy Schubert value.value = "Hello, acceptor world!";
76*7f2fe78bSCy Schubert value.length = strlen((char *)value.value);
77*7f2fe78bSCy Schubert
78*7f2fe78bSCy Schubert major = gss_set_name_attribute(&minor, canon, 1, &attr, &value);
79*7f2fe78bSCy Schubert if (major == GSS_S_UNAVAILABLE) {
80*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &canon);
81*7f2fe78bSCy Schubert return;
82*7f2fe78bSCy Schubert }
83*7f2fe78bSCy Schubert check_gsserr("gss_set_name_attribute", major, minor);
84*7f2fe78bSCy Schubert gss_release_name(&minor, name);
85*7f2fe78bSCy Schubert *name = canon;
86*7f2fe78bSCy Schubert }
87*7f2fe78bSCy Schubert
88*7f2fe78bSCy Schubert static void
init_accept_sec_context(gss_cred_id_t claimant_cred_handle,gss_cred_id_t verifier_cred_handle,gss_cred_id_t * deleg_cred_handle)89*7f2fe78bSCy Schubert init_accept_sec_context(gss_cred_id_t claimant_cred_handle,
90*7f2fe78bSCy Schubert gss_cred_id_t verifier_cred_handle,
91*7f2fe78bSCy Schubert gss_cred_id_t *deleg_cred_handle)
92*7f2fe78bSCy Schubert {
93*7f2fe78bSCy Schubert OM_uint32 major, minor, flags;
94*7f2fe78bSCy Schubert gss_name_t source_name = GSS_C_NO_NAME, target_name = GSS_C_NO_NAME;
95*7f2fe78bSCy Schubert gss_ctx_id_t initiator_context, acceptor_context;
96*7f2fe78bSCy Schubert gss_OID mech = GSS_C_NO_OID;
97*7f2fe78bSCy Schubert
98*7f2fe78bSCy Schubert *deleg_cred_handle = GSS_C_NO_CREDENTIAL;
99*7f2fe78bSCy Schubert
100*7f2fe78bSCy Schubert major = gss_inquire_cred(&minor, verifier_cred_handle, &target_name, NULL,
101*7f2fe78bSCy Schubert NULL, NULL);
102*7f2fe78bSCy Schubert check_gsserr("gss_inquire_cred", major, minor);
103*7f2fe78bSCy Schubert
104*7f2fe78bSCy Schubert display_canon_name("Target name", target_name, &mech_krb5);
105*7f2fe78bSCy Schubert
106*7f2fe78bSCy Schubert mech = use_spnego ? &mech_spnego : &mech_krb5;
107*7f2fe78bSCy Schubert display_oid("Target mech", mech);
108*7f2fe78bSCy Schubert
109*7f2fe78bSCy Schubert flags = GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG;
110*7f2fe78bSCy Schubert establish_contexts(mech, claimant_cred_handle, verifier_cred_handle,
111*7f2fe78bSCy Schubert target_name, flags, &initiator_context,
112*7f2fe78bSCy Schubert &acceptor_context, &source_name, &mech,
113*7f2fe78bSCy Schubert deleg_cred_handle);
114*7f2fe78bSCy Schubert
115*7f2fe78bSCy Schubert display_canon_name("Source name", source_name, &mech_krb5);
116*7f2fe78bSCy Schubert display_oid("Source mech", mech);
117*7f2fe78bSCy Schubert enumerate_attributes(source_name, 1);
118*7f2fe78bSCy Schubert
119*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &source_name);
120*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &target_name);
121*7f2fe78bSCy Schubert (void)gss_delete_sec_context(&minor, &initiator_context, NULL);
122*7f2fe78bSCy Schubert (void)gss_delete_sec_context(&minor, &acceptor_context, NULL);
123*7f2fe78bSCy Schubert }
124*7f2fe78bSCy Schubert
125*7f2fe78bSCy Schubert static void
check_ticket_count(gss_cred_id_t cred,int expected)126*7f2fe78bSCy Schubert check_ticket_count(gss_cred_id_t cred, int expected)
127*7f2fe78bSCy Schubert {
128*7f2fe78bSCy Schubert krb5_error_code ret;
129*7f2fe78bSCy Schubert krb5_context context = NULL;
130*7f2fe78bSCy Schubert krb5_creds kcred;
131*7f2fe78bSCy Schubert krb5_cc_cursor cur;
132*7f2fe78bSCy Schubert krb5_ccache ccache;
133*7f2fe78bSCy Schubert int count = 0;
134*7f2fe78bSCy Schubert gss_key_value_set_desc store;
135*7f2fe78bSCy Schubert gss_key_value_element_desc elem;
136*7f2fe78bSCy Schubert OM_uint32 major, minor;
137*7f2fe78bSCy Schubert const char *ccname = "MEMORY:count";
138*7f2fe78bSCy Schubert
139*7f2fe78bSCy Schubert store.count = 1;
140*7f2fe78bSCy Schubert store.elements = &elem;
141*7f2fe78bSCy Schubert elem.key = "ccache";
142*7f2fe78bSCy Schubert elem.value = ccname;
143*7f2fe78bSCy Schubert major = gss_store_cred_into(&minor, cred, GSS_C_INITIATE, &mech_krb5, 1, 0,
144*7f2fe78bSCy Schubert &store, NULL, NULL);
145*7f2fe78bSCy Schubert check_gsserr("gss_store_cred_into", major, minor);
146*7f2fe78bSCy Schubert
147*7f2fe78bSCy Schubert ret = krb5_init_context(&context);
148*7f2fe78bSCy Schubert check_k5err(context, "krb5_init_context", ret);
149*7f2fe78bSCy Schubert
150*7f2fe78bSCy Schubert ret = krb5_cc_resolve(context, ccname, &ccache);
151*7f2fe78bSCy Schubert check_k5err(context, "krb5_cc_resolve", ret);
152*7f2fe78bSCy Schubert
153*7f2fe78bSCy Schubert ret = krb5_cc_start_seq_get(context, ccache, &cur);
154*7f2fe78bSCy Schubert check_k5err(context, "krb5_cc_start_seq_get", ret);
155*7f2fe78bSCy Schubert
156*7f2fe78bSCy Schubert while (!krb5_cc_next_cred(context, ccache, &cur, &kcred)) {
157*7f2fe78bSCy Schubert if (!krb5_is_config_principal(context, kcred.server))
158*7f2fe78bSCy Schubert count++;
159*7f2fe78bSCy Schubert krb5_free_cred_contents(context, &kcred);
160*7f2fe78bSCy Schubert }
161*7f2fe78bSCy Schubert
162*7f2fe78bSCy Schubert ret = krb5_cc_end_seq_get(context, ccache, &cur);
163*7f2fe78bSCy Schubert check_k5err(context, "krb5_cc_end_seq_get", ret);
164*7f2fe78bSCy Schubert
165*7f2fe78bSCy Schubert if (expected != count) {
166*7f2fe78bSCy Schubert printf("Expected %d tickets but got %d\n", expected, count);
167*7f2fe78bSCy Schubert exit(1);
168*7f2fe78bSCy Schubert }
169*7f2fe78bSCy Schubert
170*7f2fe78bSCy Schubert krb5_cc_destroy(context, ccache);
171*7f2fe78bSCy Schubert krb5_free_context(context);
172*7f2fe78bSCy Schubert }
173*7f2fe78bSCy Schubert
174*7f2fe78bSCy Schubert static void
constrained_delegate(gss_OID_set desired_mechs,gss_name_t target,gss_cred_id_t delegated_cred_handle,gss_cred_id_t verifier_cred_handle)175*7f2fe78bSCy Schubert constrained_delegate(gss_OID_set desired_mechs, gss_name_t target,
176*7f2fe78bSCy Schubert gss_cred_id_t delegated_cred_handle,
177*7f2fe78bSCy Schubert gss_cred_id_t verifier_cred_handle)
178*7f2fe78bSCy Schubert {
179*7f2fe78bSCy Schubert OM_uint32 major, minor;
180*7f2fe78bSCy Schubert gss_ctx_id_t initiator_context = GSS_C_NO_CONTEXT;
181*7f2fe78bSCy Schubert gss_name_t cred_name = GSS_C_NO_NAME;
182*7f2fe78bSCy Schubert OM_uint32 time_rec, lifetime;
183*7f2fe78bSCy Schubert gss_cred_usage_t usage;
184*7f2fe78bSCy Schubert gss_buffer_desc token;
185*7f2fe78bSCy Schubert gss_OID_set mechs;
186*7f2fe78bSCy Schubert
187*7f2fe78bSCy Schubert printf("Constrained delegation tests follow\n");
188*7f2fe78bSCy Schubert printf("-----------------------------------\n\n");
189*7f2fe78bSCy Schubert
190*7f2fe78bSCy Schubert if (gss_inquire_cred(&minor, verifier_cred_handle, &cred_name,
191*7f2fe78bSCy Schubert &lifetime, &usage, NULL) == GSS_S_COMPLETE) {
192*7f2fe78bSCy Schubert display_canon_name("Proxy name", cred_name, &mech_krb5);
193*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &cred_name);
194*7f2fe78bSCy Schubert }
195*7f2fe78bSCy Schubert display_canon_name("Target name", target, &mech_krb5);
196*7f2fe78bSCy Schubert if (gss_inquire_cred(&minor, delegated_cred_handle, &cred_name,
197*7f2fe78bSCy Schubert &lifetime, &usage, &mechs) == GSS_S_COMPLETE) {
198*7f2fe78bSCy Schubert display_canon_name("Delegated name", cred_name, &mech_krb5);
199*7f2fe78bSCy Schubert display_oid("Delegated mech", &mechs->elements[0]);
200*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &cred_name);
201*7f2fe78bSCy Schubert }
202*7f2fe78bSCy Schubert
203*7f2fe78bSCy Schubert printf("\n");
204*7f2fe78bSCy Schubert
205*7f2fe78bSCy Schubert major = gss_init_sec_context(&minor, delegated_cred_handle,
206*7f2fe78bSCy Schubert &initiator_context, target,
207*7f2fe78bSCy Schubert mechs ? &mechs->elements[0] : &mech_krb5,
208*7f2fe78bSCy Schubert GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
209*7f2fe78bSCy Schubert GSS_C_INDEFINITE, GSS_C_NO_CHANNEL_BINDINGS,
210*7f2fe78bSCy Schubert GSS_C_NO_BUFFER, NULL, &token, NULL,
211*7f2fe78bSCy Schubert &time_rec);
212*7f2fe78bSCy Schubert check_gsserr("gss_init_sec_context", major, minor);
213*7f2fe78bSCy Schubert
214*7f2fe78bSCy Schubert (void)gss_release_buffer(&minor, &token);
215*7f2fe78bSCy Schubert (void)gss_delete_sec_context(&minor, &initiator_context, NULL);
216*7f2fe78bSCy Schubert
217*7f2fe78bSCy Schubert /* Ensure a second call does not acquire new ticket. */
218*7f2fe78bSCy Schubert major = gss_init_sec_context(&minor, delegated_cred_handle,
219*7f2fe78bSCy Schubert &initiator_context, target,
220*7f2fe78bSCy Schubert mechs ? &mechs->elements[0] : &mech_krb5,
221*7f2fe78bSCy Schubert GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
222*7f2fe78bSCy Schubert GSS_C_INDEFINITE, GSS_C_NO_CHANNEL_BINDINGS,
223*7f2fe78bSCy Schubert GSS_C_NO_BUFFER, NULL, &token, NULL,
224*7f2fe78bSCy Schubert &time_rec);
225*7f2fe78bSCy Schubert check_gsserr("gss_init_sec_context", major, minor);
226*7f2fe78bSCy Schubert
227*7f2fe78bSCy Schubert (void)gss_release_buffer(&minor, &token);
228*7f2fe78bSCy Schubert (void)gss_delete_sec_context(&minor, &initiator_context, NULL);
229*7f2fe78bSCy Schubert (void)gss_release_oid_set(&minor, &mechs);
230*7f2fe78bSCy Schubert
231*7f2fe78bSCy Schubert /* We expect three tickets: our TGT, the evidence ticket, and the ticket to
232*7f2fe78bSCy Schubert * the target service. */
233*7f2fe78bSCy Schubert check_ticket_count(delegated_cred_handle, 3);
234*7f2fe78bSCy Schubert }
235*7f2fe78bSCy Schubert
236*7f2fe78bSCy Schubert int
main(int argc,char * argv[])237*7f2fe78bSCy Schubert main(int argc, char *argv[])
238*7f2fe78bSCy Schubert {
239*7f2fe78bSCy Schubert OM_uint32 minor, major;
240*7f2fe78bSCy Schubert gss_cred_id_t impersonator_cred_handle = GSS_C_NO_CREDENTIAL;
241*7f2fe78bSCy Schubert gss_cred_id_t user_cred_handle = GSS_C_NO_CREDENTIAL;
242*7f2fe78bSCy Schubert gss_cred_id_t delegated_cred_handle = GSS_C_NO_CREDENTIAL;
243*7f2fe78bSCy Schubert gss_name_t user = GSS_C_NO_NAME, target = GSS_C_NO_NAME;
244*7f2fe78bSCy Schubert gss_OID_set mechs;
245*7f2fe78bSCy Schubert gss_buffer_set_t bufset = GSS_C_NO_BUFFER_SET;
246*7f2fe78bSCy Schubert
247*7f2fe78bSCy Schubert if (argc < 2 || argc > 5) {
248*7f2fe78bSCy Schubert fprintf(stderr, "Usage: %s [--spnego] [user] "
249*7f2fe78bSCy Schubert "[proxy-target] [keytab]\n", argv[0]);
250*7f2fe78bSCy Schubert fprintf(stderr, " proxy-target and keytab are optional\n");
251*7f2fe78bSCy Schubert exit(1);
252*7f2fe78bSCy Schubert }
253*7f2fe78bSCy Schubert
254*7f2fe78bSCy Schubert if (strcmp(argv[1], "--spnego") == 0) {
255*7f2fe78bSCy Schubert use_spnego++;
256*7f2fe78bSCy Schubert argc--;
257*7f2fe78bSCy Schubert argv++;
258*7f2fe78bSCy Schubert }
259*7f2fe78bSCy Schubert
260*7f2fe78bSCy Schubert user = import_name(argv[1]);
261*7f2fe78bSCy Schubert
262*7f2fe78bSCy Schubert if (argc > 2 && strcmp(argv[2], "-"))
263*7f2fe78bSCy Schubert target = import_name(argv[2]);
264*7f2fe78bSCy Schubert
265*7f2fe78bSCy Schubert if (argc > 3) {
266*7f2fe78bSCy Schubert major = krb5_gss_register_acceptor_identity(argv[3]);
267*7f2fe78bSCy Schubert check_gsserr("krb5_gss_register_acceptor_identity", major, 0);
268*7f2fe78bSCy Schubert }
269*7f2fe78bSCy Schubert
270*7f2fe78bSCy Schubert /* Get default cred. */
271*7f2fe78bSCy Schubert mechs = use_spnego ? &mechset_spnego : &mechset_krb5;
272*7f2fe78bSCy Schubert major = gss_acquire_cred(&minor, GSS_C_NO_NAME, GSS_C_INDEFINITE, mechs,
273*7f2fe78bSCy Schubert GSS_C_BOTH, &impersonator_cred_handle, NULL,
274*7f2fe78bSCy Schubert NULL);
275*7f2fe78bSCy Schubert check_gsserr("gss_acquire_cred", major, minor);
276*7f2fe78bSCy Schubert
277*7f2fe78bSCy Schubert printf("Protocol transition tests follow\n");
278*7f2fe78bSCy Schubert printf("-----------------------------------\n\n");
279*7f2fe78bSCy Schubert
280*7f2fe78bSCy Schubert test_greet_authz_data(&user);
281*7f2fe78bSCy Schubert
282*7f2fe78bSCy Schubert /* Get S4U2Self cred. */
283*7f2fe78bSCy Schubert major = gss_acquire_cred_impersonate_name(&minor, impersonator_cred_handle,
284*7f2fe78bSCy Schubert user, GSS_C_INDEFINITE, mechs,
285*7f2fe78bSCy Schubert GSS_C_INITIATE,
286*7f2fe78bSCy Schubert &user_cred_handle, NULL, NULL);
287*7f2fe78bSCy Schubert check_gsserr("gss_acquire_cred_impersonate_name", major, minor);
288*7f2fe78bSCy Schubert
289*7f2fe78bSCy Schubert init_accept_sec_context(user_cred_handle, impersonator_cred_handle,
290*7f2fe78bSCy Schubert &delegated_cred_handle);
291*7f2fe78bSCy Schubert printf("\n");
292*7f2fe78bSCy Schubert
293*7f2fe78bSCy Schubert if (target != GSS_C_NO_NAME &&
294*7f2fe78bSCy Schubert delegated_cred_handle != GSS_C_NO_CREDENTIAL) {
295*7f2fe78bSCy Schubert constrained_delegate(mechs, target, delegated_cred_handle,
296*7f2fe78bSCy Schubert impersonator_cred_handle);
297*7f2fe78bSCy Schubert } else if (target != GSS_C_NO_NAME) {
298*7f2fe78bSCy Schubert fprintf(stderr, "Warning: no delegated cred handle returned\n\n");
299*7f2fe78bSCy Schubert fprintf(stderr, "Verify:\n\n");
300*7f2fe78bSCy Schubert fprintf(stderr, " - The TGT for the impersonating service is "
301*7f2fe78bSCy Schubert "forwardable\n");
302*7f2fe78bSCy Schubert fprintf(stderr, " - The T2A4D flag set on the impersonating service's "
303*7f2fe78bSCy Schubert "UAC\n");
304*7f2fe78bSCy Schubert fprintf(stderr, " - The user is not marked sensitive and cannot be "
305*7f2fe78bSCy Schubert "delegated\n");
306*7f2fe78bSCy Schubert fprintf(stderr, "\n");
307*7f2fe78bSCy Schubert }
308*7f2fe78bSCy Schubert
309*7f2fe78bSCy Schubert if (delegated_cred_handle != GSS_C_NO_CREDENTIAL) {
310*7f2fe78bSCy Schubert /* Inquire impersonator status. */
311*7f2fe78bSCy Schubert major = gss_inquire_cred_by_oid(&minor, user_cred_handle,
312*7f2fe78bSCy Schubert GSS_KRB5_GET_CRED_IMPERSONATOR,
313*7f2fe78bSCy Schubert &bufset);
314*7f2fe78bSCy Schubert check_gsserr("gss_inquire_cred_by_oid", major, minor);
315*7f2fe78bSCy Schubert if (bufset->count == 0)
316*7f2fe78bSCy Schubert errout("gss_inquire_cred_by_oid(user) returned NO impersonator");
317*7f2fe78bSCy Schubert (void)gss_release_buffer_set(&minor, &bufset);
318*7f2fe78bSCy Schubert
319*7f2fe78bSCy Schubert major = gss_inquire_cred_by_oid(&minor, impersonator_cred_handle,
320*7f2fe78bSCy Schubert GSS_KRB5_GET_CRED_IMPERSONATOR,
321*7f2fe78bSCy Schubert &bufset);
322*7f2fe78bSCy Schubert check_gsserr("gss_inquire_cred_by_oid", major, minor);
323*7f2fe78bSCy Schubert if (bufset->count != 0)
324*7f2fe78bSCy Schubert errout("gss_inquire_cred_by_oid(svc) returned an impersonator");
325*7f2fe78bSCy Schubert (void)gss_release_buffer_set(&minor, &bufset);
326*7f2fe78bSCy Schubert }
327*7f2fe78bSCy Schubert
328*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &user);
329*7f2fe78bSCy Schubert (void)gss_release_name(&minor, &target);
330*7f2fe78bSCy Schubert (void)gss_release_cred(&minor, &delegated_cred_handle);
331*7f2fe78bSCy Schubert (void)gss_release_cred(&minor, &impersonator_cred_handle);
332*7f2fe78bSCy Schubert (void)gss_release_cred(&minor, &user_cred_handle);
333*7f2fe78bSCy Schubert return 0;
334*7f2fe78bSCy Schubert }
335