xref: /titanic_52/usr/src/cmd/fs.d/nfs/mountd/nfsauth_xdr.c (revision 89621fe174cf95ae903df6ceab605bf24d696ac3)
11cc55349Srmesta /*
21cc55349Srmesta  * CDDL HEADER START
31cc55349Srmesta  *
41cc55349Srmesta  * The contents of this file are subject to the terms of the
51cc55349Srmesta  * Common Development and Distribution License (the "License").
61cc55349Srmesta  * You may not use this file except in compliance with the License.
71cc55349Srmesta  *
81cc55349Srmesta  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91cc55349Srmesta  * or http://www.opensolaris.org/os/licensing.
101cc55349Srmesta  * See the License for the specific language governing permissions
111cc55349Srmesta  * and limitations under the License.
121cc55349Srmesta  *
131cc55349Srmesta  * When distributing Covered Code, include this CDDL HEADER in each
141cc55349Srmesta  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151cc55349Srmesta  * If applicable, add the following below this CDDL HEADER, with the
161cc55349Srmesta  * fields enclosed by brackets "[]" replaced with your own identifying
171cc55349Srmesta  * information: Portions Copyright [yyyy] [name of copyright owner]
181cc55349Srmesta  *
191cc55349Srmesta  * CDDL HEADER END
201cc55349Srmesta  */
21a05fd0c9SMarcel Telka 
225cb0d679SMarcel Telka /*
235cb0d679SMarcel Telka  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
245cb0d679SMarcel Telka  */
251cc55349Srmesta 
26a05fd0c9SMarcel Telka /*
27a05fd0c9SMarcel Telka  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
28a05fd0c9SMarcel Telka  * Use is subject to license terms.
29a05fd0c9SMarcel Telka  */
30a05fd0c9SMarcel Telka 
311cc55349Srmesta #include <stdlib.h>
321cc55349Srmesta #include <nfs/auth.h>
33a05fd0c9SMarcel Telka #include <rpc/auth_sys.h>
341cc55349Srmesta 
351cc55349Srmesta bool_t
361cc55349Srmesta xdr_varg(XDR *xdrs, varg_t *vap)
371cc55349Srmesta {
381cc55349Srmesta 	if (!xdr_u_int(xdrs, &vap->vers))
391cc55349Srmesta 		return (FALSE);
401cc55349Srmesta 
411cc55349Srmesta 	switch (vap->vers) {
421cc55349Srmesta 	case V_PROTO:
431cc55349Srmesta 		if (!xdr_nfsauth_arg(xdrs, &vap->arg_u.arg))
441cc55349Srmesta 			return (FALSE);
451cc55349Srmesta 		break;
461cc55349Srmesta 
471cc55349Srmesta 	/* Additional versions of the args go here */
481cc55349Srmesta 
491cc55349Srmesta 	default:
501cc55349Srmesta 		vap->vers = V_ERROR;
511cc55349Srmesta 		return (FALSE);
521cc55349Srmesta 		/* NOTREACHED */
531cc55349Srmesta 	}
541cc55349Srmesta 	return (TRUE);
551cc55349Srmesta }
561cc55349Srmesta 
571cc55349Srmesta bool_t
581cc55349Srmesta xdr_nfsauth_arg(XDR *xdrs, nfsauth_arg_t *argp)
591cc55349Srmesta {
601cc55349Srmesta 	if (!xdr_u_int(xdrs, &argp->cmd))
611cc55349Srmesta 		return (FALSE);
621cc55349Srmesta 	if (!xdr_netobj(xdrs, &argp->areq.req_client))
631cc55349Srmesta 		return (FALSE);
641cc55349Srmesta 	if (!xdr_string(xdrs, &argp->areq.req_netid, ~0))
651cc55349Srmesta 		return (FALSE);
661cc55349Srmesta 	if (!xdr_string(xdrs, &argp->areq.req_path, A_MAXPATH))
671cc55349Srmesta 		return (FALSE);
681cc55349Srmesta 	if (!xdr_int(xdrs, &argp->areq.req_flavor))
691cc55349Srmesta 		return (FALSE);
70a05fd0c9SMarcel Telka 	if (!xdr_uid_t(xdrs, &argp->areq.req_clnt_uid))
715cb0d679SMarcel Telka 		return (FALSE);
72a05fd0c9SMarcel Telka 	if (!xdr_gid_t(xdrs, &argp->areq.req_clnt_gid))
735cb0d679SMarcel Telka 		return (FALSE);
74*89621fe1SMarcel Telka 	if (!xdr_array(xdrs, (caddr_t *)&argp->areq.req_clnt_gids.val,
75*89621fe1SMarcel Telka 	    &argp->areq.req_clnt_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
76*89621fe1SMarcel Telka 	    xdr_gid_t))
77*89621fe1SMarcel Telka 		return (FALSE);
781cc55349Srmesta 	return (TRUE);
791cc55349Srmesta }
801cc55349Srmesta 
811cc55349Srmesta bool_t
821cc55349Srmesta xdr_nfsauth_res(XDR *xdrs, nfsauth_res_t *argp)
831cc55349Srmesta {
841cc55349Srmesta 	if (!xdr_u_int(xdrs, &argp->stat))
851cc55349Srmesta 		return (FALSE);
861cc55349Srmesta 	if (!xdr_int(xdrs, &argp->ares.auth_perm))
871cc55349Srmesta 		return (FALSE);
88a05fd0c9SMarcel Telka 	if (!xdr_uid_t(xdrs, &argp->ares.auth_srv_uid))
895cb0d679SMarcel Telka 		return (FALSE);
90a05fd0c9SMarcel Telka 	if (!xdr_gid_t(xdrs, &argp->ares.auth_srv_gid))
915cb0d679SMarcel Telka 		return (FALSE);
92*89621fe1SMarcel Telka 	if (!xdr_array(xdrs, (caddr_t *)&argp->ares.auth_srv_gids.val,
93*89621fe1SMarcel Telka 	    &argp->ares.auth_srv_gids.len, NGROUPS_UMAX, (uint_t)sizeof (gid_t),
94*89621fe1SMarcel Telka 	    xdr_gid_t))
95*89621fe1SMarcel Telka 		return (FALSE);
961cc55349Srmesta 	return (TRUE);
971cc55349Srmesta }
98