4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * Portions of this source code were derived from Berkeley 4.3 BSD
31 * under license from the Regents of the University of California.
36 * XDR for UNIX style authentication parameters for RPC
39 #include <sys/param.h>
44 #include <sys/utsname.h>
46 #include <rpc/types.h>
47 #include <rpc/rpc_sztypes.h>
50 #include <rpc/auth_unix.h>
54 * XDR for unix authentication parameters.
57 xdr_authunix_parms(XDR
*xdrs
, struct authunix_parms
*p
)
59 if (xdr_u_int(xdrs
, &p
->aup_time
) &&
60 xdr_string(xdrs
, &p
->aup_machname
, MAX_MACHINE_NAME
) &&
61 xdr_int(xdrs
, (int *)&(p
->aup_uid
)) &&
62 xdr_int(xdrs
, (int *)&(p
->aup_gid
)) &&
63 xdr_array(xdrs
, (caddr_t
*)&(p
->aup_gids
),
64 &(p
->aup_len
), NGRPS
, sizeof (int),
65 (xdrproc_t
)xdr_int
)) {
72 * XDR user id types (uid_t)
75 xdr_uid_t(XDR
*xdrs
, uid_t
*ip
)
78 (void) (xdr_short(xdrs
, (short *)ip
));
79 return (xdr_int32(xdrs
, (int32_t *)ip
));
81 if (sizeof (uid_t
) == sizeof (int32_t)) {
82 return (xdr_int(xdrs
, (int32_t *)ip
));
84 return (xdr_short(xdrs
, (short *)ip
));
90 * XDR group id types (gid_t)
93 xdr_gid_t(XDR
*xdrs
, gid_t
*ip
)
96 (void) (xdr_short(xdrs
, (short *)ip
));
97 return (xdr_int32(xdrs
, (int32_t *)ip
));
99 if (sizeof (gid_t
) == sizeof (int32_t)) {
100 return (xdr_int32(xdrs
, (int32_t *)ip
));
102 return (xdr_short(xdrs
, (short *)ip
));
108 * XDR kernel unix auth parameters.
109 * Goes out of the u struct directly.
110 * NOTE: this is an XDR_ENCODE only routine.
113 xdr_authkern(XDR
*xdrs
, cred_t
*cr
)
119 char *name
= uts_nodename();
122 if (xdrs
->x_op
!= XDR_ENCODE
)
127 len
= crgetngroups(cr
);
132 groups
= (caddr_t
)crgetgroups(cr
);
133 now
= gethrestime_sec();
134 if (xdr_uint32(xdrs
, (uint32_t *)&now
) &&
135 xdr_string(xdrs
, &name
, MAX_MACHINE_NAME
) &&
136 xdr_uid_t(xdrs
, &uid
) &&
137 xdr_gid_t(xdrs
, &gid
) &&
138 xdr_array(xdrs
, &groups
, &len
, NGRPS
, sizeof (gid_t
), xdr_gid_t
))
144 * XDR loopback unix auth parameters.
145 * NOTE: this is an XDR_ENCODE only routine.
148 xdr_authloopback(XDR
*xdrs
, cred_t
*cr
)
154 char *name
= uts_nodename();
157 if (xdrs
->x_op
!= XDR_ENCODE
)
162 len
= crgetngroups(cr
);
163 groups
= (caddr_t
)crgetgroups(cr
);
164 now
= gethrestime_sec();
165 if (xdr_uint32(xdrs
, (uint32_t *)&now
) &&
166 xdr_string(xdrs
, &name
, MAX_MACHINE_NAME
) &&
167 xdr_uid_t(xdrs
, &uid
) &&
168 xdr_gid_t(xdrs
, &gid
) &&
169 xdr_array(xdrs
, &groups
, &len
, NGROUPS_UMAX
, sizeof (gid_t
),