xref: /titanic_41/usr/src/cmd/fs.d/nfs/mountd/nfsauth_xdr.c (revision 2208104ea4cd6d9d44c2a0c21cf2479b92aacf08)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24  */
25 
26 /*
27  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #include <stdlib.h>
32 #include <nfs/auth.h>
33 #include <rpc/auth_sys.h>
34 
35 bool_t
36 xdr_varg(XDR *xdrs, varg_t *vap)
37 {
38 	if (!xdr_u_int(xdrs, &vap->vers))
39 		return (FALSE);
40 
41 	switch (vap->vers) {
42 	case V_PROTO:
43 		if (!xdr_nfsauth_arg(xdrs, &vap->arg_u.arg))
44 			return (FALSE);
45 		break;
46 
47 	/* Additional versions of the args go here */
48 
49 	default:
50 		vap->vers = V_ERROR;
51 		return (FALSE);
52 		/* NOTREACHED */
53 	}
54 	return (TRUE);
55 }
56 
57 bool_t
58 xdr_nfsauth_arg(XDR *xdrs, nfsauth_arg_t *argp)
59 {
60 	if (!xdr_u_int(xdrs, &argp->cmd))
61 		return (FALSE);
62 	if (!xdr_netobj(xdrs, &argp->areq.req_client))
63 		return (FALSE);
64 	if (!xdr_string(xdrs, &argp->areq.req_netid, ~0))
65 		return (FALSE);
66 	if (!xdr_string(xdrs, &argp->areq.req_path, A_MAXPATH))
67 		return (FALSE);
68 	if (!xdr_int(xdrs, &argp->areq.req_flavor))
69 		return (FALSE);
70 	if (!xdr_uid_t(xdrs, &argp->areq.req_clnt_uid))
71 		return (FALSE);
72 	if (!xdr_gid_t(xdrs, &argp->areq.req_clnt_gid))
73 		return (FALSE);
74 	if (!xdr_array(xdrs, (caddr_t *)&argp->areq.req_clnt_gids.val,
75 	    &argp->areq.req_clnt_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
76 	    xdr_gid_t))
77 		return (FALSE);
78 	return (TRUE);
79 }
80 
81 bool_t
82 xdr_nfsauth_res(XDR *xdrs, nfsauth_res_t *argp)
83 {
84 	if (!xdr_u_int(xdrs, &argp->stat))
85 		return (FALSE);
86 	if (!xdr_int(xdrs, &argp->ares.auth_perm))
87 		return (FALSE);
88 	if (!xdr_uid_t(xdrs, &argp->ares.auth_srv_uid))
89 		return (FALSE);
90 	if (!xdr_gid_t(xdrs, &argp->ares.auth_srv_gid))
91 		return (FALSE);
92 	if (!xdr_array(xdrs, (caddr_t *)&argp->ares.auth_srv_gids.val,
93 	    &argp->ares.auth_srv_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
94 	    xdr_gid_t))
95 		return (FALSE);
96 	return (TRUE);
97 }
98