xref: /titanic_50/usr/src/lib/libnsl/rpc/authsys_prot.c (revision f9bc6dadd79442185db5c8eb201c7475554fc7d7)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 /*
28  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
33 /* All Rights Reserved */
34 /*
35  * Portions of this source code were derived from Berkeley
36  * 4.3 BSD under license from the Regents of the University of
37  * California.
38  */
39 
40 /*
41  * XDR for UNIX style authentication parameters for RPC
42  */
43 
44 #include "mt.h"
45 #include <rpc/types.h>
46 #include <rpc/xdr.h>
47 #include <rpc/auth.h>
48 #include <rpc/auth_sys.h>
49 
50 /*
51  * XDR for unix authentication parameters.
52  */
53 bool_t
54 xdr_authsys_parms(XDR *xdrs, struct authsys_parms *p)
55 {
56 	if (xdr_u_int(xdrs, &(p->aup_time)) &&
57 	    xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) &&
58 	    xdr_uid_t(xdrs, (uid_t *)&(p->aup_uid)) &&
59 	    xdr_gid_t(xdrs, (gid_t *)&(p->aup_gid)) &&
60 	    xdr_array(xdrs, (caddr_t *)&(p->aup_gids),
61 	    &(p->aup_len), NGRPS, (uint_t)sizeof (gid_t),
62 	    (xdrproc_t)xdr_gid_t))
63 		return (TRUE);
64 	return (FALSE);
65 }
66 
67 /*
68  * XDR for loopback unix authentication parameters.
69  */
70 bool_t
71 xdr_authloopback_parms(XDR *xdrs, struct authsys_parms *p)
72 {
73 	if (xdr_u_int(xdrs, &(p->aup_time)) &&
74 	    xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) &&
75 	    xdr_uid_t(xdrs, (uid_t *)&(p->aup_uid)) &&
76 	    xdr_gid_t(xdrs, (gid_t *)&(p->aup_gid)) &&
77 	    xdr_array(xdrs, (caddr_t *)&(p->aup_gids),
78 	    &(p->aup_len), NGRPS_LOOPBACK, (uint_t)sizeof (gid_t),
79 	    (xdrproc_t)xdr_gid_t))
80 		return (TRUE);
81 	return (FALSE);
82 }
83 
84 /*
85  * XDR user id types (uid_t)
86  */
87 bool_t
88 xdr_uid_t(XDR *xdrs, uid_t *ip)
89 {
90 	/* CONSTCOND */
91 	if (sizeof (uid_t) != sizeof (int))
92 		return (xdr_short(xdrs, (short *)ip));
93 	return (xdr_int(xdrs, (int *)ip));
94 }
95 
96 /*
97  * XDR group id types (gid_t)
98  */
99 bool_t
100 xdr_gid_t(XDR *xdrs, gid_t *ip)
101 {
102 	/* CONSTCOND */
103 	if (sizeof (gid_t) != sizeof (int))
104 		return (xdr_short(xdrs, (short *)ip));
105 	return (xdr_int(xdrs, (int *)ip));
106 }
107