xref: /titanic_51/usr/src/lib/libnsl/rpc/authsys_prot.c (revision 4beeddd9637aefe7380f0dd3e8cf1734fed5eb30)
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 user id types (uid_t)
69  */
70 bool_t
71 xdr_uid_t(XDR *xdrs, uid_t *ip)
72 {
73 	/* CONSTCOND */
74 	if (sizeof (uid_t) != sizeof (int))
75 		return (xdr_short(xdrs, (short *)ip));
76 	return (xdr_int(xdrs, (int *)ip));
77 }
78 
79 /*
80  * XDR group id types (gid_t)
81  */
82 bool_t
83 xdr_gid_t(XDR *xdrs, gid_t *ip)
84 {
85 	/* CONSTCOND */
86 	if (sizeof (gid_t) != sizeof (int))
87 		return (xdr_short(xdrs, (short *)ip));
88 	return (xdr_int(xdrs, (int *)ip));
89 }
90