xref: /illumos-gate/usr/src/head/nss_dbdefs.h (revision 1f3e1ca0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Database-speficic definitions for the getXXXbyYYY routines
26  * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
27  * Database-independent definitions are in <nss_common.h>
28  *
29  * Ideally, this is the only switch header file one would add things
30  * to in order to support a new database.
31  *
32  * NOTE:  The interfaces documented in this file may change in a minor
33  *	  release.  It is intended that in the future a stronger committment
34  *	  will be made to these interface definitions which will guarantee
35  *	  them across minor releases.
36  */
37 
38 #ifndef _NSS_DBDEFS_H
39 #define	_NSS_DBDEFS_H
40 
41 #pragma ident	"%Z%%M%	%I%	%E% SMI"
42 
43 #include <errno.h>
44 #include <netdb.h>		/* MAXALIASES, MAXADDRS */
45 #include <limits.h>		/* LOGNAME_MAX */
46 #include <nss_common.h>
47 
48 #ifdef	__cplusplus
49 extern "C" {
50 #endif
51 
52 #ifndef	NSS_INCLUDE_UNSAFE
53 #define	NSS_INCLUDE_UNSAFE	1	/* Build old, MT-unsafe interfaces, */
54 #endif	/* NSS_INCLUDE_UNSAFE */	/*  e.g. getpwnam (c.f. getpwnam_r) */
55 
56 /*
57  * Names of the well-known databases.
58  */
59 
60 #define	NSS_DBNAM_ALIASES	"aliases"	/* E-mail aliases, that is */
61 #define	NSS_DBNAM_AUTOMOUNT	"automount"
62 #define	NSS_DBNAM_BOOTPARAMS	"bootparams"
63 #define	NSS_DBNAM_ETHERS	"ethers"
64 #define	NSS_DBNAM_GROUP		"group"
65 #define	NSS_DBNAM_HOSTS		"hosts"
66 #define	NSS_DBNAM_IPNODES	"ipnodes"
67 #define	NSS_DBNAM_NETGROUP	"netgroup"
68 #define	NSS_DBNAM_NETMASKS	"netmasks"
69 #define	NSS_DBNAM_NETWORKS	"networks"
70 #define	NSS_DBNAM_PASSWD	"passwd"
71 #define	NSS_DBNAM_PRINTERS	"printers"
72 #define	NSS_DBNAM_PROJECT	"project"
73 #define	NSS_DBNAM_PROTOCOLS	"protocols"
74 #define	NSS_DBNAM_PUBLICKEY	"publickey"
75 #define	NSS_DBNAM_RPC		"rpc"
76 #define	NSS_DBNAM_SERVICES	"services"
77 #define	NSS_DBNAM_AUDITUSER	"audit_user"
78 #define	NSS_DBNAM_AUTHATTR	"auth_attr"
79 #define	NSS_DBNAM_EXECATTR	"exec_attr"
80 #define	NSS_DBNAM_PROFATTR	"prof_attr"
81 #define	NSS_DBNAM_USERATTR	"user_attr"
82 
83 /* getspnam() et al use the "passwd" config entry but the "shadow" backend */
84 #define	NSS_DBNAM_SHADOW	"shadow"
85 
86 /* The "compat" backend gets config entries for these pseudo-databases */
87 #define	NSS_DBNAM_PASSWD_COMPAT	"passwd_compat"
88 #define	NSS_DBNAM_GROUP_COMPAT	"group_compat"
89 
90 /*
91  * Default switch configuration, compiled into the front-ends.
92  *
93  * Absent good reasons to the contrary, this should be compatible with the
94  * default /etc/nsswitch.conf file.
95  */
96 #define	NSS_FILES_ONLY		"files"
97 #define	NSS_FILES_NS		"files nis"
98 #define	NSS_NS_FALLBACK		"nis [NOTFOUND=return] files"
99 #define	NSS_NS_ONLY		"nis"
100 
101 #define	NSS_DEFCONF_ALIASES	NSS_FILES_NS
102 #define	NSS_DEFCONF_AUTOMOUNT	NSS_FILES_NS
103 #define	NSS_DEFCONF_BOOTPARAMS	NSS_NS_FALLBACK
104 #define	NSS_DEFCONF_ETHERS	NSS_NS_FALLBACK
105 #define	NSS_DEFCONF_GROUP	NSS_FILES_NS
106 #define	NSS_DEFCONF_HOSTS	NSS_NS_FALLBACK
107 #define	NSS_DEFCONF_IPNODES	NSS_NS_FALLBACK
108 #define	NSS_DEFCONF_NETGROUP	NSS_NS_ONLY
109 #define	NSS_DEFCONF_NETMASKS	NSS_NS_FALLBACK
110 #define	NSS_DEFCONF_NETWORKS	NSS_NS_FALLBACK
111 #define	NSS_DEFCONF_PASSWD	NSS_FILES_NS
112 #define	NSS_DEFCONF_PRINTERS	"user files nis nisplus"
113 #define	NSS_DEFCONF_PROJECT	NSS_FILES_NS
114 #define	NSS_DEFCONF_PROTOCOLS	NSS_NS_FALLBACK
115 #define	NSS_DEFCONF_PUBLICKEY	NSS_FILES_NS
116 #define	NSS_DEFCONF_RPC		NSS_NS_FALLBACK
117 #define	NSS_DEFCONF_SERVICES	NSS_FILES_NS	/* speeds up byname() */
118 
119 #define	NSS_DEFCONF_GROUP_COMPAT	NSS_NS_ONLY
120 #define	NSS_DEFCONF_PASSWD_COMPAT	NSS_NS_ONLY
121 
122 #define	NSS_DEFCONF_ATTRDB	NSS_FILES_NS
123 
124 #define	NSS_DEFCONF_AUDITUSER	NSS_DEFCONF_PASSWD
125 #define	NSS_DEFCONF_USERATTR	NSS_DEFCONF_PASSWD
126 #define	NSS_DEFCONF_AUTHATTR	NSS_DEFCONF_ATTRDB
127 #define	NSS_DEFCONF_PROFATTR	NSS_DEFCONF_ATTRDB
128 #define	NSS_DEFCONF_EXECATTR	NSS_DEFCONF_PROFATTR
129 
130 /*
131  * Line-lengths that the "files" and "compat" backends will try to support.
132  * It may be reasonable (even advisable) to use smaller values than these.
133  */
134 
135 #define	NSS_BUFSIZ		1024
136 
137 #define	NSS_LINELEN_GROUP	((NSS_BUFSIZ) * 8)
138 #define	NSS_LINELEN_HOSTS	((NSS_BUFSIZ) * 8)
139 #define	NSS_LINELEN_IPNODES	((NSS_BUFSIZ) * 8)
140 #define	NSS_LINELEN_NETMASKS	NSS_BUFSIZ
141 #define	NSS_LINELEN_NETWORKS	NSS_BUFSIZ
142 #define	NSS_LINELEN_PASSWD	NSS_BUFSIZ
143 #define	NSS_LINELEN_PRINTERS	NSS_BUFSIZ
144 #define	NSS_LINELEN_PROJECT	((NSS_BUFSIZ) * 4)
145 #define	NSS_LINELEN_PROTOCOLS	NSS_BUFSIZ
146 #define	NSS_LINELEN_PUBLICKEY	NSS_BUFSIZ
147 #define	NSS_LINELEN_RPC		NSS_BUFSIZ
148 #define	NSS_LINELEN_SERVICES	NSS_BUFSIZ
149 #define	NSS_LINELEN_SHADOW	NSS_BUFSIZ
150 #define	NSS_LINELEN_ETHERS	NSS_BUFSIZ
151 #define	NSS_LINELEN_BOOTPARAMS	NSS_BUFSIZ
152 
153 #define	NSS_LINELEN_ATTRDB	NSS_BUFSIZ
154 
155 #define	NSS_LINELEN_AUDITUSER	NSS_LINELEN_ATTRDB
156 #define	NSS_LINELEN_AUTHATTR	NSS_LINELEN_ATTRDB
157 #define	NSS_LINELEN_EXECATTR	NSS_LINELEN_ATTRDB
158 #define	NSS_LINELEN_PROFATTR	NSS_LINELEN_ATTRDB
159 #define	NSS_LINELEN_USERATTR	NSS_LINELEN_ATTRDB
160 
161 #define	NSS_MMAPLEN_EXECATTR	NSS_LINELEN_EXECATTR * 8
162 
163 /*
164  * Reasonable defaults for 'buflen' values passed to _r functions.  The BSD
165  * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard-
166  * coded array sizes;  the values here are meant to handle anything that
167  * those implementations handled.
168  * === These might more reasonably go in <pwd.h>, <netdb.h> et al
169  */
170 
171 #define	NSS_BUFLEN_GROUP	NSS_LINELEN_GROUP
172 #define	NSS_BUFLEN_HOSTS	\
173 	(NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
174 #define	NSS_BUFLEN_IPNODES	\
175 	(NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
176 #define	NSS_BUFLEN_NETGROUP	(MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3)
177 #define	NSS_BUFLEN_NETWORKS	NSS_LINELEN_NETWORKS	/* === ?  + 35 * 4 */
178 #define	NSS_BUFLEN_PASSWD	NSS_LINELEN_PASSWD
179 #define	NSS_BUFLEN_PROJECT	(NSS_LINELEN_PROJECT + 800 * sizeof (char *))
180 #define	NSS_BUFLEN_PROTOCOLS	NSS_LINELEN_PROTOCOLS	/* === ?  + 35 * 4 */
181 #define	NSS_BUFLEN_PUBLICKEY	NSS_LINELEN_PUBLICKEY
182 #define	NSS_BUFLEN_RPC		NSS_LINELEN_RPC		/* === ?  + 35 * 4 */
183 #define	NSS_BUFLEN_SERVICES	NSS_LINELEN_SERVICES	/* === ?  + 35 * 4 */
184 #define	NSS_BUFLEN_SHADOW	NSS_LINELEN_SHADOW
185 #define	NSS_BUFLEN_ETHERS	NSS_LINELEN_ETHERS
186 #define	NSS_BUFLEN_BOOTPARAMS	NSS_LINELEN_BOOTPARAMS
187 
188 #define	NSS_BUFLEN_ATTRDB	NSS_LINELEN_ATTRDB
189 
190 #define	NSS_BUFLEN_AUDITUSER	NSS_BUFLEN_ATTRDB
191 #define	NSS_BUFLEN_AUTHATTR	NSS_BUFLEN_ATTRDB
192 #define	NSS_BUFLEN_EXECATTR	NSS_BUFLEN_ATTRDB
193 #define	NSS_BUFLEN_PROFATTR	NSS_BUFLEN_ATTRDB
194 #define	NSS_BUFLEN_USERATTR	((NSS_BUFLEN_ATTRDB) * 8)
195 
196 
197 /*
198  * Arguments and results, passed between the frontends and backends for
199  * the well-known databases.  The getXbyY_r() and getXent_r() routines
200  * use a common format that is further described below;  other routines
201  * use their own formats.
202  */
203 
204 /*
205  * The initgroups() function [see initgroups(3c)] needs to find all the
206  *   groups to which a given user belongs.  To do this it calls
207  *   _getgroupsbymember(), which is part of the frontend for the "group"
208  *   database.
209  * We want the same effect as if we used getgrent_r() to enumerate the
210  *   entire groups database (possibly from multiple sources), but getgrent_r()
211  *   is too inefficient.  Most backends can do better if they know they're
212  *   meant to scan all groups;  hence there's a separate backend operation,
213  *   NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct.
214  * Note that the normal return-value from such a backend, even when it
215  *   successfully finds matching group entries, is NSS_NOTFOUND, because
216  *   this tells the switch engine to keep searching in any more sources.
217  *   In fact, the backends only return NSS_SUCCESS if they find enough
218  *   matching entries that the gid_array is completely filled, in which
219  *   case the switch engine should stop searching.
220  * If the force_slow_way field is set, the backend should eschew any cached
221  *   information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table)
222  *   and should instead grind its way through the group map/table/whatever.
223  */
224 
225 struct nss_groupsbymem {			/* For _getgroupsbymember() */
226 /* in: */
227 	const char	*username;
228 	gid_t		*gid_array;
229 	int		maxgids;
230 	int		force_slow_way;
231 	/*
232 	 * The process_cstr() routine does the real work for any backend
233 	 * that can supply a group entry as a string in /etc/group format
234 	 */
235 #if defined(__STDC__)
236 	int		(*str2ent)	(const char		*instr,
237 					int			instr_len,
238 					void *ent, char *buffer, int buflen);
239 	nss_status_t	(*process_cstr)	(const char		*instr,
240 					int			instr_len,
241 					struct nss_groupsbymem *);
242 #else
243 	int		(*str2ent)();
244 	nss_status_t	(*process_cstr)();
245 #endif
246 
247 /* in_out: */
248 	int		numgids;
249 };
250 
251 /*
252  * The netgroup routines are handled as follows:
253  *
254  *   Policy decision:
255  *	If netgroup A refers to netgroup B, both must occur in the same
256  *	source (other choices give very confusing semantics).  This
257  *	assumption is deeply embedded in the frontend and backends.
258  *
259  *    -	setnetgrent(), despite its name, is really a getXXXbyYYY operation:
260  *	it takes a name and finds a netgroup with that name (see the
261  *	nss_setnetgrent_args struct below).  The "result" that it returns
262  *	to the frontend is an nss_backend_t for a pseudo-backend that allows
263  *	one to enumerate the members of that netgroup.
264  *
265  *    -	getnetgrent() calls the 'getXXXent' function in the pseudo-backend;
266  *	it doesn't go through the switch engine at all.  It uses the
267  *	nss_getnetgrent_args struct below.
268  *
269  *    -	innetgr() is implemented on top of __multi_innetgr(), which replaces
270  *	each (char *) argument of innetgr() with a counted vector of (char *).
271  *	The semantics are the same as an OR of the results of innetgr()
272  *	operations on each possible 4-tuple picked from the arguments, but
273  *	it's possible to implement some cases more efficiently.  This is
274  *	important for mountd, which used to read YP netgroup.byhost directly
275  *	in order to determine efficiently whether a given host belonged to any
276  *	one of a long list of netgroups.  Wildcarded arguments are indicated
277  *	by a count of zero.
278  *
279  *    -	__multi_innetgr() uses the nss_innetgr_args struct.  A backend whose
280  *	source contains at least one of the groups listed in the 'groups'
281  *	vector will return NSS_SUCCESS and will set the 'status' field to
282  *	indicate whether any 4-tuple was satisfied.  A backend will only
283  *	return NSS_NOTFOUND if the source contained none of the groups
284  *	listed in the 'groups' vector.
285  */
286 
287 enum nss_netgr_argn {		/* We need (machine, user, domain) triples */
288 	NSS_NETGR_MACHINE,
289 	NSS_NETGR_USER,
290 	NSS_NETGR_DOMAIN,
291 	NSS_NETGR_N
292 };
293 
294 enum nss_netgr_status {		/* Status from setnetgrent, multi_innetgr */
295 	NSS_NETGR_FOUND,
296 	NSS_NETGR_NO,
297 	NSS_NETGR_NOMEM
298 };
299 
300 struct nss_setnetgrent_args {
301 /* in: */
302 	const char		*netgroup;
303 /* out: */
304 	nss_backend_t		*iterator;	/* <==== Explain */
305 };
306 
307 struct nss_getnetgrent_args {
308 /* in: */
309 	char			*buffer;
310 	int			buflen;
311 /* out: */
312 	enum nss_netgr_status	status;
313 	char			*retp[NSS_NETGR_N];
314 };
315 
316 typedef unsigned	nss_innetgr_argc;    /* 0 means wildcard */
317 typedef char **		nss_innetgr_argv;    /* === Do we really need these? */
318 
319 struct nss_innetgr_1arg {
320 	nss_innetgr_argc	argc;
321 	nss_innetgr_argv	argv;
322 };
323 
324 struct nss_innetgr_args {
325 /* in: */
326 	struct nss_innetgr_1arg	arg[NSS_NETGR_N];
327 	struct nss_innetgr_1arg groups;
328 /* out: */
329 	enum nss_netgr_status	status;
330 };
331 
332 
333 /*
334  * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
335  *   getXXXbyYYY_r() and getXXXent_r() routines.  The (void *) value points to
336  *   a struct of the appropriate type, e.g. struct passwd or struct hostent.
337  *
338  * The functions that allocate and free these structures do no locking at
339  * all, since the routines that use them are inherently MT-unsafe anyway.
340  */
341 
342 typedef struct {
343 	void		*result;	/* "result" parameter to getXbyY_r() */
344 	char		*buffer;	/* "buffer"     "             "      */
345 	int		buflen;		/* "buflen"     "             "      */
346 } nss_XbyY_buf_t;
347 
348 #if defined(__STDC__)
349 extern nss_XbyY_buf_t	*_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
350 extern void		 _nss_XbyY_buf_free(nss_XbyY_buf_t *);
351 #else
352 extern nss_XbyY_buf_t	*_nss_XbyY_buf_alloc();
353 extern void		 _nss_XbyY_buf_free();
354 #endif
355 
356 #define	NSS_XbyY_ALLOC(bufpp, str_size, buf_size)		(\
357 	(*bufpp) == 0						\
358 	? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size)	\
359 	: (*bufpp))						\
360 
361 #define	NSS_XbyY_FREE(bufpp)	(_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0)
362 
363 /*
364  * The nss_XbyY_args_t struct contains all the information passed between
365  * frontends and backends for the getXbyY_r() and getXent() routines,
366  * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r).
367  *
368  * The (*str2ent)() member converts a single XXXent from ASCII text to the
369  * appropriate struct, storing any pointer data (strings, in_addrs, arrays
370  * of these) in the buffer.  The ASCII text is a counted string (*not* a
371  * zero-terminated string) whose length is specified by the instr_len
372  * parameter.  The text is found at the address specified by instr and
373  * the string is treated as readonly. buffer and instr must be non-
374  * intersecting memory areas.
375  *
376  * With the exception of passwd, shadow and group, the text form for these
377  * databases allows trailing comments and arbitrary whitespace.  The
378  * corresponding str2ent routine assumes that comments, leading whitespace
379  * and trailing whitespace have been stripped (and thus assumes that entries
380  * consisting only of these have been discarded).
381  *
382  * The text entries for "rpc" and for the databases described in <netdb.h>
383  * follow a common format (a canonical name with a possibly empty list
384  * of aliases, and some other value), albeit with minor variations.
385  * The function _nss_netdb_aliases() does most of the generic work involved
386  * in parsing and marshalling these into the buffer.
387  */
388 
389 union nss_XbyY_key {	/* No tag;  backend should know what to expect */
390 	uid_t		uid;
391 	gid_t		gid;
392 	projid_t	projid;
393 	const char	*name;
394 	int		number;
395 	struct {
396 		int	net;
397 		int		type;
398 	}	netaddr;
399 	struct {
400 		const char	*addr;
401 		int		len;
402 		int		type;
403 	}	hostaddr;
404 	struct {
405 		union {
406 			const char	*name;
407 			int		port;
408 		}		serv;
409 		const char	*proto;
410 	}	serv;
411 	void *ether;
412 	struct {
413 		const char	*name;
414 		const char	*keytype;
415 	} pkey;
416 	struct {
417 		const char	*name;
418 		int		af_family;
419 		int		flags;
420 	}	ipnode;
421 	void *attrp;	/* for the new attr databases */
422 };
423 
424 typedef struct nss_XbyY_args {
425 
426 /* IN */
427 	nss_XbyY_buf_t	buf;
428 	int		stayopen;
429 			/*
430 			 * Support for setXXXent(stayopen)
431 			 * Used only in hosts, protocols,
432 			 * networks, rpc, and services.
433 			 */
434 #if defined(__STDC__)
435 	int		(*str2ent)	(const char		*instr,
436 					int			instr_len,
437 					void *ent, char *buffer, int buflen);
438 #else
439 	int		(*str2ent)();
440 #endif
441 	union nss_XbyY_key key;
442 
443 /* OUT */
444 	void		*returnval;
445 	int		erange;
446 	int		h_errno;		/* For gethost*_r() */
447 	nss_status_t	status; /* from the backend last called */
448 } nss_XbyY_args_t;
449 
450 /* status returned by the str2ent parsing routines */
451 #define	NSS_STR_PARSE_SUCCESS 0
452 #define	NSS_STR_PARSE_PARSE 1
453 #define	NSS_STR_PARSE_ERANGE 2
454 
455 #define	NSS_XbyY_INIT(str, res, bufp, len, func)	(\
456 	(str)->buf.result = (res),			\
457 	(str)->buf.buffer = (bufp),			\
458 	(str)->buf.buflen = (len),			\
459 	(str)->stayopen  = 0,				\
460 	(str)->str2ent  = (func),			\
461 	(str)->returnval = 0,				\
462 	(str)->erange    = 0)
463 
464 #define	NSS_XbyY_FINI(str)				(\
465 	(str)->returnval == 0 && (str)->erange && (errno = ERANGE), \
466 	(str)->returnval)
467 
468 #if defined(__STDC__)
469 extern char		**_nss_netdb_aliases
470 	(const char *, int, char *, int);
471 #else
472 extern char		**_nss_netdb_aliases();
473 #endif
474 
475 /*
476  * nss_dbop_t values for searches with various keys;  values for
477  * destructor/endent/setent/getent are defined in <nss_common.h>
478  */
479 
480 #define	NSS_DBOP_GROUP_BYNAME		(NSS_DBOP_next_iter)
481 #define	NSS_DBOP_GROUP_BYGID		(NSS_DBOP_GROUP_BYNAME + 1)
482 #define	NSS_DBOP_GROUP_BYMEMBER		(NSS_DBOP_GROUP_BYGID  + 1)
483 
484 #define	NSS_DBOP_PASSWD_BYNAME		(NSS_DBOP_next_iter)
485 #define	NSS_DBOP_PASSWD_BYUID		(NSS_DBOP_PASSWD_BYNAME + 1)
486 
487 /* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */
488 /*   (it also requires that both use key.name to pass the username). */
489 #define	NSS_DBOP_SHADOW_BYNAME		(NSS_DBOP_PASSWD_BYNAME)
490 
491 #define	NSS_DBOP_PROJECT_BYNAME		(NSS_DBOP_next_iter)
492 #define	NSS_DBOP_PROJECT_BYID		(NSS_DBOP_PROJECT_BYNAME + 1)
493 
494 #define	NSS_DBOP_HOSTS_BYNAME		(NSS_DBOP_next_iter)
495 #define	NSS_DBOP_HOSTS_BYADDR		(NSS_DBOP_HOSTS_BYNAME + 1)
496 
497 #define	NSS_DBOP_IPNODES_BYNAME		(NSS_DBOP_next_iter)
498 #define	NSS_DBOP_IPNODES_BYADDR		(NSS_DBOP_IPNODES_BYNAME + 1)
499 
500 /*
501  * NSS_DBOP_NAME_2ADDR
502  * NSS_DBOP_ADDR_2NAME
503  *                                : are defines for ipv6 api's
504  */
505 
506 #define	NSS_DBOP_NAME_2ADDR		(NSS_DBOP_next_ipv6_iter)
507 #define	NSS_DBOP_ADDR_2NAME		(NSS_DBOP_NAME_2ADDR + 1)
508 
509 #define	NSS_DBOP_RPC_BYNAME		(NSS_DBOP_next_iter)
510 #define	NSS_DBOP_RPC_BYNUMBER		(NSS_DBOP_RPC_BYNAME + 1)
511 
512 #define	NSS_DBOP_NETWORKS_BYNAME		(NSS_DBOP_next_iter)
513 #define	NSS_DBOP_NETWORKS_BYADDR		(NSS_DBOP_NETWORKS_BYNAME + 1)
514 
515 #define	NSS_DBOP_SERVICES_BYNAME	(NSS_DBOP_next_iter)
516 #define	NSS_DBOP_SERVICES_BYPORT	(NSS_DBOP_SERVICES_BYNAME + 1)
517 
518 #define	NSS_DBOP_PROTOCOLS_BYNAME	(NSS_DBOP_next_iter)
519 #define	NSS_DBOP_PROTOCOLS_BYNUMBER	(NSS_DBOP_PROTOCOLS_BYNAME + 1)
520 
521 #define	NSS_DBOP_ETHERS_HOSTTON	(NSS_DBOP_next_noiter)
522 #define	NSS_DBOP_ETHERS_NTOHOST	(NSS_DBOP_ETHERS_HOSTTON + 1)
523 
524 #define	NSS_DBOP_BOOTPARAMS_BYNAME	(NSS_DBOP_next_noiter)
525 #define	NSS_DBOP_NETMASKS_BYNET	(NSS_DBOP_next_noiter)
526 
527 #define	NSS_DBOP_PRINTERS_BYNAME	(NSS_DBOP_next_iter)
528 
529 /*
530  * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
531  */
532 #define	NSS_DBOP_NETGROUP_IN		(NSS_DBOP_next_iter)
533 #define	NSS_DBOP_NETGROUP_SET		(NSS_DBOP_NETGROUP_IN  + 1)
534 
535 /*
536  * The backend for getpublickey and getsecretkey (getkeys)
537  */
538 #define	NSS_DBOP_KEYS_BYNAME		(NSS_DBOP_next_iter)
539 
540 /*
541  * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
542  *   any getXXXbyYYY operations, just the usual destr/end/set/get ops,
543  *   so needs no definitions here.
544  */
545 
546 #define	NSS_DBOP_ATTRDB_BYNAME		(NSS_DBOP_next_iter)
547 
548 #define	NSS_DBOP_AUDITUSER_BYNAME	NSS_DBOP_ATTRDB_BYNAME
549 #define	NSS_DBOP_AUTHATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
550 #define	NSS_DBOP_EXECATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
551 #define	NSS_DBOP_EXECATTR_BYID		(NSS_DBOP_EXECATTR_BYNAME + 1)
552 #define	NSS_DBOP_EXECATTR_BYNAMEID	(NSS_DBOP_EXECATTR_BYID + 1)
553 #define	NSS_DBOP_PROFATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
554 #define	NSS_DBOP_USERATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
555 
556 /*
557  * Used all over in the switch code. The best home for it I can think of.
558  * Power-of-two alignments only.
559  */
560 #define	ROUND_DOWN(n, align)	(((uintptr_t)n) & ~((align) - 1l))
561 #define	ROUND_UP(n, align)	ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \
562 				(align))
563 
564 #ifdef	__cplusplus
565 }
566 #endif
567 
568 #endif /* _NSS_DBDEFS_H */
569