xref: /netbsd-src/lib/libc/rpc/authunix_prot.c (revision 47c0e0c312cd964546204bd0febab9a56fa11df9)
1*47c0e0c3Stron /*	$NetBSD: authunix_prot.c,v 1.16 2013/03/11 20:19:28 tron Exp $	*/
29e15c989Scgd 
363d7b677Scgd /*
4*47c0e0c3Stron  * Copyright (c) 2010, Oracle America, Inc.
563d7b677Scgd  *
6*47c0e0c3Stron  * Redistribution and use in source and binary forms, with or without
7*47c0e0c3Stron  * modification, are permitted provided that the following conditions are
8*47c0e0c3Stron  * met:
963d7b677Scgd  *
10*47c0e0c3Stron  *     * Redistributions of source code must retain the above copyright
11*47c0e0c3Stron  *       notice, this list of conditions and the following disclaimer.
12*47c0e0c3Stron  *     * Redistributions in binary form must reproduce the above
13*47c0e0c3Stron  *       copyright notice, this list of conditions and the following
14*47c0e0c3Stron  *       disclaimer in the documentation and/or other materials
15*47c0e0c3Stron  *       provided with the distribution.
16*47c0e0c3Stron  *     * Neither the name of the "Oracle America, Inc." nor the names of its
17*47c0e0c3Stron  *       contributors may be used to endorse or promote products derived
18*47c0e0c3Stron  *       from this software without specific prior written permission.
1963d7b677Scgd  *
20*47c0e0c3Stron  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21*47c0e0c3Stron  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*47c0e0c3Stron  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*47c0e0c3Stron  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24*47c0e0c3Stron  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25*47c0e0c3Stron  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26*47c0e0c3Stron  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27*47c0e0c3Stron  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28*47c0e0c3Stron  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29*47c0e0c3Stron  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30*47c0e0c3Stron  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31*47c0e0c3Stron  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3263d7b677Scgd  */
3363d7b677Scgd 
34c63c52b2Schristos #include <sys/cdefs.h>
3563d7b677Scgd #if defined(LIBC_SCCS) && !defined(lint)
36c63c52b2Schristos #if 0
37c63c52b2Schristos static char *sccsid = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
38c63c52b2Schristos static char *sccsid = "@(#)authunix_prot.c	2.1 88/07/29 4.0 RPCSRC";
39c63c52b2Schristos #else
40*47c0e0c3Stron __RCSID("$NetBSD: authunix_prot.c,v 1.16 2013/03/11 20:19:28 tron Exp $");
41c63c52b2Schristos #endif
4263d7b677Scgd #endif
4363d7b677Scgd 
4463d7b677Scgd /*
4563d7b677Scgd  * authunix_prot.c
4663d7b677Scgd  * XDR for UNIX style authentication parameters for RPC
4763d7b677Scgd  *
4863d7b677Scgd  * Copyright (C) 1984, Sun Microsystems, Inc.
4963d7b677Scgd  */
5063d7b677Scgd 
5143fa6fe3Sjtc #include "namespace.h"
5246e6c5e8Slukem 
53b48252f3Slukem #include <assert.h>
54b48252f3Slukem 
5563d7b677Scgd #include <rpc/types.h>
5663d7b677Scgd #include <rpc/xdr.h>
5763d7b677Scgd #include <rpc/auth.h>
5863d7b677Scgd #include <rpc/auth_unix.h>
5963d7b677Scgd 
6043fa6fe3Sjtc #ifdef __weak_alias
__weak_alias(xdr_authunix_parms,_xdr_authunix_parms)6160549036Smycroft __weak_alias(xdr_authunix_parms,_xdr_authunix_parms)
6243fa6fe3Sjtc #endif
6343fa6fe3Sjtc 
6463d7b677Scgd /*
6563d7b677Scgd  * XDR for unix authentication parameters.
6663d7b677Scgd  */
6763d7b677Scgd bool_t
68adb74221Smatt xdr_authunix_parms(XDR *xdrs, struct authunix_parms *p)
6963d7b677Scgd {
7063d7b677Scgd 
71b48252f3Slukem 	_DIAGASSERT(xdrs != NULL);
72b48252f3Slukem 	_DIAGASSERT(p != NULL);
73b48252f3Slukem 
7463d7b677Scgd 	if (xdr_u_long(xdrs, &(p->aup_time))
7563d7b677Scgd 	    && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
7663d7b677Scgd 	    && xdr_int(xdrs, &(p->aup_uid))
7763d7b677Scgd 	    && xdr_int(xdrs, &(p->aup_gid))
786f4493cdSmrg 	    && xdr_array(xdrs, (char **)(void *)&(p->aup_gids),
79c5e820caSchristos 		    &(p->aup_len), NGRPS, (unsigned int)sizeof(int),
80c5e820caSchristos 		    (xdrproc_t)xdr_int) ) {
8163d7b677Scgd 		return (TRUE);
8263d7b677Scgd 	}
8363d7b677Scgd 	return (FALSE);
8463d7b677Scgd }
85