xref: /titanic_50/usr/src/head/nss_dbdefs.h (revision 1f3e1ca0c778cfe11180fdbf37a73794e43491ab)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1f3e1ca0Ssatishk  * Common Development and Distribution License (the "License").
6*1f3e1ca0Ssatishk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*1f3e1ca0Ssatishk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  * Database-speficic definitions for the getXXXbyYYY routines
267c478bd9Sstevel@tonic-gate  * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
277c478bd9Sstevel@tonic-gate  * Database-independent definitions are in <nss_common.h>
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * Ideally, this is the only switch header file one would add things
307c478bd9Sstevel@tonic-gate  * to in order to support a new database.
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * NOTE:  The interfaces documented in this file may change in a minor
337c478bd9Sstevel@tonic-gate  *	  release.  It is intended that in the future a stronger committment
347c478bd9Sstevel@tonic-gate  *	  will be made to these interface definitions which will guarantee
357c478bd9Sstevel@tonic-gate  *	  them across minor releases.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifndef _NSS_DBDEFS_H
397c478bd9Sstevel@tonic-gate #define	_NSS_DBDEFS_H
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #include <errno.h>
447c478bd9Sstevel@tonic-gate #include <netdb.h>		/* MAXALIASES, MAXADDRS */
457c478bd9Sstevel@tonic-gate #include <limits.h>		/* LOGNAME_MAX */
467c478bd9Sstevel@tonic-gate #include <nss_common.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #ifndef	NSS_INCLUDE_UNSAFE
537c478bd9Sstevel@tonic-gate #define	NSS_INCLUDE_UNSAFE	1	/* Build old, MT-unsafe interfaces, */
547c478bd9Sstevel@tonic-gate #endif	/* NSS_INCLUDE_UNSAFE */	/*  e.g. getpwnam (c.f. getpwnam_r) */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Names of the well-known databases.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_ALIASES	"aliases"	/* E-mail aliases, that is */
617c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_AUTOMOUNT	"automount"
627c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_BOOTPARAMS	"bootparams"
637c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_ETHERS	"ethers"
647c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_GROUP		"group"
657c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_HOSTS		"hosts"
667c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_IPNODES	"ipnodes"
677c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_NETGROUP	"netgroup"
687c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_NETMASKS	"netmasks"
697c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_NETWORKS	"networks"
707c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PASSWD	"passwd"
717c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PRINTERS	"printers"
727c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PROJECT	"project"
737c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PROTOCOLS	"protocols"
747c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PUBLICKEY	"publickey"
757c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_RPC		"rpc"
767c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_SERVICES	"services"
777c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_AUDITUSER	"audit_user"
787c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_AUTHATTR	"auth_attr"
797c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_EXECATTR	"exec_attr"
807c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PROFATTR	"prof_attr"
817c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_USERATTR	"user_attr"
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* getspnam() et al use the "passwd" config entry but the "shadow" backend */
847c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_SHADOW	"shadow"
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /* The "compat" backend gets config entries for these pseudo-databases */
877c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_PASSWD_COMPAT	"passwd_compat"
887c478bd9Sstevel@tonic-gate #define	NSS_DBNAM_GROUP_COMPAT	"group_compat"
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * Default switch configuration, compiled into the front-ends.
927c478bd9Sstevel@tonic-gate  *
937c478bd9Sstevel@tonic-gate  * Absent good reasons to the contrary, this should be compatible with the
947c478bd9Sstevel@tonic-gate  * default /etc/nsswitch.conf file.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate #define	NSS_FILES_ONLY		"files"
977c478bd9Sstevel@tonic-gate #define	NSS_FILES_NS		"files nis"
987c478bd9Sstevel@tonic-gate #define	NSS_NS_FALLBACK		"nis [NOTFOUND=return] files"
997c478bd9Sstevel@tonic-gate #define	NSS_NS_ONLY		"nis"
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_ALIASES	NSS_FILES_NS
1027c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_AUTOMOUNT	NSS_FILES_NS
1037c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_BOOTPARAMS	NSS_NS_FALLBACK
1047c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_ETHERS	NSS_NS_FALLBACK
1057c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_GROUP	NSS_FILES_NS
1067c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_HOSTS	NSS_NS_FALLBACK
1077c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_IPNODES	NSS_NS_FALLBACK
1087c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_NETGROUP	NSS_NS_ONLY
1097c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_NETMASKS	NSS_NS_FALLBACK
1107c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_NETWORKS	NSS_NS_FALLBACK
1117c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PASSWD	NSS_FILES_NS
1127c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PRINTERS	"user files nis nisplus"
1137c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PROJECT	NSS_FILES_NS
1147c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PROTOCOLS	NSS_NS_FALLBACK
1157c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PUBLICKEY	NSS_FILES_NS
1167c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_RPC		NSS_NS_FALLBACK
1177c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_SERVICES	NSS_FILES_NS	/* speeds up byname() */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_GROUP_COMPAT	NSS_NS_ONLY
1207c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PASSWD_COMPAT	NSS_NS_ONLY
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_ATTRDB	NSS_FILES_NS
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_AUDITUSER	NSS_DEFCONF_PASSWD
1257c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_USERATTR	NSS_DEFCONF_PASSWD
1267c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_AUTHATTR	NSS_DEFCONF_ATTRDB
1277c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_PROFATTR	NSS_DEFCONF_ATTRDB
1287c478bd9Sstevel@tonic-gate #define	NSS_DEFCONF_EXECATTR	NSS_DEFCONF_PROFATTR
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Line-lengths that the "files" and "compat" backends will try to support.
1327c478bd9Sstevel@tonic-gate  * It may be reasonable (even advisable) to use smaller values than these.
1337c478bd9Sstevel@tonic-gate  */
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate #define	NSS_BUFSIZ		1024
1367c478bd9Sstevel@tonic-gate 
137*1f3e1ca0Ssatishk #define	NSS_LINELEN_GROUP	((NSS_BUFSIZ) * 8)
1387c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_HOSTS	((NSS_BUFSIZ) * 8)
1397c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_IPNODES	((NSS_BUFSIZ) * 8)
1407c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_NETMASKS	NSS_BUFSIZ
1417c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_NETWORKS	NSS_BUFSIZ
1427c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PASSWD	NSS_BUFSIZ
1437c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PRINTERS	NSS_BUFSIZ
1447c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PROJECT	((NSS_BUFSIZ) * 4)
1457c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PROTOCOLS	NSS_BUFSIZ
1467c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PUBLICKEY	NSS_BUFSIZ
1477c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_RPC		NSS_BUFSIZ
1487c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_SERVICES	NSS_BUFSIZ
1497c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_SHADOW	NSS_BUFSIZ
1507c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_ETHERS	NSS_BUFSIZ
1517c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_BOOTPARAMS	NSS_BUFSIZ
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_ATTRDB	NSS_BUFSIZ
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_AUDITUSER	NSS_LINELEN_ATTRDB
1567c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_AUTHATTR	NSS_LINELEN_ATTRDB
1577c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_EXECATTR	NSS_LINELEN_ATTRDB
1587c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_PROFATTR	NSS_LINELEN_ATTRDB
1597c478bd9Sstevel@tonic-gate #define	NSS_LINELEN_USERATTR	NSS_LINELEN_ATTRDB
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define	NSS_MMAPLEN_EXECATTR	NSS_LINELEN_EXECATTR * 8
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * Reasonable defaults for 'buflen' values passed to _r functions.  The BSD
1657c478bd9Sstevel@tonic-gate  * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard-
1667c478bd9Sstevel@tonic-gate  * coded array sizes;  the values here are meant to handle anything that
1677c478bd9Sstevel@tonic-gate  * those implementations handled.
1687c478bd9Sstevel@tonic-gate  * === These might more reasonably go in <pwd.h>, <netdb.h> et al
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate 
171*1f3e1ca0Ssatishk #define	NSS_BUFLEN_GROUP	NSS_LINELEN_GROUP
1727c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_HOSTS	\
1737c478bd9Sstevel@tonic-gate 	(NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
1747c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_IPNODES	\
1757c478bd9Sstevel@tonic-gate 	(NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
1767c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_NETGROUP	(MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3)
1777c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_NETWORKS	NSS_LINELEN_NETWORKS	/* === ?  + 35 * 4 */
1787c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_PASSWD	NSS_LINELEN_PASSWD
1797c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_PROJECT	(NSS_LINELEN_PROJECT + 800 * sizeof (char *))
1807c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_PROTOCOLS	NSS_LINELEN_PROTOCOLS	/* === ?  + 35 * 4 */
1817c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_PUBLICKEY	NSS_LINELEN_PUBLICKEY
1827c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_RPC		NSS_LINELEN_RPC		/* === ?  + 35 * 4 */
1837c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_SERVICES	NSS_LINELEN_SERVICES	/* === ?  + 35 * 4 */
1847c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_SHADOW	NSS_LINELEN_SHADOW
1857c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_ETHERS	NSS_LINELEN_ETHERS
1867c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_BOOTPARAMS	NSS_LINELEN_BOOTPARAMS
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_ATTRDB	NSS_LINELEN_ATTRDB
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_AUDITUSER	NSS_BUFLEN_ATTRDB
1917c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_AUTHATTR	NSS_BUFLEN_ATTRDB
1927c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_EXECATTR	NSS_BUFLEN_ATTRDB
1937c478bd9Sstevel@tonic-gate #define	NSS_BUFLEN_PROFATTR	NSS_BUFLEN_ATTRDB
194*1f3e1ca0Ssatishk #define	NSS_BUFLEN_USERATTR	((NSS_BUFLEN_ATTRDB) * 8)
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate /*
1987c478bd9Sstevel@tonic-gate  * Arguments and results, passed between the frontends and backends for
1997c478bd9Sstevel@tonic-gate  * the well-known databases.  The getXbyY_r() and getXent_r() routines
2007c478bd9Sstevel@tonic-gate  * use a common format that is further described below;  other routines
2017c478bd9Sstevel@tonic-gate  * use their own formats.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * The initgroups() function [see initgroups(3c)] needs to find all the
2067c478bd9Sstevel@tonic-gate  *   groups to which a given user belongs.  To do this it calls
2077c478bd9Sstevel@tonic-gate  *   _getgroupsbymember(), which is part of the frontend for the "group"
2087c478bd9Sstevel@tonic-gate  *   database.
2097c478bd9Sstevel@tonic-gate  * We want the same effect as if we used getgrent_r() to enumerate the
2107c478bd9Sstevel@tonic-gate  *   entire groups database (possibly from multiple sources), but getgrent_r()
2117c478bd9Sstevel@tonic-gate  *   is too inefficient.  Most backends can do better if they know they're
2127c478bd9Sstevel@tonic-gate  *   meant to scan all groups;  hence there's a separate backend operation,
2137c478bd9Sstevel@tonic-gate  *   NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct.
2147c478bd9Sstevel@tonic-gate  * Note that the normal return-value from such a backend, even when it
2157c478bd9Sstevel@tonic-gate  *   successfully finds matching group entries, is NSS_NOTFOUND, because
2167c478bd9Sstevel@tonic-gate  *   this tells the switch engine to keep searching in any more sources.
2177c478bd9Sstevel@tonic-gate  *   In fact, the backends only return NSS_SUCCESS if they find enough
2187c478bd9Sstevel@tonic-gate  *   matching entries that the gid_array is completely filled, in which
2197c478bd9Sstevel@tonic-gate  *   case the switch engine should stop searching.
2207c478bd9Sstevel@tonic-gate  * If the force_slow_way field is set, the backend should eschew any cached
2217c478bd9Sstevel@tonic-gate  *   information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table)
2227c478bd9Sstevel@tonic-gate  *   and should instead grind its way through the group map/table/whatever.
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate struct nss_groupsbymem {			/* For _getgroupsbymember() */
2267c478bd9Sstevel@tonic-gate /* in: */
2277c478bd9Sstevel@tonic-gate 	const char	*username;
2287c478bd9Sstevel@tonic-gate 	gid_t		*gid_array;
2297c478bd9Sstevel@tonic-gate 	int		maxgids;
2307c478bd9Sstevel@tonic-gate 	int		force_slow_way;
2317c478bd9Sstevel@tonic-gate 	/*
2327c478bd9Sstevel@tonic-gate 	 * The process_cstr() routine does the real work for any backend
2337c478bd9Sstevel@tonic-gate 	 * that can supply a group entry as a string in /etc/group format
2347c478bd9Sstevel@tonic-gate 	 */
2357c478bd9Sstevel@tonic-gate #if defined(__STDC__)
2367c478bd9Sstevel@tonic-gate 	int		(*str2ent)	(const char		*instr,
2377c478bd9Sstevel@tonic-gate 					int			instr_len,
2387c478bd9Sstevel@tonic-gate 					void *ent, char *buffer, int buflen);
2397c478bd9Sstevel@tonic-gate 	nss_status_t	(*process_cstr)	(const char		*instr,
2407c478bd9Sstevel@tonic-gate 					int			instr_len,
2417c478bd9Sstevel@tonic-gate 					struct nss_groupsbymem *);
2427c478bd9Sstevel@tonic-gate #else
2437c478bd9Sstevel@tonic-gate 	int		(*str2ent)();
2447c478bd9Sstevel@tonic-gate 	nss_status_t	(*process_cstr)();
2457c478bd9Sstevel@tonic-gate #endif
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /* in_out: */
2487c478bd9Sstevel@tonic-gate 	int		numgids;
2497c478bd9Sstevel@tonic-gate };
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate /*
2527c478bd9Sstevel@tonic-gate  * The netgroup routines are handled as follows:
2537c478bd9Sstevel@tonic-gate  *
2547c478bd9Sstevel@tonic-gate  *   Policy decision:
2557c478bd9Sstevel@tonic-gate  *	If netgroup A refers to netgroup B, both must occur in the same
2567c478bd9Sstevel@tonic-gate  *	source (other choices give very confusing semantics).  This
2577c478bd9Sstevel@tonic-gate  *	assumption is deeply embedded in the frontend and backends.
2587c478bd9Sstevel@tonic-gate  *
2597c478bd9Sstevel@tonic-gate  *    -	setnetgrent(), despite its name, is really a getXXXbyYYY operation:
2607c478bd9Sstevel@tonic-gate  *	it takes a name and finds a netgroup with that name (see the
2617c478bd9Sstevel@tonic-gate  *	nss_setnetgrent_args struct below).  The "result" that it returns
2627c478bd9Sstevel@tonic-gate  *	to the frontend is an nss_backend_t for a pseudo-backend that allows
2637c478bd9Sstevel@tonic-gate  *	one to enumerate the members of that netgroup.
2647c478bd9Sstevel@tonic-gate  *
2657c478bd9Sstevel@tonic-gate  *    -	getnetgrent() calls the 'getXXXent' function in the pseudo-backend;
2667c478bd9Sstevel@tonic-gate  *	it doesn't go through the switch engine at all.  It uses the
2677c478bd9Sstevel@tonic-gate  *	nss_getnetgrent_args struct below.
2687c478bd9Sstevel@tonic-gate  *
2697c478bd9Sstevel@tonic-gate  *    -	innetgr() is implemented on top of __multi_innetgr(), which replaces
2707c478bd9Sstevel@tonic-gate  *	each (char *) argument of innetgr() with a counted vector of (char *).
2717c478bd9Sstevel@tonic-gate  *	The semantics are the same as an OR of the results of innetgr()
2727c478bd9Sstevel@tonic-gate  *	operations on each possible 4-tuple picked from the arguments, but
2737c478bd9Sstevel@tonic-gate  *	it's possible to implement some cases more efficiently.  This is
2747c478bd9Sstevel@tonic-gate  *	important for mountd, which used to read YP netgroup.byhost directly
2757c478bd9Sstevel@tonic-gate  *	in order to determine efficiently whether a given host belonged to any
2767c478bd9Sstevel@tonic-gate  *	one of a long list of netgroups.  Wildcarded arguments are indicated
2777c478bd9Sstevel@tonic-gate  *	by a count of zero.
2787c478bd9Sstevel@tonic-gate  *
2797c478bd9Sstevel@tonic-gate  *    -	__multi_innetgr() uses the nss_innetgr_args struct.  A backend whose
2807c478bd9Sstevel@tonic-gate  *	source contains at least one of the groups listed in the 'groups'
2817c478bd9Sstevel@tonic-gate  *	vector will return NSS_SUCCESS and will set the 'status' field to
2827c478bd9Sstevel@tonic-gate  *	indicate whether any 4-tuple was satisfied.  A backend will only
2837c478bd9Sstevel@tonic-gate  *	return NSS_NOTFOUND if the source contained none of the groups
2847c478bd9Sstevel@tonic-gate  *	listed in the 'groups' vector.
2857c478bd9Sstevel@tonic-gate  */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate enum nss_netgr_argn {		/* We need (machine, user, domain) triples */
2887c478bd9Sstevel@tonic-gate 	NSS_NETGR_MACHINE,
2897c478bd9Sstevel@tonic-gate 	NSS_NETGR_USER,
2907c478bd9Sstevel@tonic-gate 	NSS_NETGR_DOMAIN,
2917c478bd9Sstevel@tonic-gate 	NSS_NETGR_N
2927c478bd9Sstevel@tonic-gate };
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate enum nss_netgr_status {		/* Status from setnetgrent, multi_innetgr */
2957c478bd9Sstevel@tonic-gate 	NSS_NETGR_FOUND,
2967c478bd9Sstevel@tonic-gate 	NSS_NETGR_NO,
2977c478bd9Sstevel@tonic-gate 	NSS_NETGR_NOMEM
2987c478bd9Sstevel@tonic-gate };
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate struct nss_setnetgrent_args {
3017c478bd9Sstevel@tonic-gate /* in: */
3027c478bd9Sstevel@tonic-gate 	const char		*netgroup;
3037c478bd9Sstevel@tonic-gate /* out: */
3047c478bd9Sstevel@tonic-gate 	nss_backend_t		*iterator;	/* <==== Explain */
3057c478bd9Sstevel@tonic-gate };
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate struct nss_getnetgrent_args {
3087c478bd9Sstevel@tonic-gate /* in: */
3097c478bd9Sstevel@tonic-gate 	char			*buffer;
3107c478bd9Sstevel@tonic-gate 	int			buflen;
3117c478bd9Sstevel@tonic-gate /* out: */
3127c478bd9Sstevel@tonic-gate 	enum nss_netgr_status	status;
3137c478bd9Sstevel@tonic-gate 	char			*retp[NSS_NETGR_N];
3147c478bd9Sstevel@tonic-gate };
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate typedef unsigned	nss_innetgr_argc;    /* 0 means wildcard */
3177c478bd9Sstevel@tonic-gate typedef char **		nss_innetgr_argv;    /* === Do we really need these? */
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate struct nss_innetgr_1arg {
3207c478bd9Sstevel@tonic-gate 	nss_innetgr_argc	argc;
3217c478bd9Sstevel@tonic-gate 	nss_innetgr_argv	argv;
3227c478bd9Sstevel@tonic-gate };
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate struct nss_innetgr_args {
3257c478bd9Sstevel@tonic-gate /* in: */
3267c478bd9Sstevel@tonic-gate 	struct nss_innetgr_1arg	arg[NSS_NETGR_N];
3277c478bd9Sstevel@tonic-gate 	struct nss_innetgr_1arg groups;
3287c478bd9Sstevel@tonic-gate /* out: */
3297c478bd9Sstevel@tonic-gate 	enum nss_netgr_status	status;
3307c478bd9Sstevel@tonic-gate };
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
3357c478bd9Sstevel@tonic-gate  *   getXXXbyYYY_r() and getXXXent_r() routines.  The (void *) value points to
3367c478bd9Sstevel@tonic-gate  *   a struct of the appropriate type, e.g. struct passwd or struct hostent.
3377c478bd9Sstevel@tonic-gate  *
3387c478bd9Sstevel@tonic-gate  * The functions that allocate and free these structures do no locking at
3397c478bd9Sstevel@tonic-gate  * all, since the routines that use them are inherently MT-unsafe anyway.
3407c478bd9Sstevel@tonic-gate  */
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate typedef struct {
3437c478bd9Sstevel@tonic-gate 	void		*result;	/* "result" parameter to getXbyY_r() */
3447c478bd9Sstevel@tonic-gate 	char		*buffer;	/* "buffer"     "             "      */
3457c478bd9Sstevel@tonic-gate 	int		buflen;		/* "buflen"     "             "      */
3467c478bd9Sstevel@tonic-gate } nss_XbyY_buf_t;
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate #if defined(__STDC__)
3497c478bd9Sstevel@tonic-gate extern nss_XbyY_buf_t	*_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
3507c478bd9Sstevel@tonic-gate extern void		 _nss_XbyY_buf_free(nss_XbyY_buf_t *);
3517c478bd9Sstevel@tonic-gate #else
3527c478bd9Sstevel@tonic-gate extern nss_XbyY_buf_t	*_nss_XbyY_buf_alloc();
3537c478bd9Sstevel@tonic-gate extern void		 _nss_XbyY_buf_free();
3547c478bd9Sstevel@tonic-gate #endif
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate #define	NSS_XbyY_ALLOC(bufpp, str_size, buf_size)		(\
3577c478bd9Sstevel@tonic-gate 	(*bufpp) == 0						\
3587c478bd9Sstevel@tonic-gate 	? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size)	\
3597c478bd9Sstevel@tonic-gate 	: (*bufpp))						\
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #define	NSS_XbyY_FREE(bufpp)	(_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0)
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate /*
3647c478bd9Sstevel@tonic-gate  * The nss_XbyY_args_t struct contains all the information passed between
3657c478bd9Sstevel@tonic-gate  * frontends and backends for the getXbyY_r() and getXent() routines,
3667c478bd9Sstevel@tonic-gate  * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r).
3677c478bd9Sstevel@tonic-gate  *
3687c478bd9Sstevel@tonic-gate  * The (*str2ent)() member converts a single XXXent from ASCII text to the
3697c478bd9Sstevel@tonic-gate  * appropriate struct, storing any pointer data (strings, in_addrs, arrays
3707c478bd9Sstevel@tonic-gate  * of these) in the buffer.  The ASCII text is a counted string (*not* a
3717c478bd9Sstevel@tonic-gate  * zero-terminated string) whose length is specified by the instr_len
3727c478bd9Sstevel@tonic-gate  * parameter.  The text is found at the address specified by instr and
3737c478bd9Sstevel@tonic-gate  * the string is treated as readonly. buffer and instr must be non-
3747c478bd9Sstevel@tonic-gate  * intersecting memory areas.
3757c478bd9Sstevel@tonic-gate  *
3767c478bd9Sstevel@tonic-gate  * With the exception of passwd, shadow and group, the text form for these
3777c478bd9Sstevel@tonic-gate  * databases allows trailing comments and arbitrary whitespace.  The
3787c478bd9Sstevel@tonic-gate  * corresponding str2ent routine assumes that comments, leading whitespace
3797c478bd9Sstevel@tonic-gate  * and trailing whitespace have been stripped (and thus assumes that entries
3807c478bd9Sstevel@tonic-gate  * consisting only of these have been discarded).
3817c478bd9Sstevel@tonic-gate  *
3827c478bd9Sstevel@tonic-gate  * The text entries for "rpc" and for the databases described in <netdb.h>
3837c478bd9Sstevel@tonic-gate  * follow a common format (a canonical name with a possibly empty list
3847c478bd9Sstevel@tonic-gate  * of aliases, and some other value), albeit with minor variations.
3857c478bd9Sstevel@tonic-gate  * The function _nss_netdb_aliases() does most of the generic work involved
3867c478bd9Sstevel@tonic-gate  * in parsing and marshalling these into the buffer.
3877c478bd9Sstevel@tonic-gate  */
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate union nss_XbyY_key {	/* No tag;  backend should know what to expect */
3907c478bd9Sstevel@tonic-gate 	uid_t		uid;
3917c478bd9Sstevel@tonic-gate 	gid_t		gid;
3927c478bd9Sstevel@tonic-gate 	projid_t	projid;
3937c478bd9Sstevel@tonic-gate 	const char	*name;
3947c478bd9Sstevel@tonic-gate 	int		number;
3957c478bd9Sstevel@tonic-gate 	struct {
3967c478bd9Sstevel@tonic-gate 		int	net;
3977c478bd9Sstevel@tonic-gate 		int		type;
3987c478bd9Sstevel@tonic-gate 	}	netaddr;
3997c478bd9Sstevel@tonic-gate 	struct {
4007c478bd9Sstevel@tonic-gate 		const char	*addr;
4017c478bd9Sstevel@tonic-gate 		int		len;
4027c478bd9Sstevel@tonic-gate 		int		type;
4037c478bd9Sstevel@tonic-gate 	}	hostaddr;
4047c478bd9Sstevel@tonic-gate 	struct {
4057c478bd9Sstevel@tonic-gate 		union {
4067c478bd9Sstevel@tonic-gate 			const char	*name;
4077c478bd9Sstevel@tonic-gate 			int		port;
4087c478bd9Sstevel@tonic-gate 		}		serv;
4097c478bd9Sstevel@tonic-gate 		const char	*proto;
4107c478bd9Sstevel@tonic-gate 	}	serv;
4117c478bd9Sstevel@tonic-gate 	void *ether;
4127c478bd9Sstevel@tonic-gate 	struct {
4137c478bd9Sstevel@tonic-gate 		const char	*name;
4147c478bd9Sstevel@tonic-gate 		const char	*keytype;
4157c478bd9Sstevel@tonic-gate 	} pkey;
4167c478bd9Sstevel@tonic-gate 	struct {
4177c478bd9Sstevel@tonic-gate 		const char	*name;
4187c478bd9Sstevel@tonic-gate 		int		af_family;
4197c478bd9Sstevel@tonic-gate 		int		flags;
4207c478bd9Sstevel@tonic-gate 	}	ipnode;
4217c478bd9Sstevel@tonic-gate 	void *attrp;	/* for the new attr databases */
4227c478bd9Sstevel@tonic-gate };
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate typedef struct nss_XbyY_args {
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate /* IN */
4277c478bd9Sstevel@tonic-gate 	nss_XbyY_buf_t	buf;
4287c478bd9Sstevel@tonic-gate 	int		stayopen;
4297c478bd9Sstevel@tonic-gate 			/*
4307c478bd9Sstevel@tonic-gate 			 * Support for setXXXent(stayopen)
4317c478bd9Sstevel@tonic-gate 			 * Used only in hosts, protocols,
4327c478bd9Sstevel@tonic-gate 			 * networks, rpc, and services.
4337c478bd9Sstevel@tonic-gate 			 */
4347c478bd9Sstevel@tonic-gate #if defined(__STDC__)
4357c478bd9Sstevel@tonic-gate 	int		(*str2ent)	(const char		*instr,
4367c478bd9Sstevel@tonic-gate 					int			instr_len,
4377c478bd9Sstevel@tonic-gate 					void *ent, char *buffer, int buflen);
4387c478bd9Sstevel@tonic-gate #else
4397c478bd9Sstevel@tonic-gate 	int		(*str2ent)();
4407c478bd9Sstevel@tonic-gate #endif
4417c478bd9Sstevel@tonic-gate 	union nss_XbyY_key key;
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate /* OUT */
4447c478bd9Sstevel@tonic-gate 	void		*returnval;
4457c478bd9Sstevel@tonic-gate 	int		erange;
4467c478bd9Sstevel@tonic-gate 	int		h_errno;		/* For gethost*_r() */
4477c478bd9Sstevel@tonic-gate 	nss_status_t	status; /* from the backend last called */
4487c478bd9Sstevel@tonic-gate } nss_XbyY_args_t;
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate /* status returned by the str2ent parsing routines */
4517c478bd9Sstevel@tonic-gate #define	NSS_STR_PARSE_SUCCESS 0
4527c478bd9Sstevel@tonic-gate #define	NSS_STR_PARSE_PARSE 1
4537c478bd9Sstevel@tonic-gate #define	NSS_STR_PARSE_ERANGE 2
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate #define	NSS_XbyY_INIT(str, res, bufp, len, func)	(\
4567c478bd9Sstevel@tonic-gate 	(str)->buf.result = (res),			\
4577c478bd9Sstevel@tonic-gate 	(str)->buf.buffer = (bufp),			\
4587c478bd9Sstevel@tonic-gate 	(str)->buf.buflen = (len),			\
4597c478bd9Sstevel@tonic-gate 	(str)->stayopen  = 0,				\
4607c478bd9Sstevel@tonic-gate 	(str)->str2ent  = (func),			\
4617c478bd9Sstevel@tonic-gate 	(str)->returnval = 0,				\
4627c478bd9Sstevel@tonic-gate 	(str)->erange    = 0)
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate #define	NSS_XbyY_FINI(str)				(\
4657c478bd9Sstevel@tonic-gate 	(str)->returnval == 0 && (str)->erange && (errno = ERANGE), \
4667c478bd9Sstevel@tonic-gate 	(str)->returnval)
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate #if defined(__STDC__)
4697c478bd9Sstevel@tonic-gate extern char		**_nss_netdb_aliases
4707c478bd9Sstevel@tonic-gate 	(const char *, int, char *, int);
4717c478bd9Sstevel@tonic-gate #else
4727c478bd9Sstevel@tonic-gate extern char		**_nss_netdb_aliases();
4737c478bd9Sstevel@tonic-gate #endif
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate /*
4767c478bd9Sstevel@tonic-gate  * nss_dbop_t values for searches with various keys;  values for
4777c478bd9Sstevel@tonic-gate  * destructor/endent/setent/getent are defined in <nss_common.h>
4787c478bd9Sstevel@tonic-gate  */
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate #define	NSS_DBOP_GROUP_BYNAME		(NSS_DBOP_next_iter)
4817c478bd9Sstevel@tonic-gate #define	NSS_DBOP_GROUP_BYGID		(NSS_DBOP_GROUP_BYNAME + 1)
4827c478bd9Sstevel@tonic-gate #define	NSS_DBOP_GROUP_BYMEMBER		(NSS_DBOP_GROUP_BYGID  + 1)
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PASSWD_BYNAME		(NSS_DBOP_next_iter)
4857c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PASSWD_BYUID		(NSS_DBOP_PASSWD_BYNAME + 1)
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate /* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */
4887c478bd9Sstevel@tonic-gate /*   (it also requires that both use key.name to pass the username). */
4897c478bd9Sstevel@tonic-gate #define	NSS_DBOP_SHADOW_BYNAME		(NSS_DBOP_PASSWD_BYNAME)
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PROJECT_BYNAME		(NSS_DBOP_next_iter)
4927c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PROJECT_BYID		(NSS_DBOP_PROJECT_BYNAME + 1)
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate #define	NSS_DBOP_HOSTS_BYNAME		(NSS_DBOP_next_iter)
4957c478bd9Sstevel@tonic-gate #define	NSS_DBOP_HOSTS_BYADDR		(NSS_DBOP_HOSTS_BYNAME + 1)
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate #define	NSS_DBOP_IPNODES_BYNAME		(NSS_DBOP_next_iter)
4987c478bd9Sstevel@tonic-gate #define	NSS_DBOP_IPNODES_BYADDR		(NSS_DBOP_IPNODES_BYNAME + 1)
4997c478bd9Sstevel@tonic-gate 
5007c478bd9Sstevel@tonic-gate /*
5017c478bd9Sstevel@tonic-gate  * NSS_DBOP_NAME_2ADDR
5027c478bd9Sstevel@tonic-gate  * NSS_DBOP_ADDR_2NAME
5037c478bd9Sstevel@tonic-gate  *                                : are defines for ipv6 api's
5047c478bd9Sstevel@tonic-gate  */
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NAME_2ADDR		(NSS_DBOP_next_ipv6_iter)
5077c478bd9Sstevel@tonic-gate #define	NSS_DBOP_ADDR_2NAME		(NSS_DBOP_NAME_2ADDR + 1)
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate #define	NSS_DBOP_RPC_BYNAME		(NSS_DBOP_next_iter)
5107c478bd9Sstevel@tonic-gate #define	NSS_DBOP_RPC_BYNUMBER		(NSS_DBOP_RPC_BYNAME + 1)
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NETWORKS_BYNAME		(NSS_DBOP_next_iter)
5137c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NETWORKS_BYADDR		(NSS_DBOP_NETWORKS_BYNAME + 1)
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate #define	NSS_DBOP_SERVICES_BYNAME	(NSS_DBOP_next_iter)
5167c478bd9Sstevel@tonic-gate #define	NSS_DBOP_SERVICES_BYPORT	(NSS_DBOP_SERVICES_BYNAME + 1)
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PROTOCOLS_BYNAME	(NSS_DBOP_next_iter)
5197c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PROTOCOLS_BYNUMBER	(NSS_DBOP_PROTOCOLS_BYNAME + 1)
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate #define	NSS_DBOP_ETHERS_HOSTTON	(NSS_DBOP_next_noiter)
5227c478bd9Sstevel@tonic-gate #define	NSS_DBOP_ETHERS_NTOHOST	(NSS_DBOP_ETHERS_HOSTTON + 1)
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate #define	NSS_DBOP_BOOTPARAMS_BYNAME	(NSS_DBOP_next_noiter)
5257c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NETMASKS_BYNET	(NSS_DBOP_next_noiter)
5267c478bd9Sstevel@tonic-gate 
5277c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PRINTERS_BYNAME	(NSS_DBOP_next_iter)
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate /*
5307c478bd9Sstevel@tonic-gate  * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
5317c478bd9Sstevel@tonic-gate  */
5327c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NETGROUP_IN		(NSS_DBOP_next_iter)
5337c478bd9Sstevel@tonic-gate #define	NSS_DBOP_NETGROUP_SET		(NSS_DBOP_NETGROUP_IN  + 1)
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate /*
5367c478bd9Sstevel@tonic-gate  * The backend for getpublickey and getsecretkey (getkeys)
5377c478bd9Sstevel@tonic-gate  */
5387c478bd9Sstevel@tonic-gate #define	NSS_DBOP_KEYS_BYNAME		(NSS_DBOP_next_iter)
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate /*
5417c478bd9Sstevel@tonic-gate  * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
5427c478bd9Sstevel@tonic-gate  *   any getXXXbyYYY operations, just the usual destr/end/set/get ops,
5437c478bd9Sstevel@tonic-gate  *   so needs no definitions here.
5447c478bd9Sstevel@tonic-gate  */
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate #define	NSS_DBOP_ATTRDB_BYNAME		(NSS_DBOP_next_iter)
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate #define	NSS_DBOP_AUDITUSER_BYNAME	NSS_DBOP_ATTRDB_BYNAME
5497c478bd9Sstevel@tonic-gate #define	NSS_DBOP_AUTHATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
5507c478bd9Sstevel@tonic-gate #define	NSS_DBOP_EXECATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
5517c478bd9Sstevel@tonic-gate #define	NSS_DBOP_EXECATTR_BYID		(NSS_DBOP_EXECATTR_BYNAME + 1)
5527c478bd9Sstevel@tonic-gate #define	NSS_DBOP_EXECATTR_BYNAMEID	(NSS_DBOP_EXECATTR_BYID + 1)
5537c478bd9Sstevel@tonic-gate #define	NSS_DBOP_PROFATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
5547c478bd9Sstevel@tonic-gate #define	NSS_DBOP_USERATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate /*
5577c478bd9Sstevel@tonic-gate  * Used all over in the switch code. The best home for it I can think of.
5587c478bd9Sstevel@tonic-gate  * Power-of-two alignments only.
5597c478bd9Sstevel@tonic-gate  */
5607c478bd9Sstevel@tonic-gate #define	ROUND_DOWN(n, align)	(((uintptr_t)n) & ~((align) - 1l))
5617c478bd9Sstevel@tonic-gate #define	ROUND_UP(n, align)	ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \
5627c478bd9Sstevel@tonic-gate 				(align))
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
5657c478bd9Sstevel@tonic-gate }
5667c478bd9Sstevel@tonic-gate #endif
5677c478bd9Sstevel@tonic-gate 
5687c478bd9Sstevel@tonic-gate #endif /* _NSS_DBDEFS_H */
569