xref: /illumos-gate/usr/src/uts/common/fs/nfs/nfs_auth_xdr.c (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
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 <nfs/auth.h>
32 #include <rpc/auth_sys.h>
33 
34 bool_t
35 xdr_varg(XDR *xdrs, varg_t *vap)
36 {
37 	if (!xdr_u_int(xdrs, &vap->vers))
38 		return (FALSE);
39 
40 	switch (vap->vers) {
41 	case V_PROTO:
42 		if (!xdr_nfsauth_arg(xdrs, &vap->arg_u.arg))
43 			return (FALSE);
44 		break;
45 
46 		/* Additional versions of the args go here */
47 
48 	default:
49 		vap->vers = V_ERROR;
50 		return (FALSE);
51 		/* NOTREACHED */
52 	}
53 	return (TRUE);
54 }
55 
56 bool_t
57 xdr_nfsauth_arg(XDR *xdrs, nfsauth_arg_t *argp)
58 {
59 	if (!xdr_u_int(xdrs, &argp->cmd))
60 		return (FALSE);
61 	if (!xdr_netobj(xdrs, &argp->areq.req_client))
62 		return (FALSE);
63 	if (!xdr_string(xdrs, &argp->areq.req_netid, ~0))
64 		return (FALSE);
65 	if (!xdr_string(xdrs, &argp->areq.req_path, A_MAXPATH))
66 		return (FALSE);
67 	if (!xdr_int(xdrs, &argp->areq.req_flavor))
68 		return (FALSE);
69 	if (!xdr_uid_t(xdrs, &argp->areq.req_clnt_uid))
70 		return (FALSE);
71 	if (!xdr_gid_t(xdrs, &argp->areq.req_clnt_gid))
72 		return (FALSE);
73 	if (!xdr_array(xdrs, (caddr_t *)&argp->areq.req_clnt_gids.val,
74 	    &argp->areq.req_clnt_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
75 	    xdr_gid_t))
76 		return (FALSE);
77 	return (TRUE);
78 }
79 
80 bool_t
81 xdr_nfsauth_res(XDR *xdrs, nfsauth_res_t *argp)
82 {
83 	if (!xdr_u_int(xdrs, &argp->stat))
84 		return (FALSE);
85 	if (!xdr_int(xdrs, &argp->ares.auth_perm))
86 		return (FALSE);
87 	if (!xdr_uid_t(xdrs, &argp->ares.auth_srv_uid))
88 		return (FALSE);
89 	if (!xdr_gid_t(xdrs, &argp->ares.auth_srv_gid))
90 		return (FALSE);
91 	if (!xdr_array(xdrs, (caddr_t *)&argp->ares.auth_srv_gids.val,
92 	    &argp->ares.auth_srv_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
93 	    xdr_gid_t))
94 		return (FALSE);
95 	return (TRUE);
96 }
97