Rearrange moonshot to have libeap as a subproject
[moonshot.git] / moonshot / mech_eap / util_radius.cpp
1 /*
2  * Copyright (c) 2011, JANET(UK)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of JANET(UK) nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32
33 /*
34  * RADIUS attribute provider implementation.
35  */
36
37 #include "gssapiP_eap.h"
38
39 /* stuff that should be provided by libradsec/libfreeradius-radius */
40 #define VENDORATTR(vendor, attr)            (((vendor) << 16) | (attr))
41
42 #ifndef ATTRID
43 #define ATTRID(attr)                        ((attr) & 0xFFFF)
44 #endif
45
46 static gss_buffer_desc radiusUrnPrefix = {
47     sizeof("urn:x-radius:") - 1,
48     (void *)"urn:x-radius:"
49 };
50
51 static VALUE_PAIR *copyAvps(const VALUE_PAIR *src);
52
53 gss_eap_radius_attr_provider::gss_eap_radius_attr_provider(void)
54 {
55     m_vps = NULL;
56     m_authenticated = false;
57 }
58
59 gss_eap_radius_attr_provider::~gss_eap_radius_attr_provider(void)
60 {
61     if (m_vps != NULL)
62         pairfree(&m_vps);
63 }
64
65 bool
66 gss_eap_radius_attr_provider::initWithExistingContext(const gss_eap_attr_ctx *manager,
67                                                       const gss_eap_attr_provider *ctx)
68 {
69     const gss_eap_radius_attr_provider *radius;
70
71     if (!gss_eap_attr_provider::initWithExistingContext(manager, ctx))
72         return false;
73
74     radius = static_cast<const gss_eap_radius_attr_provider *>(ctx);
75
76     if (radius->m_vps != NULL)
77         m_vps = copyAvps(const_cast<VALUE_PAIR *>(radius->getAvps()));
78
79     m_authenticated = radius->m_authenticated;
80
81     return true;
82 }
83
84 bool
85 gss_eap_radius_attr_provider::initWithGssContext(const gss_eap_attr_ctx *manager,
86                                                  const gss_cred_id_t gssCred,
87                                                  const gss_ctx_id_t gssCtx)
88 {
89     if (!gss_eap_attr_provider::initWithGssContext(manager, gssCred, gssCtx))
90         return false;
91
92     if (gssCtx != GSS_C_NO_CONTEXT) {
93         if (gssCtx->acceptorCtx.vps != NULL) {
94             m_vps = copyAvps(gssCtx->acceptorCtx.vps);
95             if (m_vps == NULL)
96                 return false;
97
98             /* We assume libradsec validated this for us */
99             assert(pairfind(m_vps, PW_MESSAGE_AUTHENTICATOR) != NULL);
100             m_authenticated = true;
101         }
102     }
103
104     return true;
105 }
106
107 static bool
108 alreadyAddedAttributeP(std::vector <std::string> &attrs, VALUE_PAIR *vp)
109 {
110     for (std::vector<std::string>::const_iterator a = attrs.begin();
111          a != attrs.end();
112          ++a) {
113         if (strcmp(vp->name, (*a).c_str()) == 0)
114             return true;
115     }
116
117     return false;
118 }
119
120 static bool
121 isSecretAttributeP(uint16_t attrid, uint16_t vendor)
122 {
123     bool bSecretAttribute = false;
124
125     switch (vendor) {
126     case VENDORPEC_MS:
127         switch (attrid) {
128         case PW_MS_MPPE_SEND_KEY:
129         case PW_MS_MPPE_RECV_KEY:
130             bSecretAttribute = true;
131             break;
132         default:
133             break;
134         }
135     default:
136         break;
137     }
138
139     return bSecretAttribute;
140 }
141
142 static bool
143 isSecretAttributeP(uint32_t attribute)
144 {
145     return isSecretAttributeP(ATTRID(attribute), VENDOR(attribute));
146 }
147
148 static bool
149 isInternalAttributeP(uint16_t attrid, uint16_t vendor)
150 {
151     bool bInternalAttribute = false;
152
153     /* should have been filtered */
154     assert(!isSecretAttributeP(attrid, vendor));
155
156     switch (vendor) {
157     case VENDORPEC_UKERNA:
158         bInternalAttribute = true;
159         break;
160     default:
161         break;
162     }
163
164     return bInternalAttribute;
165 }
166
167 static bool
168 isInternalAttributeP(uint32_t attribute)
169 {
170     return isInternalAttributeP(ATTRID(attribute), VENDOR(attribute));
171 }
172
173 /*
174  * Copy AVP list, same as paircopy except it filters out attributes
175  * containing keys.
176  */
177 static VALUE_PAIR *
178 copyAvps(const VALUE_PAIR *src)
179 {
180     const VALUE_PAIR *vp;
181     VALUE_PAIR *dst = NULL, **pDst = &dst;
182
183     for (vp = src; vp != NULL; vp = vp->next) {
184         VALUE_PAIR *vpcopy;
185
186         if (isSecretAttributeP(vp->attribute))
187             continue;
188
189         vpcopy = paircopyvp(vp);
190         if (vpcopy == NULL) {
191             pairfree(&dst);
192             throw std::bad_alloc();
193         }
194         *pDst = vpcopy;
195         pDst = &vpcopy->next;
196      }
197
198     return dst;
199 }
200
201 bool
202 gss_eap_radius_attr_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAttribute,
203                                                 void *data) const
204 {
205     VALUE_PAIR *vp;
206     std::vector <std::string> seen;
207
208     for (vp = m_vps; vp != NULL; vp = vp->next) {
209         gss_buffer_desc attribute;
210         char attrid[64];
211
212         /* Don't advertise attributes that are internal to the GSS-EAP mechanism */
213         if (isInternalAttributeP(vp->attribute))
214             continue;
215
216         if (alreadyAddedAttributeP(seen, vp))
217             continue;
218
219         snprintf(attrid, sizeof(attrid), "%s%d",
220             (char *)radiusUrnPrefix.value, vp->attribute);
221
222         attribute.value = attrid;
223         attribute.length = strlen(attrid);
224
225         if (!addAttribute(m_manager, this, &attribute, data))
226             return false;
227
228         seen.push_back(std::string(vp->name));
229     }
230
231     return true;
232 }
233
234 uint32_t
235 getAttributeId(const gss_buffer_t attr)
236 {
237     OM_uint32 tmpMinor;
238     gss_buffer_desc strAttr = GSS_C_EMPTY_BUFFER;
239     DICT_ATTR *da;
240     char *s;
241     uint32_t attrid = 0;
242
243     if (attr->length < radiusUrnPrefix.length ||
244         memcmp(attr->value, radiusUrnPrefix.value, radiusUrnPrefix.length) != 0)
245         return 0;
246
247     /* need to duplicate because attr may not be NUL terminated */
248     duplicateBuffer(*attr, &strAttr);
249     s = (char *)strAttr.value + radiusUrnPrefix.length;
250
251     if (isdigit(*s)) {
252         attrid = strtoul(s, NULL, 10);
253     } else {
254         da = dict_attrbyname(s);
255         if (da != NULL)
256             attrid = da->attr;
257     }
258
259     gss_release_buffer(&tmpMinor, &strAttr);
260
261     return attrid;
262 }
263
264 bool
265 gss_eap_radius_attr_provider::setAttribute(int complete GSSEAP_UNUSED,
266                                            uint32_t attrid,
267                                            const gss_buffer_t value)
268 {
269     OM_uint32 major = GSS_S_UNAVAILABLE, minor;
270
271     if (!isSecretAttributeP(attrid) &&
272         !isInternalAttributeP(attrid)) {
273         deleteAttribute(attrid);
274
275         major = gssEapRadiusAddAvp(&minor, &m_vps,
276                                    ATTRID(attrid), VENDOR(attrid), 
277                                    value);
278     }
279
280     return !GSS_ERROR(major);
281 }
282
283 bool
284 gss_eap_radius_attr_provider::setAttribute(int complete,
285                                            const gss_buffer_t attr,
286                                            const gss_buffer_t value)
287 {
288     uint32_t attrid = getAttributeId(attr);
289
290     if (!attrid)
291         return false;
292
293     return setAttribute(complete, attrid, value);
294 }
295
296 bool
297 gss_eap_radius_attr_provider::deleteAttribute(uint32_t attrid)
298 {
299     if (isSecretAttributeP(attrid) || isInternalAttributeP(attrid) ||
300         pairfind(m_vps, attrid) == NULL)
301         return false;
302
303     pairdelete(&m_vps, attrid);
304
305     return true;
306 }
307
308 bool
309 gss_eap_radius_attr_provider::deleteAttribute(const gss_buffer_t attr)
310 {
311     uint32_t attrid = getAttributeId(attr);
312
313     if (!attrid)
314         return false;
315
316     return deleteAttribute(attrid);
317 }
318
319 bool
320 gss_eap_radius_attr_provider::getAttribute(const gss_buffer_t attr,
321                                            int *authenticated,
322                                            int *complete,
323                                            gss_buffer_t value,
324                                            gss_buffer_t display_value,
325                                            int *more) const
326 {
327     uint32_t attrid;
328
329     attrid = getAttributeId(attr);
330     if (!attrid)
331         return false;
332
333     return getAttribute(attrid, authenticated, complete,
334                         value, display_value, more);
335 }
336
337 bool
338 gss_eap_radius_attr_provider::getAttribute(uint32_t attrid,
339                                            int *authenticated,
340                                            int *complete,
341                                            gss_buffer_t value,
342                                            gss_buffer_t display_value,
343                                            int *more) const
344 {
345     VALUE_PAIR *vp;
346     int i = *more, count = 0;
347
348     *more = 0;
349
350     if (i == -1)
351         i = 0;
352
353     for (vp = pairfind(m_vps, attrid);
354          vp != NULL;
355          vp = pairfind(vp->next, attrid)) {
356         if (count++ == i) {
357             if (pairfind(vp->next, attrid) != NULL)
358                 *more = count;
359             break;
360         }
361     }
362
363     if (vp == NULL && *more == 0)
364         return false;
365
366     if (value != GSS_C_NO_BUFFER) {
367         gss_buffer_desc valueBuf;
368
369         valueBuf.value = (void *)vp->vp_octets;
370         valueBuf.length = vp->length;
371
372         duplicateBuffer(valueBuf, value);
373     }
374
375     if (display_value != GSS_C_NO_BUFFER) {
376         char displayString[MAX_STRING_LEN];
377         gss_buffer_desc displayBuf;
378
379         displayBuf.length = vp_prints_value(displayString,
380                                             sizeof(displayString), vp, 0);
381         displayBuf.value = (void *)displayString;
382
383         duplicateBuffer(displayBuf, display_value);
384     }
385
386     if (authenticated != NULL)
387         *authenticated = m_authenticated;
388     if (complete != NULL)
389         *complete = true;
390
391     return true;
392 }
393
394 bool
395 gss_eap_radius_attr_provider::getFragmentedAttribute(uint16_t attribute,
396                                                      uint16_t vendor,
397                                                      int *authenticated,
398                                                      int *complete,
399                                                      gss_buffer_t value) const
400 {
401     OM_uint32 major, minor;
402
403     major = gssEapRadiusGetAvp(&minor, m_vps, attribute, vendor, value, TRUE);
404
405     if (authenticated != NULL)
406         *authenticated = m_authenticated;
407     if (complete != NULL)
408         *complete = true;
409
410     return !GSS_ERROR(major);
411 }
412
413 bool
414 gss_eap_radius_attr_provider::getAttribute(uint16_t attribute,
415                                            uint16_t vendor,
416                                            int *authenticated,
417                                            int *complete,
418                                            gss_buffer_t value,
419                                            gss_buffer_t display_value,
420                                            int *more) const
421 {
422
423     return getAttribute(VENDORATTR(attribute, vendor),
424                         authenticated, complete,
425                         value, display_value, more);
426 }
427
428 gss_any_t
429 gss_eap_radius_attr_provider::mapToAny(int authenticated,
430                                        gss_buffer_t type_id GSSEAP_UNUSED) const
431 {
432     if (authenticated && !m_authenticated)
433         return (gss_any_t)NULL;
434
435     return (gss_any_t)copyAvps(m_vps);
436 }
437
438 void
439 gss_eap_radius_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id GSSEAP_UNUSED,
440                                                     gss_any_t input) const
441 {
442     VALUE_PAIR *vp = (VALUE_PAIR *)input;
443     pairfree(&vp);
444 }
445
446 bool
447 gss_eap_radius_attr_provider::init(void)
448 {
449     struct rs_context *radContext;
450
451     gss_eap_attr_ctx::registerProvider(ATTR_TYPE_RADIUS, createAttrContext);
452
453 #if 1
454     /*
455      * This hack is necessary in order to force the loading of the global
456      * dictionary, otherwise accepting reauthentication tokens fails unless
457      * the acceptor has already accepted a normal authentication token.
458      */
459     if (rs_context_create(&radContext) != 0)
460         return false;
461
462     if (rs_context_read_config(radContext, RS_CONFIG_FILE) != 0) {
463         rs_context_destroy(radContext);
464         return false;
465     }
466
467     if (rs_context_init_freeradius_dict(radContext, NULL)) {
468         rs_context_destroy(radContext);
469         return false;
470     }
471
472     rs_context_destroy(radContext);
473 #endif
474
475     return true;
476 }
477
478 void
479 gss_eap_radius_attr_provider::finalize(void)
480 {
481     gss_eap_attr_ctx::unregisterProvider(ATTR_TYPE_RADIUS);
482 }
483
484 gss_eap_attr_provider *
485 gss_eap_radius_attr_provider::createAttrContext(void)
486 {
487     return new gss_eap_radius_attr_provider;
488 }
489
490 OM_uint32
491 gssEapRadiusAddAvp(OM_uint32 *minor,
492                    VALUE_PAIR **vps,
493                    uint16_t attribute,
494                    uint16_t vendor,
495                    const gss_buffer_t buffer)
496 {
497     uint32_t attrid = VENDORATTR(vendor, attribute);
498     unsigned char *p = (unsigned char *)buffer->value;
499     size_t remain = buffer->length;
500
501     do {
502         VALUE_PAIR *vp;
503         size_t n = remain;
504
505         /*
506          * There's an extra byte of padding; RADIUS AVPs can only
507          * be 253 octets.
508          */
509         if (n >= MAX_STRING_LEN)
510             n = MAX_STRING_LEN - 1;
511
512         vp = paircreate(attrid, PW_TYPE_OCTETS);
513         if (vp == NULL) {
514             *minor = ENOMEM;
515             return GSS_S_FAILURE;
516         }
517
518         memcpy(vp->vp_octets, p, n);
519         vp->length = n;
520
521         pairadd(vps, vp);
522
523         p += n;
524         remain -= n;
525     } while (remain != 0);
526
527     return GSS_S_COMPLETE;
528 }
529
530 OM_uint32
531 gssEapRadiusGetRawAvp(OM_uint32 *minor,
532                       VALUE_PAIR *vps,
533                       uint16_t attribute,
534                       uint16_t vendor,
535                       VALUE_PAIR **vp)
536 {
537     uint32_t attr = VENDORATTR(vendor, attribute);
538
539     *vp = pairfind(vps, attr);
540     if (*vp == NULL) {
541         *minor = GSSEAP_NO_SUCH_ATTR;
542         return GSS_S_UNAVAILABLE;
543     }
544
545     return GSS_S_COMPLETE;
546 }
547
548 OM_uint32
549 gssEapRadiusGetAvp(OM_uint32 *minor,
550                    VALUE_PAIR *vps,
551                    uint16_t attribute,
552                    uint16_t vendor,
553                    gss_buffer_t buffer,
554                    int concat)
555 {
556     VALUE_PAIR *vp;
557     unsigned char *p;
558     uint32_t attr = VENDORATTR(vendor, attribute);
559
560     buffer->length = 0;
561     buffer->value = NULL;
562
563     vp = pairfind(vps, attr);
564     if (vp == NULL) {
565         *minor = GSSEAP_NO_SUCH_ATTR;
566         return GSS_S_UNAVAILABLE;
567     }
568
569     do {
570         buffer->length += vp->length;
571     } while (concat && (vp = pairfind(vp->next, attr)) != NULL);
572
573     buffer->value = GSSEAP_MALLOC(buffer->length);
574     if (buffer->value == NULL) {
575         *minor = ENOMEM;
576         return GSS_S_FAILURE;
577     }
578
579     p = (unsigned char *)buffer->value;
580
581     for (vp = pairfind(vps, attr);
582          concat && vp != NULL;
583          vp = pairfind(vp->next, attr)) {
584         memcpy(p, vp->vp_octets, vp->length);
585         p += vp->length;
586     }
587
588     *minor = 0;
589     return GSS_S_COMPLETE;
590 }
591
592 OM_uint32
593 gssEapRadiusFreeAvps(OM_uint32 *minor,
594                      VALUE_PAIR **vps)
595 {
596     pairfree(vps);
597     *minor = 0;
598     return GSS_S_COMPLETE;
599 }
600
601 OM_uint32
602 gssEapRadiusAttrProviderInit(OM_uint32 *minor)
603 {
604     if (!gss_eap_radius_attr_provider::init()) {
605         *minor = GSSEAP_RADSEC_INIT_FAILURE;
606         return GSS_S_FAILURE;
607     }
608
609     return GSS_S_COMPLETE;
610 }
611
612 OM_uint32
613 gssEapRadiusAttrProviderFinalize(OM_uint32 *minor)
614 {
615     gss_eap_radius_attr_provider::finalize();
616
617     *minor = 0;
618     return GSS_S_COMPLETE;
619 }
620
621 static JSONObject
622 avpToJson(const VALUE_PAIR *vp)
623 {
624     JSONObject obj;
625
626     assert(vp->length <= MAX_STRING_LEN);
627
628     switch (vp->type) {
629     case PW_TYPE_INTEGER:
630     case PW_TYPE_IPADDR:
631     case PW_TYPE_DATE:
632         obj.set("value", vp->lvalue);
633         break;
634     case PW_TYPE_STRING:
635         obj.set("value", vp->vp_strvalue);
636         break;
637     default: {
638         char *b64;
639
640         if (base64Encode(vp->vp_octets, vp->length, &b64) < 0)
641             throw std::bad_alloc();
642
643         obj.set("value", b64);
644         GSSEAP_FREE(b64);
645         break;
646     }
647     }
648
649     obj.set("type", vp->attribute);
650
651     return obj;
652 }
653
654 static bool
655 jsonToAvp(VALUE_PAIR **pVp, JSONObject &obj)
656 {
657     VALUE_PAIR *vp = NULL;
658     DICT_ATTR *da;
659     uint32_t attrid;
660
661     JSONObject type = obj["type"];
662     JSONObject value = obj["value"];
663
664     if (!type.isInteger())
665         goto fail;
666
667     attrid = type.integer();
668     da = dict_attrbyvalue(attrid);
669     if (da != NULL) {
670         vp = pairalloc(da);
671     } else {
672         int type = base64Valid(value.string()) ?
673             PW_TYPE_OCTETS : PW_TYPE_STRING;
674         vp = paircreate(attrid, type);
675     }
676     if (vp == NULL)
677         throw std::bad_alloc();
678
679     switch (vp->type) {
680     case PW_TYPE_INTEGER:
681     case PW_TYPE_IPADDR:
682     case PW_TYPE_DATE:
683         if (!value.isInteger())
684             goto fail;
685
686         vp->length = 4;
687         vp->lvalue = value.integer();
688         break;
689     case PW_TYPE_STRING: {
690         if (!value.isString())
691             goto fail;
692
693         const char *str = value.string();
694         size_t len = strlen(str);
695
696         if (len >= MAX_STRING_LEN)
697             goto fail;
698
699         vp->length = len;
700         memcpy(vp->vp_strvalue, str, len + 1);
701         break;
702     }
703     case PW_TYPE_OCTETS:
704     default: {
705         if (!value.isString())
706             goto fail;
707
708         const char *str = value.string();
709         ssize_t len = strlen(str);
710
711         /* this optimization requires base64Decode only understand packed encoding */
712         if (len >= BASE64_EXPAND(MAX_STRING_LEN))
713             goto fail;
714
715         len = base64Decode(str, vp->vp_octets);
716         if (len < 0)
717             goto fail;
718
719         vp->length = len;
720         break;
721     }
722     }
723
724     *pVp = vp;
725
726     return true;
727
728 fail:
729     if (vp != NULL)
730         pairbasicfree(vp);
731     *pVp = NULL;
732     return false;
733 }
734
735 const char *
736 gss_eap_radius_attr_provider::name(void) const
737 {
738     return "radius";
739 }
740
741 bool
742 gss_eap_radius_attr_provider::initWithJsonObject(const gss_eap_attr_ctx *ctx,
743                                                  JSONObject &obj)
744 {
745     VALUE_PAIR **pNext = &m_vps;
746
747     if (!gss_eap_attr_provider::initWithJsonObject(ctx, obj))
748         return false;
749
750     JSONObject attrs = obj["attributes"];
751     size_t nelems = attrs.size();
752
753     for (size_t i = 0; i < nelems; i++) {
754         JSONObject attr = attrs[i];
755         VALUE_PAIR *vp;
756
757         if (!jsonToAvp(&vp, attr))
758             return false;
759
760         *pNext = vp;
761         pNext = &vp->next;
762     }
763
764     m_authenticated = obj["authenticated"].integer();
765
766     return true;
767 }
768
769 const char *
770 gss_eap_radius_attr_provider::prefix(void) const
771 {
772     return "urn:ietf:params:gss-eap:radius-avp";
773 }
774
775 JSONObject
776 gss_eap_radius_attr_provider::jsonRepresentation(void) const
777 {
778     JSONObject obj, attrs = JSONObject::array();
779
780     for (VALUE_PAIR *vp = m_vps; vp != NULL; vp = vp->next) {
781         JSONObject attr = avpToJson(vp);
782         attrs.append(attr);
783     }
784
785     obj.set("attributes", attrs);
786
787     obj.set("authenticated", m_authenticated);
788
789     return obj;
790 }
791
792 time_t
793 gss_eap_radius_attr_provider::getExpiryTime(void) const
794 {
795     VALUE_PAIR *vp;
796
797     vp = pairfind(m_vps, PW_SESSION_TIMEOUT);
798     if (vp == NULL || vp->lvalue == 0)
799         return 0;
800
801     return time(NULL) + vp->lvalue;
802 }
803
804 OM_uint32
805 gssEapRadiusMapError(OM_uint32 *minor,
806                      struct rs_error *err)
807 {
808     int code;
809
810     assert(err != NULL);
811
812     code = rs_err_code(err, 0);
813
814     if (code == RSE_OK) {
815         *minor = 0;
816         return GSS_S_COMPLETE;
817     }
818
819     *minor = ERROR_TABLE_BASE_rse + code;
820
821     gssEapSaveStatusInfo(*minor, "%s", rs_err_msg(err));
822     rs_err_free(err);
823
824     return GSS_S_FAILURE;
825 }