17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * lib/krb5/krb/ser_ctx.c
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * Copyright 1995 by the Massachusetts Institute of Technology.
57c478bd9Sstevel@tonic-gate * All Rights Reserved.
67c478bd9Sstevel@tonic-gate *
77c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may
87c478bd9Sstevel@tonic-gate * require a specific license from the United States Government.
97c478bd9Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating
107c478bd9Sstevel@tonic-gate * export to obtain such a license before exporting.
117c478bd9Sstevel@tonic-gate *
127c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
137c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and
147c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright
157c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and
167c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that
177c478bd9Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining
187c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior
197c478bd9Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label
207c478bd9Sstevel@tonic-gate * your software as modified software and not distribute it in such a
217c478bd9Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software.
227c478bd9Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of
237c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express
247c478bd9Sstevel@tonic-gate * or implied warranty.
257c478bd9Sstevel@tonic-gate *
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate * ser_ctx.c - Routines to deal with serializing the krb5_context and
307c478bd9Sstevel@tonic-gate * krb5_os_context structures.
317c478bd9Sstevel@tonic-gate */
32159d09a2SMark Phalan #include "k5-int.h"
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate * Routines to deal with externalizing the krb5_context:
367c478bd9Sstevel@tonic-gate * krb5_context_size();
377c478bd9Sstevel@tonic-gate * krb5_context_externalize();
387c478bd9Sstevel@tonic-gate * krb5_context_internalize();
39*55fea89dSDan Cross *
407c478bd9Sstevel@tonic-gate * Routines to deal with externalizing the krb5_os_context:
417c478bd9Sstevel@tonic-gate * krb5_oscontext_size();
427c478bd9Sstevel@tonic-gate * krb5_oscontext_externalize();
437c478bd9Sstevel@tonic-gate * krb5_oscontext_internalize();
447c478bd9Sstevel@tonic-gate *
457c478bd9Sstevel@tonic-gate * Routines to deal with externalizing the profile.
467c478bd9Sstevel@tonic-gate * profile_ser_size();
477c478bd9Sstevel@tonic-gate * profile_ser_externalize();
487c478bd9Sstevel@tonic-gate * profile_ser_internalize();
497c478bd9Sstevel@tonic-gate *
507c478bd9Sstevel@tonic-gate * Interface to initialize serializing of krb5_context and krb5_os_context:
517c478bd9Sstevel@tonic-gate * krb5_ser_context_init();
527c478bd9Sstevel@tonic-gate */
537c478bd9Sstevel@tonic-gate static krb5_error_code krb5_context_size
54505d05c7Sgtb (krb5_context, krb5_pointer, size_t *);
557c478bd9Sstevel@tonic-gate static krb5_error_code krb5_context_externalize
56505d05c7Sgtb (krb5_context, krb5_pointer, krb5_octet **, size_t *);
577c478bd9Sstevel@tonic-gate static krb5_error_code krb5_context_internalize
58505d05c7Sgtb (krb5_context,krb5_pointer *, krb5_octet **, size_t *);
597c478bd9Sstevel@tonic-gate static krb5_error_code krb5_oscontext_size
60505d05c7Sgtb (krb5_context, krb5_pointer, size_t *);
617c478bd9Sstevel@tonic-gate static krb5_error_code krb5_oscontext_externalize
62505d05c7Sgtb (krb5_context, krb5_pointer, krb5_octet **, size_t *);
637c478bd9Sstevel@tonic-gate static krb5_error_code krb5_oscontext_internalize
64505d05c7Sgtb (krb5_context,krb5_pointer *, krb5_octet **, size_t *);
657c478bd9Sstevel@tonic-gate #ifndef _KERNEL
667c478bd9Sstevel@tonic-gate krb5_error_code profile_ser_size
67505d05c7Sgtb (krb5_context, krb5_pointer, size_t *);
687c478bd9Sstevel@tonic-gate krb5_error_code profile_ser_externalize
69505d05c7Sgtb (krb5_context, krb5_pointer, krb5_octet **, size_t *);
707c478bd9Sstevel@tonic-gate krb5_error_code profile_ser_internalize
71505d05c7Sgtb (krb5_context,krb5_pointer *, krb5_octet **, size_t *);
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate /* Local data */
747c478bd9Sstevel@tonic-gate static const krb5_ser_entry krb5_context_ser_entry = {
757c478bd9Sstevel@tonic-gate KV5M_CONTEXT, /* Type */
767c478bd9Sstevel@tonic-gate krb5_context_size, /* Sizer routine */
777c478bd9Sstevel@tonic-gate krb5_context_externalize, /* Externalize routine */
787c478bd9Sstevel@tonic-gate krb5_context_internalize /* Internalize routine */
797c478bd9Sstevel@tonic-gate };
807c478bd9Sstevel@tonic-gate static const krb5_ser_entry krb5_oscontext_ser_entry = {
817c478bd9Sstevel@tonic-gate KV5M_OS_CONTEXT, /* Type */
827c478bd9Sstevel@tonic-gate krb5_oscontext_size, /* Sizer routine */
837c478bd9Sstevel@tonic-gate krb5_oscontext_externalize, /* Externalize routine */
847c478bd9Sstevel@tonic-gate krb5_oscontext_internalize /* Internalize routine */
857c478bd9Sstevel@tonic-gate };
867c478bd9Sstevel@tonic-gate #ifndef _KERNEL
877c478bd9Sstevel@tonic-gate static const krb5_ser_entry krb5_profile_ser_entry = {
887c478bd9Sstevel@tonic-gate PROF_MAGIC_PROFILE, /* Type */
897c478bd9Sstevel@tonic-gate profile_ser_size, /* Sizer routine */
907c478bd9Sstevel@tonic-gate profile_ser_externalize, /* Externalize routine */
917c478bd9Sstevel@tonic-gate profile_ser_internalize /* Internalize routine */
927c478bd9Sstevel@tonic-gate };
93*55fea89dSDan Cross #endif
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate * krb5_context_size() - Determine the size required to externalize the
977c478bd9Sstevel@tonic-gate * krb5_context.
987c478bd9Sstevel@tonic-gate */
997c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_context_size(krb5_context kcontext,krb5_pointer arg,size_t * sizep)100505d05c7Sgtb krb5_context_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate krb5_error_code kret;
1037c478bd9Sstevel@tonic-gate size_t required;
1047c478bd9Sstevel@tonic-gate krb5_context context;
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate * The KRB5 context itself requires:
1087c478bd9Sstevel@tonic-gate * krb5_int32 for KV5M_CONTEXT
1097c478bd9Sstevel@tonic-gate * krb5_int32 for sizeof(default_realm)
1107c478bd9Sstevel@tonic-gate * strlen(default_realm) for default_realm.
1117c478bd9Sstevel@tonic-gate * krb5_int32 for n_in_tkt_ktypes*sizeof(krb5_int32)
1127c478bd9Sstevel@tonic-gate * nktypes*sizeof(krb5_int32) for in_tkt_ktypes.
1137c478bd9Sstevel@tonic-gate * krb5_int32 for n_tgs_ktypes*sizeof(krb5_int32)
1147c478bd9Sstevel@tonic-gate * nktypes*sizeof(krb5_int32) for tgs_ktypes.
1157c478bd9Sstevel@tonic-gate * krb5_int32 for clockskew
1167c478bd9Sstevel@tonic-gate * krb5_int32 for kdc_req_sumtype
1177c478bd9Sstevel@tonic-gate * krb5_int32 for ap_req_sumtype
1187c478bd9Sstevel@tonic-gate * krb5_int32 for safe_sumtype
1197c478bd9Sstevel@tonic-gate * krb5_int32 for kdc_default_options
1207c478bd9Sstevel@tonic-gate * krb5_int32 for library_options
1217c478bd9Sstevel@tonic-gate * krb5_int32 for profile_secure
1227c478bd9Sstevel@tonic-gate * krb5_int32 for fcc_default_format
1237c478bd9Sstevel@tonic-gate * krb5_int32 for scc_default_format
1247c478bd9Sstevel@tonic-gate * <> for os_context
1257c478bd9Sstevel@tonic-gate * <> for db_context
1267c478bd9Sstevel@tonic-gate * <> for profile
1277c478bd9Sstevel@tonic-gate * krb5_int32 for trailer.
1287c478bd9Sstevel@tonic-gate */
1297c478bd9Sstevel@tonic-gate kret = EINVAL;
130159d09a2SMark Phalan if ((context = (krb5_context) arg)) {
1317c478bd9Sstevel@tonic-gate /* Calculate base length */
1327c478bd9Sstevel@tonic-gate required = (14 * sizeof(krb5_int32) +
1337c478bd9Sstevel@tonic-gate (context->in_tkt_ktype_count * sizeof(krb5_int32)) +
1347c478bd9Sstevel@tonic-gate (context->tgs_ktype_count * sizeof(krb5_int32)));
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate if (context->default_realm)
1377c478bd9Sstevel@tonic-gate required += strlen(context->default_realm);
1387c478bd9Sstevel@tonic-gate /* Calculate size required by os_context, if appropriate */
1397c478bd9Sstevel@tonic-gate if (context->os_context)
1407c478bd9Sstevel@tonic-gate kret = krb5_size_opaque(kcontext,
1417c478bd9Sstevel@tonic-gate KV5M_OS_CONTEXT,
1427c478bd9Sstevel@tonic-gate (krb5_pointer) context->os_context,
1437c478bd9Sstevel@tonic-gate &required);
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate /* Calculate size required by db_context, if appropriate */
1467c478bd9Sstevel@tonic-gate if (!kret && context->db_context)
1477c478bd9Sstevel@tonic-gate kret = krb5_size_opaque(kcontext,
1487c478bd9Sstevel@tonic-gate KV5M_DB_CONTEXT,
1497c478bd9Sstevel@tonic-gate (krb5_pointer) context->db_context,
1507c478bd9Sstevel@tonic-gate &required);
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate /* Finally, calculate size required by profile, if appropriate */
1537c478bd9Sstevel@tonic-gate if (!kret && context->profile)
1547c478bd9Sstevel@tonic-gate kret = krb5_size_opaque(kcontext,
1557c478bd9Sstevel@tonic-gate PROF_MAGIC_PROFILE,
1567c478bd9Sstevel@tonic-gate (krb5_pointer) context->profile,
1577c478bd9Sstevel@tonic-gate &required);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate if (!kret)
1607c478bd9Sstevel@tonic-gate *sizep += required;
1617c478bd9Sstevel@tonic-gate return(kret);
1627c478bd9Sstevel@tonic-gate }
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate * krb5_context_externalize() - Externalize the krb5_context.
1667c478bd9Sstevel@tonic-gate */
1677c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_context_externalize(krb5_context kcontext,krb5_pointer arg,krb5_octet ** buffer,size_t * lenremain)168505d05c7Sgtb krb5_context_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet **buffer, size_t *lenremain)
1697c478bd9Sstevel@tonic-gate {
1707c478bd9Sstevel@tonic-gate krb5_error_code kret;
1717c478bd9Sstevel@tonic-gate krb5_context context;
1727c478bd9Sstevel@tonic-gate size_t required;
1737c478bd9Sstevel@tonic-gate krb5_octet *bp;
1747c478bd9Sstevel@tonic-gate size_t remain;
1757c478bd9Sstevel@tonic-gate int i;
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate required = 0;
1787c478bd9Sstevel@tonic-gate bp = *buffer;
1797c478bd9Sstevel@tonic-gate remain = *lenremain;
1807c478bd9Sstevel@tonic-gate context = (krb5_context) arg;
1817c478bd9Sstevel@tonic-gate if (!context)
1827c478bd9Sstevel@tonic-gate return (EINVAL);
1837c478bd9Sstevel@tonic-gate KRB5_VERIFY_MAGIC(context, KV5M_CONTEXT);
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate if ((kret = krb5_context_size(kcontext, arg, &required)))
1867c478bd9Sstevel@tonic-gate return (kret);
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate if (required > remain)
1897c478bd9Sstevel@tonic-gate return (ENOMEM);
190*55fea89dSDan Cross
1917c478bd9Sstevel@tonic-gate /* First write our magic number */
1927c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32(KV5M_CONTEXT, &bp, &remain);
1937c478bd9Sstevel@tonic-gate if (kret)
1947c478bd9Sstevel@tonic-gate return (kret);
195*55fea89dSDan Cross
1967c478bd9Sstevel@tonic-gate /* Now sizeof default realm */
1977c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((context->default_realm) ?
1987c478bd9Sstevel@tonic-gate (krb5_int32) strlen(context->default_realm) : 0,
1997c478bd9Sstevel@tonic-gate &bp, &remain);
2007c478bd9Sstevel@tonic-gate if (kret)
2017c478bd9Sstevel@tonic-gate return (kret);
202*55fea89dSDan Cross
2037c478bd9Sstevel@tonic-gate /* Now default_realm bytes */
2047c478bd9Sstevel@tonic-gate if (context->default_realm) {
2057c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_bytes((krb5_octet *) context->default_realm,
206*55fea89dSDan Cross strlen(context->default_realm),
2077c478bd9Sstevel@tonic-gate &bp, &remain);
2087c478bd9Sstevel@tonic-gate if (kret)
2097c478bd9Sstevel@tonic-gate return (kret);
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate /* Now number of initial ticket ktypes */
2137c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->in_tkt_ktype_count,
2147c478bd9Sstevel@tonic-gate &bp, &remain);
2157c478bd9Sstevel@tonic-gate if (kret)
2167c478bd9Sstevel@tonic-gate return (kret);
217*55fea89dSDan Cross
2187c478bd9Sstevel@tonic-gate /* Now serialize ktypes */
2197c478bd9Sstevel@tonic-gate for (i=0; i<context->in_tkt_ktype_count; i++) {
2207c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->in_tkt_ktypes[i],
2217c478bd9Sstevel@tonic-gate &bp, &remain);
2227c478bd9Sstevel@tonic-gate if (kret)
2237c478bd9Sstevel@tonic-gate return (kret);
2247c478bd9Sstevel@tonic-gate }
225*55fea89dSDan Cross
2267c478bd9Sstevel@tonic-gate /* Now number of default ktypes */
2277c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->tgs_ktype_count,
2287c478bd9Sstevel@tonic-gate &bp, &remain);
2297c478bd9Sstevel@tonic-gate if (kret)
2307c478bd9Sstevel@tonic-gate return (kret);
231*55fea89dSDan Cross
2327c478bd9Sstevel@tonic-gate /* Now serialize ktypes */
2337c478bd9Sstevel@tonic-gate for (i=0; i<context->tgs_ktype_count; i++) {
2347c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->tgs_ktypes[i],
2357c478bd9Sstevel@tonic-gate &bp, &remain);
2367c478bd9Sstevel@tonic-gate if (kret)
2377c478bd9Sstevel@tonic-gate return (kret);
2387c478bd9Sstevel@tonic-gate }
239*55fea89dSDan Cross
2407c478bd9Sstevel@tonic-gate /* Now allowable clockskew */
2417c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->clockskew,
2427c478bd9Sstevel@tonic-gate &bp, &remain);
2437c478bd9Sstevel@tonic-gate if (kret)
2447c478bd9Sstevel@tonic-gate return (kret);
245*55fea89dSDan Cross
2467c478bd9Sstevel@tonic-gate /* Now kdc_req_sumtype */
2477c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->kdc_req_sumtype,
2487c478bd9Sstevel@tonic-gate &bp, &remain);
2497c478bd9Sstevel@tonic-gate if (kret)
2507c478bd9Sstevel@tonic-gate return (kret);
251*55fea89dSDan Cross
2527c478bd9Sstevel@tonic-gate /* Now default ap_req_sumtype */
2537c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->default_ap_req_sumtype,
2547c478bd9Sstevel@tonic-gate &bp, &remain);
2557c478bd9Sstevel@tonic-gate if (kret)
2567c478bd9Sstevel@tonic-gate return (kret);
2577c478bd9Sstevel@tonic-gate
2587c478bd9Sstevel@tonic-gate /* Now default safe_sumtype */
2597c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->default_safe_sumtype,
2607c478bd9Sstevel@tonic-gate &bp, &remain);
2617c478bd9Sstevel@tonic-gate if (kret)
2627c478bd9Sstevel@tonic-gate return (kret);
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate /* Now kdc_default_options */
2657c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->kdc_default_options,
2667c478bd9Sstevel@tonic-gate &bp, &remain);
2677c478bd9Sstevel@tonic-gate if (kret)
2687c478bd9Sstevel@tonic-gate return (kret);
2697c478bd9Sstevel@tonic-gate
2707c478bd9Sstevel@tonic-gate /* Now library_options */
2717c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->library_options,
2727c478bd9Sstevel@tonic-gate &bp, &remain);
2737c478bd9Sstevel@tonic-gate if (kret)
2747c478bd9Sstevel@tonic-gate return (kret);
275*55fea89dSDan Cross
2767c478bd9Sstevel@tonic-gate /* Now profile_secure */
2777c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->profile_secure,
2787c478bd9Sstevel@tonic-gate &bp, &remain);
2797c478bd9Sstevel@tonic-gate if (kret)
2807c478bd9Sstevel@tonic-gate return (kret);
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gate /* Now fcc_default_format */
2837c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->fcc_default_format,
2847c478bd9Sstevel@tonic-gate &bp, &remain);
2857c478bd9Sstevel@tonic-gate if (kret)
2867c478bd9Sstevel@tonic-gate return (kret);
2877c478bd9Sstevel@tonic-gate
2887c478bd9Sstevel@tonic-gate /* Now scc_default_format */
2897c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32((krb5_int32) context->scc_default_format,
2907c478bd9Sstevel@tonic-gate &bp, &remain);
2917c478bd9Sstevel@tonic-gate if (kret)
2927c478bd9Sstevel@tonic-gate return (kret);
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate /* Now handle os_context, if appropriate */
2957c478bd9Sstevel@tonic-gate if (context->os_context) {
2967c478bd9Sstevel@tonic-gate kret = krb5_externalize_opaque(kcontext, KV5M_OS_CONTEXT,
2977c478bd9Sstevel@tonic-gate (krb5_pointer) context->os_context,
2987c478bd9Sstevel@tonic-gate &bp, &remain);
2997c478bd9Sstevel@tonic-gate if (kret)
3007c478bd9Sstevel@tonic-gate return (kret);
3017c478bd9Sstevel@tonic-gate }
302*55fea89dSDan Cross
3037c478bd9Sstevel@tonic-gate /* Now handle database context, if appropriate */
3047c478bd9Sstevel@tonic-gate if (context->db_context) {
3057c478bd9Sstevel@tonic-gate kret = krb5_externalize_opaque(kcontext, KV5M_DB_CONTEXT,
3067c478bd9Sstevel@tonic-gate (krb5_pointer) context->db_context,
3077c478bd9Sstevel@tonic-gate &bp, &remain);
3087c478bd9Sstevel@tonic-gate if (kret)
3097c478bd9Sstevel@tonic-gate return (kret);
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate
3127c478bd9Sstevel@tonic-gate /* Finally, handle profile, if appropriate */
3137c478bd9Sstevel@tonic-gate if (context->profile) {
3147c478bd9Sstevel@tonic-gate kret = krb5_externalize_opaque(kcontext, PROF_MAGIC_PROFILE,
3157c478bd9Sstevel@tonic-gate (krb5_pointer) context->profile,
3167c478bd9Sstevel@tonic-gate &bp, &remain);
3177c478bd9Sstevel@tonic-gate if (kret)
3187c478bd9Sstevel@tonic-gate return (kret);
3197c478bd9Sstevel@tonic-gate }
320*55fea89dSDan Cross
3217c478bd9Sstevel@tonic-gate /*
3227c478bd9Sstevel@tonic-gate * If we were successful, write trailer then update the pointer and
3237c478bd9Sstevel@tonic-gate * remaining length;
3247c478bd9Sstevel@tonic-gate */
3257c478bd9Sstevel@tonic-gate kret = krb5_ser_pack_int32(KV5M_CONTEXT, &bp, &remain);
3267c478bd9Sstevel@tonic-gate if (kret)
3277c478bd9Sstevel@tonic-gate return (kret);
328*55fea89dSDan Cross
3297c478bd9Sstevel@tonic-gate *buffer = bp;
3307c478bd9Sstevel@tonic-gate *lenremain = remain;
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate return (0);
3337c478bd9Sstevel@tonic-gate }
3347c478bd9Sstevel@tonic-gate
3357c478bd9Sstevel@tonic-gate /*
3367c478bd9Sstevel@tonic-gate * krb5_context_internalize() - Internalize the krb5_context.
3377c478bd9Sstevel@tonic-gate */
3387c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_context_internalize(krb5_context kcontext,krb5_pointer * argp,krb5_octet ** buffer,size_t * lenremain)339505d05c7Sgtb krb5_context_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octet **buffer, size_t *lenremain)
3407c478bd9Sstevel@tonic-gate {
3417c478bd9Sstevel@tonic-gate krb5_error_code kret;
3427c478bd9Sstevel@tonic-gate krb5_context context;
3437c478bd9Sstevel@tonic-gate krb5_int32 ibuf;
3447c478bd9Sstevel@tonic-gate krb5_octet *bp;
3457c478bd9Sstevel@tonic-gate size_t remain;
3467c478bd9Sstevel@tonic-gate int i;
3477c478bd9Sstevel@tonic-gate
3487c478bd9Sstevel@tonic-gate bp = *buffer;
3497c478bd9Sstevel@tonic-gate remain = *lenremain;
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate /* Read our magic number */
3527c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
3537c478bd9Sstevel@tonic-gate return (EINVAL);
3547c478bd9Sstevel@tonic-gate
3557c478bd9Sstevel@tonic-gate if (ibuf != KV5M_CONTEXT)
3567c478bd9Sstevel@tonic-gate return (EINVAL);
3577c478bd9Sstevel@tonic-gate
3587c478bd9Sstevel@tonic-gate /* Get memory for the context */
3597c478bd9Sstevel@tonic-gate context = (krb5_context) MALLOC(sizeof(struct _krb5_context));
3607c478bd9Sstevel@tonic-gate if (!context)
3617c478bd9Sstevel@tonic-gate return (ENOMEM);
3627c478bd9Sstevel@tonic-gate (void) memset(context, 0, sizeof(struct _krb5_context));
3637c478bd9Sstevel@tonic-gate
3647c478bd9Sstevel@tonic-gate /* Get the size of the default realm */
3657c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
3667c478bd9Sstevel@tonic-gate goto cleanup;
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate if (ibuf) {
3697c478bd9Sstevel@tonic-gate context->default_realm = (char *) MALLOC((size_t) ibuf+1);
3707c478bd9Sstevel@tonic-gate if (!context->default_realm) {
3717c478bd9Sstevel@tonic-gate kret = ENOMEM;
3727c478bd9Sstevel@tonic-gate goto cleanup;
3737c478bd9Sstevel@tonic-gate }
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate kret = krb5_ser_unpack_bytes((krb5_octet *) context->default_realm,
3767c478bd9Sstevel@tonic-gate (size_t) ibuf, &bp, &remain);
3777c478bd9Sstevel@tonic-gate if (kret)
3787c478bd9Sstevel@tonic-gate goto cleanup;
379*55fea89dSDan Cross
3807c478bd9Sstevel@tonic-gate context->default_realm[ibuf] = '\0';
3817c478bd9Sstevel@tonic-gate }
382*55fea89dSDan Cross
3837c478bd9Sstevel@tonic-gate /* Get the number of in_tkt_ktypes */
3847c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
3857c478bd9Sstevel@tonic-gate goto cleanup;
386*55fea89dSDan Cross
3877c478bd9Sstevel@tonic-gate context->in_tkt_ktype_count = (int) ibuf;
3887c478bd9Sstevel@tonic-gate context->in_tkt_ktypes = (krb5_enctype *) MALLOC(sizeof(krb5_enctype) *
3897c478bd9Sstevel@tonic-gate (context->in_tkt_ktype_count+1));
3907c478bd9Sstevel@tonic-gate if (!context->in_tkt_ktypes) {
3917c478bd9Sstevel@tonic-gate kret = ENOMEM;
3927c478bd9Sstevel@tonic-gate goto cleanup;
3937c478bd9Sstevel@tonic-gate }
3947c478bd9Sstevel@tonic-gate (void) memset(context->in_tkt_ktypes, 0, (sizeof(krb5_enctype) *
3957c478bd9Sstevel@tonic-gate (context->in_tkt_ktype_count + 1)));
396*55fea89dSDan Cross
3977c478bd9Sstevel@tonic-gate for (i=0; i<context->in_tkt_ktype_count; i++) {
3987c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
3997c478bd9Sstevel@tonic-gate goto cleanup;
4007c478bd9Sstevel@tonic-gate context->in_tkt_ktypes[i] = (krb5_enctype) ibuf;
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate
4037c478bd9Sstevel@tonic-gate /* Get the number of tgs_ktypes */
4047c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4057c478bd9Sstevel@tonic-gate goto cleanup;
406*55fea89dSDan Cross
4077c478bd9Sstevel@tonic-gate context->tgs_ktype_count = (int) ibuf;
4087c478bd9Sstevel@tonic-gate context->tgs_ktypes = (krb5_enctype *) MALLOC(sizeof(krb5_enctype) *
4097c478bd9Sstevel@tonic-gate (context->tgs_ktype_count+1));
4107c478bd9Sstevel@tonic-gate if (!context->tgs_ktypes) {
4117c478bd9Sstevel@tonic-gate kret = ENOMEM;
4127c478bd9Sstevel@tonic-gate goto cleanup;
4137c478bd9Sstevel@tonic-gate }
4147c478bd9Sstevel@tonic-gate (void) memset(context->tgs_ktypes, 0, (sizeof(krb5_enctype) *
4157c478bd9Sstevel@tonic-gate (context->tgs_ktype_count + 1)));
4167c478bd9Sstevel@tonic-gate for (i=0; i<context->tgs_ktype_count; i++) {
4177c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4187c478bd9Sstevel@tonic-gate goto cleanup;
4197c478bd9Sstevel@tonic-gate context->tgs_ktypes[i] = (krb5_enctype) ibuf;
4207c478bd9Sstevel@tonic-gate }
4217c478bd9Sstevel@tonic-gate
4227c478bd9Sstevel@tonic-gate /* Allowable checksum */
4237c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4247c478bd9Sstevel@tonic-gate goto cleanup;
4257c478bd9Sstevel@tonic-gate context->clockskew = (krb5_deltat) ibuf;
426*55fea89dSDan Cross
4277c478bd9Sstevel@tonic-gate /* kdc_req_sumtype */
4287c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4297c478bd9Sstevel@tonic-gate goto cleanup;
4307c478bd9Sstevel@tonic-gate context->kdc_req_sumtype = (krb5_cksumtype) ibuf;
431*55fea89dSDan Cross
4327c478bd9Sstevel@tonic-gate /* default ap_req_sumtype */
4337c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4347c478bd9Sstevel@tonic-gate goto cleanup;
4357c478bd9Sstevel@tonic-gate context->default_ap_req_sumtype = (krb5_cksumtype) ibuf;
436*55fea89dSDan Cross
4377c478bd9Sstevel@tonic-gate /* default_safe_sumtype */
4387c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4397c478bd9Sstevel@tonic-gate goto cleanup;
4407c478bd9Sstevel@tonic-gate context->default_safe_sumtype = (krb5_cksumtype) ibuf;
4417c478bd9Sstevel@tonic-gate
4427c478bd9Sstevel@tonic-gate /* kdc_default_options */
4437c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4447c478bd9Sstevel@tonic-gate goto cleanup;
4457c478bd9Sstevel@tonic-gate context->kdc_default_options = (krb5_flags) ibuf;
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate /* library_options */
4487c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4497c478bd9Sstevel@tonic-gate goto cleanup;
4507c478bd9Sstevel@tonic-gate context->library_options = (krb5_flags) ibuf;
4517c478bd9Sstevel@tonic-gate
4527c478bd9Sstevel@tonic-gate /* profile_secure */
4537c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4547c478bd9Sstevel@tonic-gate goto cleanup;
4557c478bd9Sstevel@tonic-gate context->profile_secure = (krb5_boolean) ibuf;
4567c478bd9Sstevel@tonic-gate
4577c478bd9Sstevel@tonic-gate /* fcc_default_format */
4587c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4597c478bd9Sstevel@tonic-gate goto cleanup;
4607c478bd9Sstevel@tonic-gate context->fcc_default_format = (int) ibuf;
4617c478bd9Sstevel@tonic-gate
4627c478bd9Sstevel@tonic-gate /* scc_default_format */
4637c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
4647c478bd9Sstevel@tonic-gate goto cleanup;
4657c478bd9Sstevel@tonic-gate context->scc_default_format = (int) ibuf;
466*55fea89dSDan Cross
467505d05c7Sgtb /* Attempt to read in the os_context. It's an array now, but
468505d05c7Sgtb we still treat it in most places as a separate object with
469505d05c7Sgtb a pointer. */
470505d05c7Sgtb {
471505d05c7Sgtb krb5_os_context osp = 0;
472505d05c7Sgtb kret = krb5_internalize_opaque(kcontext, KV5M_OS_CONTEXT,
473505d05c7Sgtb (krb5_pointer *) &osp,
474505d05c7Sgtb &bp, &remain);
475505d05c7Sgtb if (kret && (kret != EINVAL) && (kret != ENOENT))
476505d05c7Sgtb goto cleanup;
477505d05c7Sgtb /* Put the newly allocated data into the krb5_context
478505d05c7Sgtb structure where we're really keeping it these days. */
479505d05c7Sgtb if (osp)
480505d05c7Sgtb *context->os_context = *osp;
481505d05c7Sgtb free(osp);
482505d05c7Sgtb }
4837c478bd9Sstevel@tonic-gate
4847c478bd9Sstevel@tonic-gate /* Attempt to read in the db_context */
4857c478bd9Sstevel@tonic-gate kret = krb5_internalize_opaque(kcontext, KV5M_DB_CONTEXT,
4867c478bd9Sstevel@tonic-gate (krb5_pointer *) &context->db_context,
4877c478bd9Sstevel@tonic-gate &bp, &remain);
4887c478bd9Sstevel@tonic-gate if (kret && (kret != EINVAL) && (kret != ENOENT))
4897c478bd9Sstevel@tonic-gate goto cleanup;
490*55fea89dSDan Cross
491*55fea89dSDan Cross #ifndef _KERNEL
4927c478bd9Sstevel@tonic-gate /* Attempt to read in the profile */
4937c478bd9Sstevel@tonic-gate kret = krb5_internalize_opaque(kcontext, PROF_MAGIC_PROFILE,
4947c478bd9Sstevel@tonic-gate (krb5_pointer *) &context->profile,
4957c478bd9Sstevel@tonic-gate &bp, &remain);
4967c478bd9Sstevel@tonic-gate #endif
4977c478bd9Sstevel@tonic-gate if (kret && (kret != EINVAL) && (kret != ENOENT))
4987c478bd9Sstevel@tonic-gate goto cleanup;
499*55fea89dSDan Cross
5007c478bd9Sstevel@tonic-gate /* Finally, find the trailer */
5017c478bd9Sstevel@tonic-gate if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
5027c478bd9Sstevel@tonic-gate goto cleanup;
5037c478bd9Sstevel@tonic-gate
5047c478bd9Sstevel@tonic-gate if (ibuf != KV5M_CONTEXT) {
5057c478bd9Sstevel@tonic-gate kret = EINVAL;
5067c478bd9Sstevel@tonic-gate goto cleanup;
5077c478bd9Sstevel@tonic-gate }
5087c478bd9Sstevel@tonic-gate
5097c478bd9Sstevel@tonic-gate context->magic = KV5M_CONTEXT;
5107c478bd9Sstevel@tonic-gate *buffer = bp;
5117c478bd9Sstevel@tonic-gate *lenremain = remain;
5127c478bd9Sstevel@tonic-gate *argp = (krb5_pointer) context;
5137c478bd9Sstevel@tonic-gate
5147c478bd9Sstevel@tonic-gate return 0;
5157c478bd9Sstevel@tonic-gate
5167c478bd9Sstevel@tonic-gate cleanup:
5177c478bd9Sstevel@tonic-gate if (context)
5187c478bd9Sstevel@tonic-gate krb5_free_context(context);
5197c478bd9Sstevel@tonic-gate return(kret);
5207c478bd9Sstevel@tonic-gate }
5217c478bd9Sstevel@tonic-gate
5227c478bd9Sstevel@tonic-gate /*
5237c478bd9Sstevel@tonic-gate * krb5_oscontext_size() - Determine the size required to externalize
5247c478bd9Sstevel@tonic-gate * the krb5_os_context.
5257c478bd9Sstevel@tonic-gate */
5267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5277c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_oscontext_size(krb5_context kcontext,krb5_pointer arg,size_t * sizep)528505d05c7Sgtb krb5_oscontext_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep)
5297c478bd9Sstevel@tonic-gate {
5307c478bd9Sstevel@tonic-gate /*
5317c478bd9Sstevel@tonic-gate * We need five 32-bit integers:
5327c478bd9Sstevel@tonic-gate * two for header and trailer
5337c478bd9Sstevel@tonic-gate * one each for time_offset, usec_offset and os_flags
5347c478bd9Sstevel@tonic-gate */
5357c478bd9Sstevel@tonic-gate *sizep += (5*sizeof(krb5_int32));
5367c478bd9Sstevel@tonic-gate return(0);
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate
5397c478bd9Sstevel@tonic-gate /*
5407c478bd9Sstevel@tonic-gate * krb5_oscontext_externalize() - Externalize the krb5_os_context.
5417c478bd9Sstevel@tonic-gate */
5427c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_oscontext_externalize(krb5_context kcontext,krb5_pointer arg,krb5_octet ** buffer,size_t * lenremain)543505d05c7Sgtb krb5_oscontext_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet **buffer, size_t *lenremain)
5447c478bd9Sstevel@tonic-gate {
5457c478bd9Sstevel@tonic-gate krb5_error_code kret;
5467c478bd9Sstevel@tonic-gate krb5_os_context os_ctx;
5477c478bd9Sstevel@tonic-gate size_t required;
5487c478bd9Sstevel@tonic-gate krb5_octet *bp;
5497c478bd9Sstevel@tonic-gate size_t remain;
5507c478bd9Sstevel@tonic-gate
5517c478bd9Sstevel@tonic-gate required = 0;
5527c478bd9Sstevel@tonic-gate bp = *buffer;
5537c478bd9Sstevel@tonic-gate remain = *lenremain;
5547c478bd9Sstevel@tonic-gate kret = EINVAL;
555159d09a2SMark Phalan if ((os_ctx = (krb5_os_context) arg)) {
5567c478bd9Sstevel@tonic-gate kret = ENOMEM;
5577c478bd9Sstevel@tonic-gate if (!krb5_oscontext_size(kcontext, arg, &required) &&
5587c478bd9Sstevel@tonic-gate (required <= remain)) {
5597c478bd9Sstevel@tonic-gate (void) krb5_ser_pack_int32(KV5M_OS_CONTEXT, &bp, &remain);
5607c478bd9Sstevel@tonic-gate (void) krb5_ser_pack_int32(os_ctx->time_offset, &bp, &remain);
5617c478bd9Sstevel@tonic-gate (void) krb5_ser_pack_int32(os_ctx->usec_offset, &bp, &remain);
5627c478bd9Sstevel@tonic-gate (void) krb5_ser_pack_int32(os_ctx->os_flags, &bp, &remain);
5637c478bd9Sstevel@tonic-gate (void) krb5_ser_pack_int32(KV5M_OS_CONTEXT, &bp, &remain);
5647c478bd9Sstevel@tonic-gate
5657c478bd9Sstevel@tonic-gate /* Handle any other OS context here */
5667c478bd9Sstevel@tonic-gate kret = 0;
5677c478bd9Sstevel@tonic-gate if (!kret) {
5687c478bd9Sstevel@tonic-gate *buffer = bp;
5697c478bd9Sstevel@tonic-gate *lenremain = remain;
5707c478bd9Sstevel@tonic-gate }
5717c478bd9Sstevel@tonic-gate }
5727c478bd9Sstevel@tonic-gate }
5737c478bd9Sstevel@tonic-gate return(kret);
5747c478bd9Sstevel@tonic-gate }
5757c478bd9Sstevel@tonic-gate
5767c478bd9Sstevel@tonic-gate /*
5777c478bd9Sstevel@tonic-gate * krb5_oscontext_internalize() - Internalize the krb5_os_context.
5787c478bd9Sstevel@tonic-gate */
5797c478bd9Sstevel@tonic-gate /*ARGSUSED*/
5807c478bd9Sstevel@tonic-gate static krb5_error_code
krb5_oscontext_internalize(krb5_context kcontext,krb5_pointer * argp,krb5_octet ** buffer,size_t * lenremain)581505d05c7Sgtb krb5_oscontext_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octet **buffer, size_t *lenremain)
5827c478bd9Sstevel@tonic-gate {
5837c478bd9Sstevel@tonic-gate krb5_error_code kret;
5847c478bd9Sstevel@tonic-gate krb5_os_context os_ctx;
5857c478bd9Sstevel@tonic-gate krb5_int32 ibuf;
5867c478bd9Sstevel@tonic-gate krb5_octet *bp;
5877c478bd9Sstevel@tonic-gate size_t remain;
5887c478bd9Sstevel@tonic-gate
5897c478bd9Sstevel@tonic-gate bp = *buffer;
5907c478bd9Sstevel@tonic-gate remain = *lenremain;
5917c478bd9Sstevel@tonic-gate kret = EINVAL;
5927c478bd9Sstevel@tonic-gate os_ctx = (krb5_os_context) NULL;
5937c478bd9Sstevel@tonic-gate /* Read our magic number */
5947c478bd9Sstevel@tonic-gate if (krb5_ser_unpack_int32(&ibuf, &bp, &remain))
5957c478bd9Sstevel@tonic-gate ibuf = 0;
5967c478bd9Sstevel@tonic-gate if (ibuf == KV5M_OS_CONTEXT) {
5977c478bd9Sstevel@tonic-gate kret = ENOMEM;
5987c478bd9Sstevel@tonic-gate
5997c478bd9Sstevel@tonic-gate /* Get memory for the context */
600*55fea89dSDan Cross if ((os_ctx = (krb5_os_context)
601159d09a2SMark Phalan MALLOC(sizeof(struct _krb5_os_context))) &&
6027c478bd9Sstevel@tonic-gate (remain >= 4*sizeof(krb5_int32))) {
6037c478bd9Sstevel@tonic-gate (void) memset(os_ctx, 0, sizeof(struct _krb5_os_context));
6047c478bd9Sstevel@tonic-gate os_ctx->magic = KV5M_OS_CONTEXT;
6057c478bd9Sstevel@tonic-gate
6067c478bd9Sstevel@tonic-gate /* Read out our context */
6077c478bd9Sstevel@tonic-gate (void) krb5_ser_unpack_int32(&os_ctx->time_offset, &bp, &remain);
6087c478bd9Sstevel@tonic-gate (void) krb5_ser_unpack_int32(&os_ctx->usec_offset, &bp, &remain);
6097c478bd9Sstevel@tonic-gate (void) krb5_ser_unpack_int32(&os_ctx->os_flags, &bp, &remain);
6107c478bd9Sstevel@tonic-gate (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
6117c478bd9Sstevel@tonic-gate
6127c478bd9Sstevel@tonic-gate if (ibuf == KV5M_OS_CONTEXT) {
6137c478bd9Sstevel@tonic-gate os_ctx->magic = KV5M_OS_CONTEXT;
6147c478bd9Sstevel@tonic-gate kret = 0;
6157c478bd9Sstevel@tonic-gate *buffer = bp;
6167c478bd9Sstevel@tonic-gate *lenremain = remain;
6177c478bd9Sstevel@tonic-gate } else
6187c478bd9Sstevel@tonic-gate kret = EINVAL;
6197c478bd9Sstevel@tonic-gate }
6207c478bd9Sstevel@tonic-gate }
6217c478bd9Sstevel@tonic-gate if (!kret) {
6227c478bd9Sstevel@tonic-gate *argp = (krb5_pointer) os_ctx;
6237c478bd9Sstevel@tonic-gate }
6247c478bd9Sstevel@tonic-gate else {
6257c478bd9Sstevel@tonic-gate if (os_ctx)
6267c478bd9Sstevel@tonic-gate FREE(os_ctx, sizeof(struct _krb5_os_context));
6277c478bd9Sstevel@tonic-gate }
6287c478bd9Sstevel@tonic-gate return(kret);
6297c478bd9Sstevel@tonic-gate }
6307c478bd9Sstevel@tonic-gate
6317c478bd9Sstevel@tonic-gate /*
6327c478bd9Sstevel@tonic-gate * Register the context serializers.
6337c478bd9Sstevel@tonic-gate */
634505d05c7Sgtb krb5_error_code KRB5_CALLCONV
krb5_ser_context_init(krb5_context kcontext)635505d05c7Sgtb krb5_ser_context_init(krb5_context kcontext)
6367c478bd9Sstevel@tonic-gate {
6377c478bd9Sstevel@tonic-gate krb5_error_code kret;
6387c478bd9Sstevel@tonic-gate kret = krb5_register_serializer(kcontext, &krb5_context_ser_entry);
6397c478bd9Sstevel@tonic-gate if (!kret)
6407c478bd9Sstevel@tonic-gate kret = krb5_register_serializer(kcontext, &krb5_oscontext_ser_entry);
6417c478bd9Sstevel@tonic-gate
6427c478bd9Sstevel@tonic-gate /* Profile nformation need not be serialzied when we are importing the
6437c478bd9Sstevel@tonic-gate * context into kernel. Besides the function pointers to file access
6447c478bd9Sstevel@tonic-gate * routines can't be used in the kernel.
645*55fea89dSDan Cross
6467c478bd9Sstevel@tonic-gate * Any info needed from the profile is already a part of the
6477c478bd9Sstevel@tonic-gate * exported context obviating the need for importer to know about
6487c478bd9Sstevel@tonic-gate * profile config files.
649*55fea89dSDan Cross
6507c478bd9Sstevel@tonic-gate */
6517c478bd9Sstevel@tonic-gate
6527c478bd9Sstevel@tonic-gate #ifndef _KERNEL
6537c478bd9Sstevel@tonic-gate if (!kret)
6547c478bd9Sstevel@tonic-gate kret = krb5_register_serializer(kcontext, &krb5_profile_ser_entry);
6557c478bd9Sstevel@tonic-gate #endif
6567c478bd9Sstevel@tonic-gate return(kret);
6577c478bd9Sstevel@tonic-gate }
658