18360efbdSAlfred Perlstein /* $NetBSD: authunix_prot.c,v 1.12 2000/01/22 22:19:17 mycroft Exp $ */
28360efbdSAlfred Perlstein
32e322d37SHiroki Sato /*-
4*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause
5*8a16b7a1SPedro F. Giffuni *
62e322d37SHiroki Sato * Copyright (c) 2009, Sun Microsystems, Inc.
72e322d37SHiroki Sato * All rights reserved.
899064799SGarrett Wollman *
92e322d37SHiroki Sato * Redistribution and use in source and binary forms, with or without
102e322d37SHiroki Sato * modification, are permitted provided that the following conditions are met:
112e322d37SHiroki Sato * - Redistributions of source code must retain the above copyright notice,
122e322d37SHiroki Sato * this list of conditions and the following disclaimer.
132e322d37SHiroki Sato * - Redistributions in binary form must reproduce the above copyright notice,
142e322d37SHiroki Sato * this list of conditions and the following disclaimer in the documentation
152e322d37SHiroki Sato * and/or other materials provided with the distribution.
162e322d37SHiroki Sato * - Neither the name of Sun Microsystems, Inc. nor the names of its
172e322d37SHiroki Sato * contributors may be used to endorse or promote products derived
182e322d37SHiroki Sato * from this software without specific prior written permission.
1999064799SGarrett Wollman *
202e322d37SHiroki Sato * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
212e322d37SHiroki Sato * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
222e322d37SHiroki Sato * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
232e322d37SHiroki Sato * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
242e322d37SHiroki Sato * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
252e322d37SHiroki Sato * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
262e322d37SHiroki Sato * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
272e322d37SHiroki Sato * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
282e322d37SHiroki Sato * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
292e322d37SHiroki Sato * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
302e322d37SHiroki Sato * POSSIBILITY OF SUCH DAMAGE.
3199064799SGarrett Wollman */
3299064799SGarrett Wollman
3399064799SGarrett Wollman /*
3499064799SGarrett Wollman * authunix_prot.c
3599064799SGarrett Wollman * XDR for UNIX style authentication parameters for RPC
3699064799SGarrett Wollman *
3799064799SGarrett Wollman * Copyright (C) 1984, Sun Microsystems, Inc.
3899064799SGarrett Wollman */
3999064799SGarrett Wollman
408360efbdSAlfred Perlstein #include "namespace.h"
418360efbdSAlfred Perlstein #include <assert.h>
4299064799SGarrett Wollman
4399064799SGarrett Wollman #include <rpc/types.h>
4499064799SGarrett Wollman #include <rpc/xdr.h>
4599064799SGarrett Wollman #include <rpc/auth.h>
4699064799SGarrett Wollman #include <rpc/auth_unix.h>
478360efbdSAlfred Perlstein #include "un-namespace.h"
4899064799SGarrett Wollman
4999064799SGarrett Wollman /*
5099064799SGarrett Wollman * XDR for unix authentication parameters.
5199064799SGarrett Wollman */
5299064799SGarrett Wollman bool_t
xdr_authunix_parms(XDR * xdrs,struct authunix_parms * p)53587cf682SCraig Rodrigues xdr_authunix_parms(XDR *xdrs, struct authunix_parms *p)
5499064799SGarrett Wollman {
550d1040e5SPedro F. Giffuni u_int **paup_gids;
5699064799SGarrett Wollman
578360efbdSAlfred Perlstein assert(xdrs != NULL);
588360efbdSAlfred Perlstein assert(p != NULL);
598360efbdSAlfred Perlstein
60102c7c92SJohn Birrell paup_gids = &p->aup_gids;
61102c7c92SJohn Birrell
62e9f7ad1fSPedro F. Giffuni if (xdr_u_long(xdrs, &(p->aup_time)) &&
63e9f7ad1fSPedro F. Giffuni xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) &&
64ff12c59dSPedro F. Giffuni xdr_u_int(xdrs, &(p->aup_uid)) &&
65ff12c59dSPedro F. Giffuni xdr_u_int(xdrs, &(p->aup_gid)) &&
66e9f7ad1fSPedro F. Giffuni xdr_array(xdrs, (char **) paup_gids,
670d1040e5SPedro F. Giffuni &(p->aup_len), NGRPS, sizeof(u_int), (xdrproc_t)xdr_u_int) ) {
6899064799SGarrett Wollman return (TRUE);
6999064799SGarrett Wollman }
7099064799SGarrett Wollman return (FALSE);
7199064799SGarrett Wollman }
72