xref: /minix3/lib/libc/rpc/auth_unix.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $	*/
22fe8fb19SBen Gras 
32fe8fb19SBen Gras /*
484d9c625SLionel Sambuc  * Copyright (c) 2010, Oracle America, Inc.
52fe8fb19SBen Gras  *
684d9c625SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
784d9c625SLionel Sambuc  * modification, are permitted provided that the following conditions are
884d9c625SLionel Sambuc  * met:
92fe8fb19SBen Gras  *
1084d9c625SLionel Sambuc  *     * Redistributions of source code must retain the above copyright
1184d9c625SLionel Sambuc  *       notice, this list of conditions and the following disclaimer.
1284d9c625SLionel Sambuc  *     * Redistributions in binary form must reproduce the above
1384d9c625SLionel Sambuc  *       copyright notice, this list of conditions and the following
1484d9c625SLionel Sambuc  *       disclaimer in the documentation and/or other materials
1584d9c625SLionel Sambuc  *       provided with the distribution.
1684d9c625SLionel Sambuc  *     * Neither the name of the "Oracle America, Inc." nor the names of its
1784d9c625SLionel Sambuc  *       contributors may be used to endorse or promote products derived
1884d9c625SLionel Sambuc  *       from this software without specific prior written permission.
192fe8fb19SBen Gras  *
2084d9c625SLionel Sambuc  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2184d9c625SLionel Sambuc  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2284d9c625SLionel Sambuc  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2384d9c625SLionel Sambuc  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
2484d9c625SLionel Sambuc  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
2584d9c625SLionel Sambuc  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2684d9c625SLionel Sambuc  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
2784d9c625SLionel Sambuc  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2884d9c625SLionel Sambuc  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2984d9c625SLionel Sambuc  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3084d9c625SLionel Sambuc  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3184d9c625SLionel Sambuc  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
322fe8fb19SBen Gras  */
332fe8fb19SBen Gras 
342fe8fb19SBen Gras #include <sys/cdefs.h>
352fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint)
362fe8fb19SBen Gras #if 0
372fe8fb19SBen Gras static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
382fe8fb19SBen Gras static char *sccsid = "@(#)auth_unix.c	2.2 88/08/01 4.0 RPCSRC";
392fe8fb19SBen Gras #else
40*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $");
412fe8fb19SBen Gras #endif
422fe8fb19SBen Gras #endif
432fe8fb19SBen Gras 
442fe8fb19SBen Gras /*
452fe8fb19SBen Gras  * auth_unix.c, Implements UNIX style authentication parameters.
462fe8fb19SBen Gras  *
472fe8fb19SBen Gras  * Copyright (C) 1984, Sun Microsystems, Inc.
482fe8fb19SBen Gras  *
49*0a6a1f1dSLionel Sambuc  * The system is very weak.  The client uses no encryption for its
502fe8fb19SBen Gras  * credentials and only sends null verifiers.  The server sends backs
512fe8fb19SBen Gras  * null verifiers or optionally a verifier that suggests a new short hand
522fe8fb19SBen Gras  * for the credentials.
532fe8fb19SBen Gras  *
542fe8fb19SBen Gras  */
552fe8fb19SBen Gras 
562fe8fb19SBen Gras #include "namespace.h"
572fe8fb19SBen Gras #include "reentrant.h"
582fe8fb19SBen Gras #include <sys/param.h>
592fe8fb19SBen Gras 
602fe8fb19SBen Gras #include <assert.h>
612fe8fb19SBen Gras #include <err.h>
622fe8fb19SBen Gras #include <stdio.h>
632fe8fb19SBen Gras #include <stdlib.h>
642fe8fb19SBen Gras #include <string.h>
652fe8fb19SBen Gras #include <unistd.h>
662fe8fb19SBen Gras 
672fe8fb19SBen Gras #include <rpc/types.h>
682fe8fb19SBen Gras #include <rpc/xdr.h>
692fe8fb19SBen Gras #include <rpc/auth.h>
702fe8fb19SBen Gras #include <rpc/auth_unix.h>
712fe8fb19SBen Gras 
722fe8fb19SBen Gras #ifdef __weak_alias
732fe8fb19SBen Gras __weak_alias(authunix_create,_authunix_create)
742fe8fb19SBen Gras __weak_alias(authunix_create_default,_authunix_create_default)
752fe8fb19SBen Gras #endif
762fe8fb19SBen Gras 
772fe8fb19SBen Gras 
782fe8fb19SBen Gras /* auth_unix.c */
79f14fb602SLionel Sambuc static void authunix_nextverf(AUTH *);
80f14fb602SLionel Sambuc static bool_t authunix_marshal(AUTH *, XDR *);
81f14fb602SLionel Sambuc static bool_t authunix_validate(AUTH *, struct opaque_auth *);
82f14fb602SLionel Sambuc static bool_t authunix_refresh(AUTH *);
83f14fb602SLionel Sambuc static void authunix_destroy(AUTH *);
84f14fb602SLionel Sambuc static void marshal_new_auth(AUTH *);
85f14fb602SLionel Sambuc static const struct auth_ops *authunix_ops(void);
862fe8fb19SBen Gras 
872fe8fb19SBen Gras /*
882fe8fb19SBen Gras  * This struct is pointed to by the ah_private field of an auth_handle.
892fe8fb19SBen Gras  */
902fe8fb19SBen Gras struct audata {
912fe8fb19SBen Gras 	struct opaque_auth	au_origcred;	/* original credentials */
922fe8fb19SBen Gras 	struct opaque_auth	au_shcred;	/* short hand cred */
932fe8fb19SBen Gras 	u_long			au_shfaults;	/* short hand cache faults */
942fe8fb19SBen Gras 	char			au_marshed[MAX_AUTH_BYTES];
952fe8fb19SBen Gras 	u_int			au_mpos;	/* xdr pos at end of marshed */
962fe8fb19SBen Gras };
972fe8fb19SBen Gras #define	AUTH_PRIVATE(auth)	((struct audata *)auth->ah_private)
982fe8fb19SBen Gras 
992fe8fb19SBen Gras /*
1002fe8fb19SBen Gras  * Create a unix style authenticator.
1012fe8fb19SBen Gras  * Returns an auth handle with the given stuff in it.
1022fe8fb19SBen Gras  */
1032fe8fb19SBen Gras AUTH *
authunix_create(char * machname,int uid,int gid,int len,int * aup_gids)104f14fb602SLionel Sambuc authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
1052fe8fb19SBen Gras {
1062fe8fb19SBen Gras 	struct authunix_parms aup;
1072fe8fb19SBen Gras 	char mymem[MAX_AUTH_BYTES];
1082fe8fb19SBen Gras 	struct timeval now;
1092fe8fb19SBen Gras 	XDR xdrs;
1102fe8fb19SBen Gras 	AUTH *auth;
1112fe8fb19SBen Gras 	struct audata *au;
1122fe8fb19SBen Gras 
1132fe8fb19SBen Gras 	/*
1142fe8fb19SBen Gras 	 * Allocate and set up auth handle
1152fe8fb19SBen Gras 	 */
1162fe8fb19SBen Gras 	au = NULL;
1172fe8fb19SBen Gras 	auth = mem_alloc(sizeof(*auth));
1182fe8fb19SBen Gras #ifndef KERNEL
1192fe8fb19SBen Gras 	if (auth == NULL) {
12084d9c625SLionel Sambuc 		warn("%s: out of memory", __func__);
1212fe8fb19SBen Gras 		goto cleanup_authunix_create;
1222fe8fb19SBen Gras 	}
1232fe8fb19SBen Gras #endif
1242fe8fb19SBen Gras 	au = mem_alloc(sizeof(*au));
1252fe8fb19SBen Gras #ifndef KERNEL
1262fe8fb19SBen Gras 	if (au == NULL) {
12784d9c625SLionel Sambuc 		warn("%s: out of memory", __func__);
1282fe8fb19SBen Gras 		goto cleanup_authunix_create;
1292fe8fb19SBen Gras 	}
1302fe8fb19SBen Gras #endif
1312fe8fb19SBen Gras 	auth->ah_ops = authunix_ops();
1322fe8fb19SBen Gras 	auth->ah_private = au;
1332fe8fb19SBen Gras 	auth->ah_verf = au->au_shcred = _null_auth;
1342fe8fb19SBen Gras 	au->au_shfaults = 0;
1352fe8fb19SBen Gras 	au->au_origcred.oa_base = NULL;
1362fe8fb19SBen Gras 
1372fe8fb19SBen Gras 	/*
1382fe8fb19SBen Gras 	 * fill in param struct from the given params
1392fe8fb19SBen Gras 	 */
1402fe8fb19SBen Gras 	(void)gettimeofday(&now, NULL);
1412fe8fb19SBen Gras 	aup.aup_time = (u_long)now.tv_sec;	/* XXX: truncate on 32 bit */
1422fe8fb19SBen Gras 	aup.aup_machname = machname;
1432fe8fb19SBen Gras 	aup.aup_uid = uid;
1442fe8fb19SBen Gras 	aup.aup_gid = gid;
1452fe8fb19SBen Gras 	aup.aup_len = (u_int)len;
1462fe8fb19SBen Gras 	aup.aup_gids = aup_gids;
1472fe8fb19SBen Gras 
1482fe8fb19SBen Gras 	/*
1492fe8fb19SBen Gras 	 * Serialize the parameters into origcred
1502fe8fb19SBen Gras 	 */
1512fe8fb19SBen Gras 	xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE);
1522fe8fb19SBen Gras 	if (! xdr_authunix_parms(&xdrs, &aup))
1532fe8fb19SBen Gras 		abort();
1542fe8fb19SBen Gras 	au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs);
1552fe8fb19SBen Gras 	au->au_origcred.oa_flavor = AUTH_UNIX;
1562fe8fb19SBen Gras #ifdef KERNEL
1572fe8fb19SBen Gras 	au->au_origcred.oa_base = mem_alloc((size_t)len);
1582fe8fb19SBen Gras #else
1592fe8fb19SBen Gras 	if ((au->au_origcred.oa_base = mem_alloc((size_t)len)) == NULL) {
16084d9c625SLionel Sambuc 		warn("%s: out of memory", __func__);
1612fe8fb19SBen Gras 		goto cleanup_authunix_create;
1622fe8fb19SBen Gras 	}
1632fe8fb19SBen Gras #endif
1642fe8fb19SBen Gras 	memmove(au->au_origcred.oa_base, mymem, (size_t)len);
1652fe8fb19SBen Gras 
1662fe8fb19SBen Gras 	/*
1672fe8fb19SBen Gras 	 * set auth handle to reflect new cred.
1682fe8fb19SBen Gras 	 */
1692fe8fb19SBen Gras 	auth->ah_cred = au->au_origcred;
1702fe8fb19SBen Gras 	marshal_new_auth(auth);
1712fe8fb19SBen Gras 	return (auth);
1722fe8fb19SBen Gras #ifndef KERNEL
1732fe8fb19SBen Gras  cleanup_authunix_create:
1742fe8fb19SBen Gras 	if (auth)
1752fe8fb19SBen Gras 		mem_free(auth, sizeof(*auth));
1762fe8fb19SBen Gras 	if (au) {
1772fe8fb19SBen Gras 		if (au->au_origcred.oa_base)
1782fe8fb19SBen Gras 			mem_free(au->au_origcred.oa_base, (u_int)len);
1792fe8fb19SBen Gras 		mem_free(au, sizeof(*au));
1802fe8fb19SBen Gras 	}
1812fe8fb19SBen Gras 	return (NULL);
1822fe8fb19SBen Gras #endif
1832fe8fb19SBen Gras }
1842fe8fb19SBen Gras 
1852fe8fb19SBen Gras /*
1862fe8fb19SBen Gras  * Returns an auth handle with parameters determined by doing lots of
1872fe8fb19SBen Gras  * syscalls.
1882fe8fb19SBen Gras  */
1892fe8fb19SBen Gras AUTH *
authunix_create_default(void)190f14fb602SLionel Sambuc authunix_create_default(void)
1912fe8fb19SBen Gras {
1922fe8fb19SBen Gras 	int len;
1932fe8fb19SBen Gras 	char machname[MAXHOSTNAMELEN + 1];
1942fe8fb19SBen Gras 	uid_t uid;
1952fe8fb19SBen Gras 	gid_t gid;
1962fe8fb19SBen Gras 	gid_t gids[NGRPS];
1972fe8fb19SBen Gras 
1982fe8fb19SBen Gras 	if (gethostname(machname, sizeof machname) == -1)
1992fe8fb19SBen Gras 		abort();
2002fe8fb19SBen Gras 	machname[sizeof(machname) - 1] = 0;
2012fe8fb19SBen Gras 	uid = geteuid();
2022fe8fb19SBen Gras 	gid = getegid();
2032fe8fb19SBen Gras 	if ((len = getgroups(NGRPS, gids)) < 0)
2042fe8fb19SBen Gras 		abort();
2052fe8fb19SBen Gras 	/* XXX: interface problem; those should all have been unsigned */
2062fe8fb19SBen Gras 	return (authunix_create(machname, (int)uid, (int)gid, len,
2072fe8fb19SBen Gras 	    (int *)gids));
2082fe8fb19SBen Gras }
2092fe8fb19SBen Gras 
2102fe8fb19SBen Gras /*
2112fe8fb19SBen Gras  * authunix operations
2122fe8fb19SBen Gras  */
2132fe8fb19SBen Gras 
2142fe8fb19SBen Gras /* ARGSUSED */
2152fe8fb19SBen Gras static void
authunix_nextverf(AUTH * auth)216f14fb602SLionel Sambuc authunix_nextverf(AUTH *auth)
2172fe8fb19SBen Gras {
2182fe8fb19SBen Gras 	/* no action necessary */
2192fe8fb19SBen Gras }
2202fe8fb19SBen Gras 
2212fe8fb19SBen Gras static bool_t
authunix_marshal(AUTH * auth,XDR * xdrs)222f14fb602SLionel Sambuc authunix_marshal(AUTH *auth, XDR *xdrs)
2232fe8fb19SBen Gras {
2242fe8fb19SBen Gras 	struct audata *au;
2252fe8fb19SBen Gras 
2262fe8fb19SBen Gras 	_DIAGASSERT(auth != NULL);
2272fe8fb19SBen Gras 	_DIAGASSERT(xdrs != NULL);
2282fe8fb19SBen Gras 
2292fe8fb19SBen Gras 	au = AUTH_PRIVATE(auth);
2302fe8fb19SBen Gras 	return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos));
2312fe8fb19SBen Gras }
2322fe8fb19SBen Gras 
2332fe8fb19SBen Gras static bool_t
authunix_validate(AUTH * auth,struct opaque_auth * verf)234f14fb602SLionel Sambuc authunix_validate(AUTH *auth, struct opaque_auth *verf)
2352fe8fb19SBen Gras {
2362fe8fb19SBen Gras 	struct audata *au;
2372fe8fb19SBen Gras 	XDR xdrs;
2382fe8fb19SBen Gras 
2392fe8fb19SBen Gras 	_DIAGASSERT(auth != NULL);
2402fe8fb19SBen Gras 	_DIAGASSERT(verf != NULL);
2412fe8fb19SBen Gras 
2422fe8fb19SBen Gras 	if (verf->oa_flavor == AUTH_SHORT) {
2432fe8fb19SBen Gras 		au = AUTH_PRIVATE(auth);
2442fe8fb19SBen Gras 		xdrmem_create(&xdrs, verf->oa_base, verf->oa_length,
2452fe8fb19SBen Gras 		    XDR_DECODE);
2462fe8fb19SBen Gras 
2472fe8fb19SBen Gras 		if (au->au_shcred.oa_base != NULL) {
2482fe8fb19SBen Gras 			mem_free(au->au_shcred.oa_base,
2492fe8fb19SBen Gras 			    au->au_shcred.oa_length);
2502fe8fb19SBen Gras 			au->au_shcred.oa_base = NULL;
2512fe8fb19SBen Gras 		}
2522fe8fb19SBen Gras 		if (xdr_opaque_auth(&xdrs, &au->au_shcred)) {
2532fe8fb19SBen Gras 			auth->ah_cred = au->au_shcred;
2542fe8fb19SBen Gras 		} else {
2552fe8fb19SBen Gras 			xdrs.x_op = XDR_FREE;
2562fe8fb19SBen Gras 			(void)xdr_opaque_auth(&xdrs, &au->au_shcred);
2572fe8fb19SBen Gras 			au->au_shcred.oa_base = NULL;
2582fe8fb19SBen Gras 			auth->ah_cred = au->au_origcred;
2592fe8fb19SBen Gras 		}
2602fe8fb19SBen Gras 		marshal_new_auth(auth);
2612fe8fb19SBen Gras 	}
2622fe8fb19SBen Gras 	return (TRUE);
2632fe8fb19SBen Gras }
2642fe8fb19SBen Gras 
2652fe8fb19SBen Gras static bool_t
authunix_refresh(AUTH * auth)266f14fb602SLionel Sambuc authunix_refresh(AUTH *auth)
2672fe8fb19SBen Gras {
2682fe8fb19SBen Gras 	struct audata *au = AUTH_PRIVATE(auth);
2692fe8fb19SBen Gras 	struct authunix_parms aup;
2702fe8fb19SBen Gras 	struct timeval now;
2712fe8fb19SBen Gras 	XDR xdrs;
2722fe8fb19SBen Gras 	int stat;
2732fe8fb19SBen Gras 
2742fe8fb19SBen Gras 	_DIAGASSERT(auth != NULL);
2752fe8fb19SBen Gras 
2762fe8fb19SBen Gras 	if (auth->ah_cred.oa_base == au->au_origcred.oa_base) {
2772fe8fb19SBen Gras 		/* there is no hope.  Punt */
2782fe8fb19SBen Gras 		return (FALSE);
2792fe8fb19SBen Gras 	}
2802fe8fb19SBen Gras 	au->au_shfaults++;
2812fe8fb19SBen Gras 
2822fe8fb19SBen Gras 	/* first deserialize the creds back into a struct authunix_parms */
2832fe8fb19SBen Gras 	aup.aup_machname = NULL;
2842fe8fb19SBen Gras 	aup.aup_gids = NULL;
2852fe8fb19SBen Gras 	xdrmem_create(&xdrs, au->au_origcred.oa_base,
2862fe8fb19SBen Gras 	    au->au_origcred.oa_length, XDR_DECODE);
2872fe8fb19SBen Gras 	stat = xdr_authunix_parms(&xdrs, &aup);
2882fe8fb19SBen Gras 	if (! stat)
2892fe8fb19SBen Gras 		goto done;
2902fe8fb19SBen Gras 
2912fe8fb19SBen Gras 	/* update the time and serialize in place */
2922fe8fb19SBen Gras 	(void)gettimeofday(&now, NULL);
2932fe8fb19SBen Gras 	aup.aup_time = (u_long)now.tv_sec;	/* XXX: truncate on 32 bit */
2942fe8fb19SBen Gras 	xdrs.x_op = XDR_ENCODE;
2952fe8fb19SBen Gras 	XDR_SETPOS(&xdrs, 0);
2962fe8fb19SBen Gras 	stat = xdr_authunix_parms(&xdrs, &aup);
2972fe8fb19SBen Gras 	if (! stat)
2982fe8fb19SBen Gras 		goto done;
2992fe8fb19SBen Gras 	auth->ah_cred = au->au_origcred;
3002fe8fb19SBen Gras 	marshal_new_auth(auth);
3012fe8fb19SBen Gras done:
3022fe8fb19SBen Gras 	/* free the struct authunix_parms created by deserializing */
3032fe8fb19SBen Gras 	xdrs.x_op = XDR_FREE;
3042fe8fb19SBen Gras 	(void)xdr_authunix_parms(&xdrs, &aup);
3052fe8fb19SBen Gras 	XDR_DESTROY(&xdrs);
3062fe8fb19SBen Gras 	return (stat);
3072fe8fb19SBen Gras }
3082fe8fb19SBen Gras 
3092fe8fb19SBen Gras static void
authunix_destroy(AUTH * auth)310f14fb602SLionel Sambuc authunix_destroy(AUTH *auth)
3112fe8fb19SBen Gras {
3122fe8fb19SBen Gras 	struct audata *au;
3132fe8fb19SBen Gras 
3142fe8fb19SBen Gras 	_DIAGASSERT(auth != NULL);
3152fe8fb19SBen Gras 
3162fe8fb19SBen Gras 	au = AUTH_PRIVATE(auth);
3172fe8fb19SBen Gras 	mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length);
3182fe8fb19SBen Gras 
3192fe8fb19SBen Gras 	if (au->au_shcred.oa_base != NULL)
3202fe8fb19SBen Gras 		mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length);
3212fe8fb19SBen Gras 
3222fe8fb19SBen Gras 	mem_free(auth->ah_private, sizeof(struct audata));
3232fe8fb19SBen Gras 
3242fe8fb19SBen Gras 	if (auth->ah_verf.oa_base != NULL)
3252fe8fb19SBen Gras 		mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length);
3262fe8fb19SBen Gras 
3272fe8fb19SBen Gras 	mem_free(auth, sizeof(*auth));
3282fe8fb19SBen Gras }
3292fe8fb19SBen Gras 
3302fe8fb19SBen Gras /*
3312fe8fb19SBen Gras  * Marshals (pre-serializes) an auth struct.
3322fe8fb19SBen Gras  * sets private data, au_marshed and au_mpos
3332fe8fb19SBen Gras  */
3342fe8fb19SBen Gras static void
marshal_new_auth(AUTH * auth)335f14fb602SLionel Sambuc marshal_new_auth(AUTH *auth)
3362fe8fb19SBen Gras {
3372fe8fb19SBen Gras 	XDR	xdr_stream;
3382fe8fb19SBen Gras 	XDR	*xdrs = &xdr_stream;
3392fe8fb19SBen Gras 	struct audata *au;
3402fe8fb19SBen Gras 
3412fe8fb19SBen Gras 	_DIAGASSERT(auth != NULL);
3422fe8fb19SBen Gras 
3432fe8fb19SBen Gras 	au = AUTH_PRIVATE(auth);
3442fe8fb19SBen Gras 	xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
3452fe8fb19SBen Gras 	if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) ||
3462fe8fb19SBen Gras 	    (! xdr_opaque_auth(xdrs, &(auth->ah_verf))))
34784d9c625SLionel Sambuc 		warnx("%s: Fatal marshalling problem", __func__);
3482fe8fb19SBen Gras 	else
3492fe8fb19SBen Gras 		au->au_mpos = XDR_GETPOS(xdrs);
3502fe8fb19SBen Gras 	XDR_DESTROY(xdrs);
3512fe8fb19SBen Gras }
3522fe8fb19SBen Gras 
3532fe8fb19SBen Gras static const struct auth_ops *
authunix_ops(void)354f14fb602SLionel Sambuc authunix_ops(void)
3552fe8fb19SBen Gras {
3562fe8fb19SBen Gras 	static struct auth_ops ops;
3572fe8fb19SBen Gras #ifdef _REENTRANT
3582fe8fb19SBen Gras 	extern mutex_t ops_lock;
3592fe8fb19SBen Gras #endif
3602fe8fb19SBen Gras 
3612fe8fb19SBen Gras 	/* VARIABLES PROTECTED BY ops_lock: ops */
3622fe8fb19SBen Gras 
3632fe8fb19SBen Gras 	mutex_lock(&ops_lock);
3642fe8fb19SBen Gras 	if (ops.ah_nextverf == NULL) {
3652fe8fb19SBen Gras 		ops.ah_nextverf = authunix_nextverf;
3662fe8fb19SBen Gras 		ops.ah_marshal = authunix_marshal;
3672fe8fb19SBen Gras 		ops.ah_validate = authunix_validate;
3682fe8fb19SBen Gras 		ops.ah_refresh = authunix_refresh;
3692fe8fb19SBen Gras 		ops.ah_destroy = authunix_destroy;
3702fe8fb19SBen Gras 	}
3712fe8fb19SBen Gras 	mutex_unlock(&ops_lock);
3722fe8fb19SBen Gras 	return (&ops);
3732fe8fb19SBen Gras }
374