dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / krb5 / kadm5 / srv / adb_xdr.c
blobc88857ca56f2091a8a6cd382b00b784da1cccab4
1 /*
2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
7 /*
8 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10 * Openvision retains the copyright to derivative works of
11 * this source code. Do *NOT* create a derivative of this
12 * source code before consulting with your legal department.
13 * Do *NOT* integrate *ANY* of this source code into another
14 * product before consulting with your legal department.
16 * For further information, read the top-level Openvision
17 * copyright which is contained in the top-level MIT Kerberos
18 * copyright.
20 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
26 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
28 * $Header$
31 static char *rcsid = "$Header$";
33 #include <sys/types.h>
34 #include "server_internal.h"
35 #include <krb5.h>
36 #include <rpc/rpc.h> /* SUNWresync121 XXX */
37 #include "admin_xdr.h"
38 #ifdef HAVE_MEMORY_H
39 #include <memory.h>
40 #endif
42 bool_t
43 xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp)
45 unsigned int tmp;
47 if (!xdr_krb5_int16(xdrs, &objp->key_data_ver))
48 return(FALSE);
49 if (!xdr_krb5_int16(xdrs, &objp->key_data_kvno))
50 return(FALSE);
51 if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0]))
52 return(FALSE);
53 if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1]))
54 return(FALSE);
55 /* SUNW14resync */
56 if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[0]))
57 return(FALSE);
58 if (!xdr_krb5_ui_2(xdrs, (krb5_ui_2 *)&objp->key_data_length[1]))
59 return(FALSE);
61 tmp = (unsigned int) objp->key_data_length[0];
62 if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0],
63 &tmp, ~0))
64 return FALSE;
66 tmp = (unsigned int) objp->key_data_length[1];
67 if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1],
68 &tmp, ~0))
69 return FALSE;
71 /* don't need to copy tmp out, since key_data_length will be set
72 by the above encoding. */
74 return(TRUE);
77 bool_t
78 xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp)
80 if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
81 (u_int *) &objp->n_key_data, ~0,
82 sizeof(krb5_key_data),
83 xdr_krb5_key_data))
84 return (FALSE);
85 return (TRUE);
88 bool_t
89 xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp)
91 switch (xdrs->x_op) {
92 case XDR_ENCODE:
93 objp->version = OSA_ADB_PRINC_VERSION_1;
94 /* fall through */
95 case XDR_FREE:
96 if (!xdr_int(xdrs, &objp->version))
97 return FALSE;
98 break;
99 case XDR_DECODE:
100 if (!xdr_int(xdrs, &objp->version))
101 return FALSE;
102 if (objp->version != OSA_ADB_PRINC_VERSION_1)
103 return FALSE;
104 break;
107 if (!xdr_nullstring(xdrs, &objp->policy))
108 return (FALSE);
109 if (!xdr_long(xdrs, &objp->aux_attributes))
110 return (FALSE);
111 if (!xdr_u_int(xdrs, &objp->old_key_next))
112 return (FALSE);
113 if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno))
114 return (FALSE);
115 if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys,
116 (unsigned int *) &objp->old_key_len, ~0,
117 sizeof(osa_pw_hist_ent),
118 xdr_osa_pw_hist_ent))
119 return (FALSE);
120 return (TRUE);
123 void
124 osa_free_princ_ent(osa_princ_ent_t val)
126 XDR xdrs;
128 xdrmem_create(&xdrs, NULL, 0, XDR_FREE);
130 xdr_osa_princ_ent_rec(&xdrs, val);
131 free(val);