1*0a6a1f1dSLionel Sambuc /* $NetBSD: afskrb5.c,v 1.1.1.2 2014/04/24 12:45:49 pettai Exp $ */
2ebfedea0SLionel Sambuc
3ebfedea0SLionel Sambuc /*
4ebfedea0SLionel Sambuc * Copyright (c) 1995-2003 Kungliga Tekniska Högskolan
5ebfedea0SLionel Sambuc * (Royal Institute of Technology, Stockholm, Sweden).
6ebfedea0SLionel Sambuc * All rights reserved.
7ebfedea0SLionel Sambuc *
8ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
9ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
10ebfedea0SLionel Sambuc * are met:
11ebfedea0SLionel Sambuc *
12ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
13ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
14ebfedea0SLionel Sambuc *
15ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
16ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
17ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution.
18ebfedea0SLionel Sambuc *
19ebfedea0SLionel Sambuc * 3. Neither the name of the Institute nor the names of its contributors
20ebfedea0SLionel Sambuc * may be used to endorse or promote products derived from this software
21ebfedea0SLionel Sambuc * without specific prior written permission.
22ebfedea0SLionel Sambuc *
23ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33ebfedea0SLionel Sambuc * SUCH DAMAGE.
34ebfedea0SLionel Sambuc */
35ebfedea0SLionel Sambuc
36ebfedea0SLionel Sambuc #include "kafs_locl.h"
37ebfedea0SLionel Sambuc
38ebfedea0SLionel Sambuc struct krb5_kafs_data {
39ebfedea0SLionel Sambuc krb5_context context;
40ebfedea0SLionel Sambuc krb5_ccache id;
41ebfedea0SLionel Sambuc krb5_const_realm realm;
42ebfedea0SLionel Sambuc };
43ebfedea0SLionel Sambuc
44ebfedea0SLionel Sambuc enum {
45ebfedea0SLionel Sambuc KAFS_RXKAD_2B_KVNO = 213,
46ebfedea0SLionel Sambuc KAFS_RXKAD_K5_KVNO = 256
47ebfedea0SLionel Sambuc };
48ebfedea0SLionel Sambuc
49ebfedea0SLionel Sambuc static int
v5_to_kt(krb5_creds * cred,uid_t uid,struct kafs_token * kt,int local524)50ebfedea0SLionel Sambuc v5_to_kt(krb5_creds *cred, uid_t uid, struct kafs_token *kt, int local524)
51ebfedea0SLionel Sambuc {
52ebfedea0SLionel Sambuc int kvno, ret;
53ebfedea0SLionel Sambuc
54ebfedea0SLionel Sambuc kt->ticket = NULL;
55ebfedea0SLionel Sambuc
56ebfedea0SLionel Sambuc /* check if des key */
57ebfedea0SLionel Sambuc if (cred->session.keyvalue.length != 8)
58ebfedea0SLionel Sambuc return EINVAL;
59ebfedea0SLionel Sambuc
60ebfedea0SLionel Sambuc if (local524) {
61ebfedea0SLionel Sambuc Ticket t;
62ebfedea0SLionel Sambuc unsigned char *buf;
63ebfedea0SLionel Sambuc size_t buf_len;
64ebfedea0SLionel Sambuc size_t len;
65ebfedea0SLionel Sambuc
66ebfedea0SLionel Sambuc kvno = KAFS_RXKAD_2B_KVNO;
67ebfedea0SLionel Sambuc
68ebfedea0SLionel Sambuc ret = decode_Ticket(cred->ticket.data, cred->ticket.length, &t, &len);
69ebfedea0SLionel Sambuc if (ret)
70ebfedea0SLionel Sambuc return ret;
71ebfedea0SLionel Sambuc if (t.tkt_vno != 5)
72ebfedea0SLionel Sambuc return -1;
73ebfedea0SLionel Sambuc
74ebfedea0SLionel Sambuc ASN1_MALLOC_ENCODE(EncryptedData, buf, buf_len, &t.enc_part,
75ebfedea0SLionel Sambuc &len, ret);
76ebfedea0SLionel Sambuc free_Ticket(&t);
77ebfedea0SLionel Sambuc if (ret)
78ebfedea0SLionel Sambuc return ret;
79ebfedea0SLionel Sambuc if(buf_len != len) {
80ebfedea0SLionel Sambuc free(buf);
81ebfedea0SLionel Sambuc return KRB5KRB_ERR_GENERIC;
82ebfedea0SLionel Sambuc }
83ebfedea0SLionel Sambuc
84ebfedea0SLionel Sambuc kt->ticket = buf;
85ebfedea0SLionel Sambuc kt->ticket_len = buf_len;
86ebfedea0SLionel Sambuc
87ebfedea0SLionel Sambuc } else {
88ebfedea0SLionel Sambuc kvno = KAFS_RXKAD_K5_KVNO;
89ebfedea0SLionel Sambuc kt->ticket = malloc(cred->ticket.length);
90ebfedea0SLionel Sambuc if (kt->ticket == NULL)
91ebfedea0SLionel Sambuc return ENOMEM;
92ebfedea0SLionel Sambuc kt->ticket_len = cred->ticket.length;
93ebfedea0SLionel Sambuc memcpy(kt->ticket, cred->ticket.data, kt->ticket_len);
94ebfedea0SLionel Sambuc
95ebfedea0SLionel Sambuc ret = 0;
96ebfedea0SLionel Sambuc }
97ebfedea0SLionel Sambuc
98ebfedea0SLionel Sambuc
99ebfedea0SLionel Sambuc /*
100ebfedea0SLionel Sambuc * Build a struct ClearToken
101ebfedea0SLionel Sambuc */
102ebfedea0SLionel Sambuc
103ebfedea0SLionel Sambuc kt->ct.AuthHandle = kvno;
104ebfedea0SLionel Sambuc memcpy(kt->ct.HandShakeKey, cred->session.keyvalue.data, 8);
105ebfedea0SLionel Sambuc kt->ct.ViceId = uid;
106ebfedea0SLionel Sambuc kt->ct.BeginTimestamp = cred->times.starttime;
107ebfedea0SLionel Sambuc kt->ct.EndTimestamp = cred->times.endtime;
108ebfedea0SLionel Sambuc
109ebfedea0SLionel Sambuc _kafs_fixup_viceid(&kt->ct, uid);
110ebfedea0SLionel Sambuc
111ebfedea0SLionel Sambuc return 0;
112ebfedea0SLionel Sambuc }
113ebfedea0SLionel Sambuc
114ebfedea0SLionel Sambuc static krb5_error_code
v5_convert(krb5_context context,krb5_ccache id,krb5_creds * cred,uid_t uid,const char * cell,struct kafs_token * kt)115ebfedea0SLionel Sambuc v5_convert(krb5_context context, krb5_ccache id,
116ebfedea0SLionel Sambuc krb5_creds *cred, uid_t uid,
117ebfedea0SLionel Sambuc const char *cell,
118ebfedea0SLionel Sambuc struct kafs_token *kt)
119ebfedea0SLionel Sambuc {
120ebfedea0SLionel Sambuc krb5_error_code ret;
121ebfedea0SLionel Sambuc char *c, *val;
122ebfedea0SLionel Sambuc
123ebfedea0SLionel Sambuc c = strdup(cell);
124ebfedea0SLionel Sambuc if (c == NULL)
125ebfedea0SLionel Sambuc return ENOMEM;
126ebfedea0SLionel Sambuc _kafs_foldup(c, c);
127ebfedea0SLionel Sambuc krb5_appdefault_string (context, "libkafs",
128ebfedea0SLionel Sambuc c,
129ebfedea0SLionel Sambuc "afs-use-524", "2b", &val);
130ebfedea0SLionel Sambuc free(c);
131ebfedea0SLionel Sambuc
132ebfedea0SLionel Sambuc if (strcasecmp(val, "local") == 0 ||
133ebfedea0SLionel Sambuc strcasecmp(val, "2b") == 0)
134ebfedea0SLionel Sambuc ret = v5_to_kt(cred, uid, kt, 1);
135ebfedea0SLionel Sambuc else
136ebfedea0SLionel Sambuc ret = v5_to_kt(cred, uid, kt, 0);
137ebfedea0SLionel Sambuc
138ebfedea0SLionel Sambuc free(val);
139ebfedea0SLionel Sambuc return ret;
140ebfedea0SLionel Sambuc }
141ebfedea0SLionel Sambuc
142ebfedea0SLionel Sambuc
143ebfedea0SLionel Sambuc /*
144ebfedea0SLionel Sambuc *
145ebfedea0SLionel Sambuc */
146ebfedea0SLionel Sambuc
147ebfedea0SLionel Sambuc static int
get_cred(struct kafs_data * data,const char * name,const char * inst,const char * realm,uid_t uid,struct kafs_token * kt)148ebfedea0SLionel Sambuc get_cred(struct kafs_data *data, const char *name, const char *inst,
149ebfedea0SLionel Sambuc const char *realm, uid_t uid, struct kafs_token *kt)
150ebfedea0SLionel Sambuc {
151ebfedea0SLionel Sambuc krb5_error_code ret;
152ebfedea0SLionel Sambuc krb5_creds in_creds, *out_creds;
153ebfedea0SLionel Sambuc struct krb5_kafs_data *d = data->data;
154ebfedea0SLionel Sambuc int invalid;
155ebfedea0SLionel Sambuc
156ebfedea0SLionel Sambuc memset(&in_creds, 0, sizeof(in_creds));
157ebfedea0SLionel Sambuc
158ebfedea0SLionel Sambuc ret = krb5_make_principal(d->context, &in_creds.server,
159ebfedea0SLionel Sambuc realm, name, inst, NULL);
160ebfedea0SLionel Sambuc if(ret)
161ebfedea0SLionel Sambuc return ret;
162ebfedea0SLionel Sambuc ret = krb5_cc_get_principal(d->context, d->id, &in_creds.client);
163ebfedea0SLionel Sambuc if(ret){
164ebfedea0SLionel Sambuc krb5_free_principal(d->context, in_creds.server);
165ebfedea0SLionel Sambuc return ret;
166ebfedea0SLionel Sambuc }
167ebfedea0SLionel Sambuc
168ebfedea0SLionel Sambuc in_creds.session.keytype = ETYPE_DES_CBC_CRC;
169ebfedea0SLionel Sambuc
170ebfedea0SLionel Sambuc /* check if des is disable, and in that case enable it for afs */
171ebfedea0SLionel Sambuc invalid = krb5_enctype_valid(d->context, in_creds.session.keytype);
172ebfedea0SLionel Sambuc if (invalid)
173ebfedea0SLionel Sambuc krb5_enctype_enable(d->context, in_creds.session.keytype);
174ebfedea0SLionel Sambuc
175ebfedea0SLionel Sambuc ret = krb5_get_credentials(d->context, 0, d->id, &in_creds, &out_creds);
176*0a6a1f1dSLionel Sambuc if (ret) {
177*0a6a1f1dSLionel Sambuc in_creds.session.keytype = ETYPE_DES_CBC_MD5;
178*0a6a1f1dSLionel Sambuc ret = krb5_get_credentials(d->context, 0, d->id, &in_creds, &out_creds);
179*0a6a1f1dSLionel Sambuc }
180ebfedea0SLionel Sambuc
181ebfedea0SLionel Sambuc if (invalid)
182ebfedea0SLionel Sambuc krb5_enctype_disable(d->context, in_creds.session.keytype);
183ebfedea0SLionel Sambuc
184ebfedea0SLionel Sambuc krb5_free_principal(d->context, in_creds.server);
185ebfedea0SLionel Sambuc krb5_free_principal(d->context, in_creds.client);
186ebfedea0SLionel Sambuc if(ret)
187ebfedea0SLionel Sambuc return ret;
188ebfedea0SLionel Sambuc
189ebfedea0SLionel Sambuc ret = v5_convert(d->context, d->id, out_creds, uid,
190ebfedea0SLionel Sambuc (inst != NULL && inst[0] != '\0') ? inst : realm, kt);
191ebfedea0SLionel Sambuc krb5_free_creds(d->context, out_creds);
192ebfedea0SLionel Sambuc
193ebfedea0SLionel Sambuc return ret;
194ebfedea0SLionel Sambuc }
195ebfedea0SLionel Sambuc
196ebfedea0SLionel Sambuc static const char *
get_error(struct kafs_data * data,int error)197ebfedea0SLionel Sambuc get_error(struct kafs_data *data, int error)
198ebfedea0SLionel Sambuc {
199ebfedea0SLionel Sambuc struct krb5_kafs_data *d = data->data;
200ebfedea0SLionel Sambuc return krb5_get_error_message(d->context, error);
201ebfedea0SLionel Sambuc }
202ebfedea0SLionel Sambuc
203ebfedea0SLionel Sambuc static void
free_error(struct kafs_data * data,const char * str)204ebfedea0SLionel Sambuc free_error(struct kafs_data *data, const char *str)
205ebfedea0SLionel Sambuc {
206ebfedea0SLionel Sambuc struct krb5_kafs_data *d = data->data;
207ebfedea0SLionel Sambuc krb5_free_error_message(d->context, str);
208ebfedea0SLionel Sambuc }
209ebfedea0SLionel Sambuc
210ebfedea0SLionel Sambuc static krb5_error_code
afslog_uid_int(struct kafs_data * data,const char * cell,const char * rh,uid_t uid,const char * homedir)211ebfedea0SLionel Sambuc afslog_uid_int(struct kafs_data *data, const char *cell, const char *rh,
212ebfedea0SLionel Sambuc uid_t uid, const char *homedir)
213ebfedea0SLionel Sambuc {
214ebfedea0SLionel Sambuc krb5_error_code ret;
215ebfedea0SLionel Sambuc struct kafs_token kt;
216ebfedea0SLionel Sambuc krb5_principal princ;
217ebfedea0SLionel Sambuc const char *trealm; /* ticket realm */
218ebfedea0SLionel Sambuc struct krb5_kafs_data *d = data->data;
219ebfedea0SLionel Sambuc
220ebfedea0SLionel Sambuc if (cell == 0 || cell[0] == 0)
221ebfedea0SLionel Sambuc return _kafs_afslog_all_local_cells (data, uid, homedir);
222ebfedea0SLionel Sambuc
223ebfedea0SLionel Sambuc ret = krb5_cc_get_principal (d->context, d->id, &princ);
224ebfedea0SLionel Sambuc if (ret)
225ebfedea0SLionel Sambuc return ret;
226ebfedea0SLionel Sambuc
227ebfedea0SLionel Sambuc trealm = krb5_principal_get_realm (d->context, princ);
228ebfedea0SLionel Sambuc
229ebfedea0SLionel Sambuc kt.ticket = NULL;
230ebfedea0SLionel Sambuc ret = _kafs_get_cred(data, cell, d->realm, trealm, uid, &kt);
231ebfedea0SLionel Sambuc krb5_free_principal (d->context, princ);
232ebfedea0SLionel Sambuc
233ebfedea0SLionel Sambuc if(ret == 0) {
234ebfedea0SLionel Sambuc ret = kafs_settoken_rxkad(cell, &kt.ct, kt.ticket, kt.ticket_len);
235ebfedea0SLionel Sambuc free(kt.ticket);
236ebfedea0SLionel Sambuc }
237ebfedea0SLionel Sambuc return ret;
238ebfedea0SLionel Sambuc }
239ebfedea0SLionel Sambuc
240ebfedea0SLionel Sambuc static char *
get_realm(struct kafs_data * data,const char * host)241ebfedea0SLionel Sambuc get_realm(struct kafs_data *data, const char *host)
242ebfedea0SLionel Sambuc {
243ebfedea0SLionel Sambuc struct krb5_kafs_data *d = data->data;
244ebfedea0SLionel Sambuc krb5_realm *realms;
245ebfedea0SLionel Sambuc char *r;
246ebfedea0SLionel Sambuc if(krb5_get_host_realm(d->context, host, &realms))
247ebfedea0SLionel Sambuc return NULL;
248ebfedea0SLionel Sambuc r = strdup(realms[0]);
249ebfedea0SLionel Sambuc krb5_free_host_realm(d->context, realms);
250ebfedea0SLionel Sambuc return r;
251ebfedea0SLionel Sambuc }
252ebfedea0SLionel Sambuc
253ebfedea0SLionel Sambuc krb5_error_code
krb5_afslog_uid_home(krb5_context context,krb5_ccache id,const char * cell,krb5_const_realm realm,uid_t uid,const char * homedir)254ebfedea0SLionel Sambuc krb5_afslog_uid_home(krb5_context context,
255ebfedea0SLionel Sambuc krb5_ccache id,
256ebfedea0SLionel Sambuc const char *cell,
257ebfedea0SLionel Sambuc krb5_const_realm realm,
258ebfedea0SLionel Sambuc uid_t uid,
259ebfedea0SLionel Sambuc const char *homedir)
260ebfedea0SLionel Sambuc {
261ebfedea0SLionel Sambuc struct kafs_data kd;
262ebfedea0SLionel Sambuc struct krb5_kafs_data d;
263ebfedea0SLionel Sambuc krb5_error_code ret;
264ebfedea0SLionel Sambuc
265ebfedea0SLionel Sambuc kd.name = "krb5";
266ebfedea0SLionel Sambuc kd.afslog_uid = afslog_uid_int;
267ebfedea0SLionel Sambuc kd.get_cred = get_cred;
268ebfedea0SLionel Sambuc kd.get_realm = get_realm;
269ebfedea0SLionel Sambuc kd.get_error = get_error;
270ebfedea0SLionel Sambuc kd.free_error = free_error;
271ebfedea0SLionel Sambuc kd.data = &d;
272ebfedea0SLionel Sambuc if (context == NULL) {
273ebfedea0SLionel Sambuc ret = krb5_init_context(&d.context);
274ebfedea0SLionel Sambuc if (ret)
275ebfedea0SLionel Sambuc return ret;
276ebfedea0SLionel Sambuc } else
277ebfedea0SLionel Sambuc d.context = context;
278ebfedea0SLionel Sambuc if (id == NULL) {
279ebfedea0SLionel Sambuc ret = krb5_cc_default(d.context, &d.id);
280ebfedea0SLionel Sambuc if (ret)
281ebfedea0SLionel Sambuc goto out;
282ebfedea0SLionel Sambuc } else
283ebfedea0SLionel Sambuc d.id = id;
284ebfedea0SLionel Sambuc d.realm = realm;
285ebfedea0SLionel Sambuc ret = afslog_uid_int(&kd, cell, 0, uid, homedir);
286ebfedea0SLionel Sambuc if (id == NULL)
287ebfedea0SLionel Sambuc krb5_cc_close(context, d.id);
288ebfedea0SLionel Sambuc out:
289ebfedea0SLionel Sambuc if (context == NULL)
290ebfedea0SLionel Sambuc krb5_free_context(d.context);
291ebfedea0SLionel Sambuc return ret;
292ebfedea0SLionel Sambuc }
293ebfedea0SLionel Sambuc
294ebfedea0SLionel Sambuc krb5_error_code
krb5_afslog_uid(krb5_context context,krb5_ccache id,const char * cell,krb5_const_realm realm,uid_t uid)295ebfedea0SLionel Sambuc krb5_afslog_uid(krb5_context context,
296ebfedea0SLionel Sambuc krb5_ccache id,
297ebfedea0SLionel Sambuc const char *cell,
298ebfedea0SLionel Sambuc krb5_const_realm realm,
299ebfedea0SLionel Sambuc uid_t uid)
300ebfedea0SLionel Sambuc {
301ebfedea0SLionel Sambuc return krb5_afslog_uid_home (context, id, cell, realm, uid, NULL);
302ebfedea0SLionel Sambuc }
303ebfedea0SLionel Sambuc
304ebfedea0SLionel Sambuc krb5_error_code
krb5_afslog(krb5_context context,krb5_ccache id,const char * cell,krb5_const_realm realm)305ebfedea0SLionel Sambuc krb5_afslog(krb5_context context,
306ebfedea0SLionel Sambuc krb5_ccache id,
307ebfedea0SLionel Sambuc const char *cell,
308ebfedea0SLionel Sambuc krb5_const_realm realm)
309ebfedea0SLionel Sambuc {
310ebfedea0SLionel Sambuc return krb5_afslog_uid (context, id, cell, realm, getuid());
311ebfedea0SLionel Sambuc }
312ebfedea0SLionel Sambuc
313ebfedea0SLionel Sambuc krb5_error_code
krb5_afslog_home(krb5_context context,krb5_ccache id,const char * cell,krb5_const_realm realm,const char * homedir)314ebfedea0SLionel Sambuc krb5_afslog_home(krb5_context context,
315ebfedea0SLionel Sambuc krb5_ccache id,
316ebfedea0SLionel Sambuc const char *cell,
317ebfedea0SLionel Sambuc krb5_const_realm realm,
318ebfedea0SLionel Sambuc const char *homedir)
319ebfedea0SLionel Sambuc {
320ebfedea0SLionel Sambuc return krb5_afslog_uid_home (context, id, cell, realm, getuid(), homedir);
321ebfedea0SLionel Sambuc }
322ebfedea0SLionel Sambuc
323ebfedea0SLionel Sambuc /*
324ebfedea0SLionel Sambuc *
325ebfedea0SLionel Sambuc */
326ebfedea0SLionel Sambuc
327ebfedea0SLionel Sambuc krb5_error_code
krb5_realm_of_cell(const char * cell,char ** realm)328ebfedea0SLionel Sambuc krb5_realm_of_cell(const char *cell, char **realm)
329ebfedea0SLionel Sambuc {
330ebfedea0SLionel Sambuc struct kafs_data kd;
331ebfedea0SLionel Sambuc
332ebfedea0SLionel Sambuc kd.name = "krb5";
333ebfedea0SLionel Sambuc kd.get_realm = get_realm;
334ebfedea0SLionel Sambuc kd.get_error = get_error;
335ebfedea0SLionel Sambuc kd.free_error = free_error;
336ebfedea0SLionel Sambuc return _kafs_realm_of_cell(&kd, cell, realm);
337ebfedea0SLionel Sambuc }
338ebfedea0SLionel Sambuc
339ebfedea0SLionel Sambuc /*
340ebfedea0SLionel Sambuc *
341ebfedea0SLionel Sambuc */
342ebfedea0SLionel Sambuc
343ebfedea0SLionel Sambuc int
kafs_settoken5(krb5_context context,const char * cell,uid_t uid,krb5_creds * cred)344ebfedea0SLionel Sambuc kafs_settoken5(krb5_context context, const char *cell, uid_t uid,
345ebfedea0SLionel Sambuc krb5_creds *cred)
346ebfedea0SLionel Sambuc {
347ebfedea0SLionel Sambuc struct kafs_token kt;
348ebfedea0SLionel Sambuc int ret;
349ebfedea0SLionel Sambuc
350ebfedea0SLionel Sambuc ret = v5_convert(context, NULL, cred, uid, cell, &kt);
351ebfedea0SLionel Sambuc if (ret)
352ebfedea0SLionel Sambuc return ret;
353ebfedea0SLionel Sambuc
354ebfedea0SLionel Sambuc ret = kafs_settoken_rxkad(cell, &kt.ct, kt.ticket, kt.ticket_len);
355ebfedea0SLionel Sambuc
356ebfedea0SLionel Sambuc free(kt.ticket);
357ebfedea0SLionel Sambuc
358ebfedea0SLionel Sambuc return ret;
359ebfedea0SLionel Sambuc }
360