1*7f2fe78bSCy Schubert /* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t -*- */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
4*7f2fe78bSCy Schubert *
5*7f2fe78bSCy Schubert * $Header$
6*7f2fe78bSCy Schubert */
7*7f2fe78bSCy Schubert
8*7f2fe78bSCy Schubert #include <sys/types.h>
9*7f2fe78bSCy Schubert #include <krb5.h>
10*7f2fe78bSCy Schubert #include <gssrpc/rpc.h>
11*7f2fe78bSCy Schubert #include "server_internal.h"
12*7f2fe78bSCy Schubert #include "admin_xdr.h"
13*7f2fe78bSCy Schubert #ifdef HAVE_MEMORY_H
14*7f2fe78bSCy Schubert #include <memory.h>
15*7f2fe78bSCy Schubert #endif
16*7f2fe78bSCy Schubert
17*7f2fe78bSCy Schubert bool_t
xdr_krb5_key_data(XDR * xdrs,krb5_key_data * objp)18*7f2fe78bSCy Schubert xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp)
19*7f2fe78bSCy Schubert {
20*7f2fe78bSCy Schubert unsigned int tmp;
21*7f2fe78bSCy Schubert
22*7f2fe78bSCy Schubert if (!xdr_krb5_int16(xdrs, &objp->key_data_ver))
23*7f2fe78bSCy Schubert return(FALSE);
24*7f2fe78bSCy Schubert if (!xdr_krb5_ui_2(xdrs, &objp->key_data_kvno))
25*7f2fe78bSCy Schubert return(FALSE);
26*7f2fe78bSCy Schubert if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0]))
27*7f2fe78bSCy Schubert return(FALSE);
28*7f2fe78bSCy Schubert if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1]))
29*7f2fe78bSCy Schubert return(FALSE);
30*7f2fe78bSCy Schubert if (!xdr_krb5_ui_2(xdrs, &objp->key_data_length[0]))
31*7f2fe78bSCy Schubert return(FALSE);
32*7f2fe78bSCy Schubert if (!xdr_krb5_ui_2(xdrs, &objp->key_data_length[1]))
33*7f2fe78bSCy Schubert return(FALSE);
34*7f2fe78bSCy Schubert
35*7f2fe78bSCy Schubert tmp = (unsigned int) objp->key_data_length[0];
36*7f2fe78bSCy Schubert if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0],
37*7f2fe78bSCy Schubert &tmp, ~0))
38*7f2fe78bSCy Schubert return FALSE;
39*7f2fe78bSCy Schubert
40*7f2fe78bSCy Schubert tmp = (unsigned int) objp->key_data_length[1];
41*7f2fe78bSCy Schubert if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1],
42*7f2fe78bSCy Schubert &tmp, ~0))
43*7f2fe78bSCy Schubert return FALSE;
44*7f2fe78bSCy Schubert
45*7f2fe78bSCy Schubert /* don't need to copy tmp out, since key_data_length will be set
46*7f2fe78bSCy Schubert by the above encoding. */
47*7f2fe78bSCy Schubert
48*7f2fe78bSCy Schubert return(TRUE);
49*7f2fe78bSCy Schubert }
50*7f2fe78bSCy Schubert
51*7f2fe78bSCy Schubert bool_t
xdr_osa_pw_hist_ent(XDR * xdrs,osa_pw_hist_ent * objp)52*7f2fe78bSCy Schubert xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp)
53*7f2fe78bSCy Schubert {
54*7f2fe78bSCy Schubert if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
55*7f2fe78bSCy Schubert (u_int *) &objp->n_key_data, ~0,
56*7f2fe78bSCy Schubert sizeof(krb5_key_data),
57*7f2fe78bSCy Schubert xdr_krb5_key_data))
58*7f2fe78bSCy Schubert return (FALSE);
59*7f2fe78bSCy Schubert return (TRUE);
60*7f2fe78bSCy Schubert }
61*7f2fe78bSCy Schubert
62*7f2fe78bSCy Schubert bool_t
xdr_osa_princ_ent_rec(XDR * xdrs,osa_princ_ent_t objp)63*7f2fe78bSCy Schubert xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp)
64*7f2fe78bSCy Schubert {
65*7f2fe78bSCy Schubert switch (xdrs->x_op) {
66*7f2fe78bSCy Schubert case XDR_ENCODE:
67*7f2fe78bSCy Schubert objp->version = OSA_ADB_PRINC_VERSION_1;
68*7f2fe78bSCy Schubert /* fall through */
69*7f2fe78bSCy Schubert case XDR_FREE:
70*7f2fe78bSCy Schubert if (!xdr_int(xdrs, &objp->version))
71*7f2fe78bSCy Schubert return FALSE;
72*7f2fe78bSCy Schubert break;
73*7f2fe78bSCy Schubert case XDR_DECODE:
74*7f2fe78bSCy Schubert if (!xdr_int(xdrs, &objp->version))
75*7f2fe78bSCy Schubert return FALSE;
76*7f2fe78bSCy Schubert if (objp->version != OSA_ADB_PRINC_VERSION_1)
77*7f2fe78bSCy Schubert return FALSE;
78*7f2fe78bSCy Schubert break;
79*7f2fe78bSCy Schubert }
80*7f2fe78bSCy Schubert
81*7f2fe78bSCy Schubert if (!xdr_nullstring(xdrs, &objp->policy))
82*7f2fe78bSCy Schubert return (FALSE);
83*7f2fe78bSCy Schubert if (!xdr_long(xdrs, &objp->aux_attributes))
84*7f2fe78bSCy Schubert return (FALSE);
85*7f2fe78bSCy Schubert if (!xdr_u_int(xdrs, &objp->old_key_next))
86*7f2fe78bSCy Schubert return (FALSE);
87*7f2fe78bSCy Schubert if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno))
88*7f2fe78bSCy Schubert return (FALSE);
89*7f2fe78bSCy Schubert if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys,
90*7f2fe78bSCy Schubert (unsigned int *) &objp->old_key_len, ~0,
91*7f2fe78bSCy Schubert sizeof(osa_pw_hist_ent),
92*7f2fe78bSCy Schubert xdr_osa_pw_hist_ent))
93*7f2fe78bSCy Schubert return (FALSE);
94*7f2fe78bSCy Schubert return (TRUE);
95*7f2fe78bSCy Schubert }
96*7f2fe78bSCy Schubert
97*7f2fe78bSCy Schubert void
osa_free_princ_ent(osa_princ_ent_t val)98*7f2fe78bSCy Schubert osa_free_princ_ent(osa_princ_ent_t val)
99*7f2fe78bSCy Schubert {
100*7f2fe78bSCy Schubert XDR xdrs;
101*7f2fe78bSCy Schubert
102*7f2fe78bSCy Schubert xdrmem_create(&xdrs, NULL, 0, XDR_FREE);
103*7f2fe78bSCy Schubert
104*7f2fe78bSCy Schubert xdr_osa_princ_ent_rec(&xdrs, val);
105*7f2fe78bSCy Schubert free(val);
106*7f2fe78bSCy Schubert }
107