8749 loader: efipart_strategy is using wrong offset with >512B sectors
[unleashed.git] / include / nss_dbdefs.h
blob051aeb2897ec2af86d27a58b656b214556be1a25
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
27 * Database-specific definitions for the getXXXbyYYY routines
28 * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
29 * Database-independent definitions are in <nss_common.h>
31 * Ideally, this is the only switch header file one would add things
32 * to in order to support a new database.
34 * NOTE: The interfaces documented in this file may change in a minor
35 * release. It is intended that in the future a stronger committment
36 * will be made to these interface definitions which will guarantee
37 * them across minor releases.
40 #ifndef _NSS_DBDEFS_H
41 #define _NSS_DBDEFS_H
43 #include <sys/types.h>
44 #include <unistd.h>
45 #include <errno.h>
46 #include <netdb.h> /* MAXALIASES, MAXADDRS */
47 #include <limits.h> /* LOGNAME_MAX */
48 #include <nss_common.h>
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
55 * Names of the well-known databases.
58 #define NSS_DBNAM_ALIASES "aliases" /* E-mail aliases, that is */
59 #define NSS_DBNAM_AUTOMOUNT "automount"
60 #define NSS_DBNAM_BOOTPARAMS "bootparams"
61 #define NSS_DBNAM_ETHERS "ethers"
62 #define NSS_DBNAM_GROUP "group"
63 #define NSS_DBNAM_HOSTS "hosts"
64 #define NSS_DBNAM_IPNODES "ipnodes"
65 #define NSS_DBNAM_NETGROUP "netgroup"
66 #define NSS_DBNAM_NETMASKS "netmasks"
67 #define NSS_DBNAM_NETWORKS "networks"
68 #define NSS_DBNAM_PASSWD "passwd"
69 #define NSS_DBNAM_PRINTERS "printers"
70 #define NSS_DBNAM_PROJECT "project"
71 #define NSS_DBNAM_PROTOCOLS "protocols"
72 #define NSS_DBNAM_PUBLICKEY "publickey"
73 #define NSS_DBNAM_RPC "rpc"
74 #define NSS_DBNAM_SERVICES "services"
75 #define NSS_DBNAM_AUDITUSER "audit_user"
76 #define NSS_DBNAM_AUTHATTR "auth_attr"
77 #define NSS_DBNAM_EXECATTR "exec_attr"
78 #define NSS_DBNAM_PROFATTR "prof_attr"
79 #define NSS_DBNAM_USERATTR "user_attr"
81 /* getspnam() et al use the "passwd" config entry but the "shadow" backend */
82 #define NSS_DBNAM_SHADOW "shadow"
84 /* The "compat" backend gets config entries for these pseudo-databases */
85 #define NSS_DBNAM_PASSWD_COMPAT "passwd_compat"
86 #define NSS_DBNAM_GROUP_COMPAT "group_compat"
89 * Default switch configuration, compiled into the front-ends.
91 * Absent good reasons to the contrary, this should be compatible with the
92 * default /etc/nsswitch.conf file.
94 #define NSS_FILES_ONLY "files"
95 #define NSS_FILES_NS "files nis"
96 #define NSS_NS_FALLBACK "nis [NOTFOUND=return] files"
97 #define NSS_NS_ONLY "nis"
99 #define NSS_DEFCONF_ALIASES NSS_FILES_NS
100 #define NSS_DEFCONF_AUTOMOUNT NSS_FILES_NS
101 #define NSS_DEFCONF_BOOTPARAMS NSS_NS_FALLBACK
102 #define NSS_DEFCONF_ETHERS NSS_NS_FALLBACK
103 #define NSS_DEFCONF_GROUP NSS_FILES_NS
104 #define NSS_DEFCONF_HOSTS NSS_NS_FALLBACK
105 #define NSS_DEFCONF_IPNODES NSS_NS_FALLBACK
106 #define NSS_DEFCONF_NETGROUP NSS_NS_ONLY
107 #define NSS_DEFCONF_NETMASKS NSS_NS_FALLBACK
108 #define NSS_DEFCONF_NETWORKS NSS_NS_FALLBACK
109 #define NSS_DEFCONF_PASSWD NSS_FILES_NS
110 #define NSS_DEFCONF_PRINTERS "user files nis"
111 #define NSS_DEFCONF_PROJECT NSS_FILES_NS
112 #define NSS_DEFCONF_PROTOCOLS NSS_NS_FALLBACK
113 #define NSS_DEFCONF_PUBLICKEY NSS_FILES_NS
114 #define NSS_DEFCONF_RPC NSS_NS_FALLBACK
115 #define NSS_DEFCONF_SERVICES NSS_FILES_NS /* speeds up byname() */
117 #define NSS_DEFCONF_GROUP_COMPAT NSS_NS_ONLY
118 #define NSS_DEFCONF_PASSWD_COMPAT NSS_NS_ONLY
120 #define NSS_DEFCONF_ATTRDB NSS_FILES_NS
122 #define NSS_DEFCONF_AUDITUSER NSS_DEFCONF_PASSWD
123 #define NSS_DEFCONF_USERATTR NSS_DEFCONF_PASSWD
124 #define NSS_DEFCONF_AUTHATTR NSS_DEFCONF_ATTRDB
125 #define NSS_DEFCONF_PROFATTR NSS_DEFCONF_ATTRDB
126 #define NSS_DEFCONF_EXECATTR NSS_DEFCONF_PROFATTR
129 * Line-lengths that the "files" and "compat" backends will try to support.
130 * It may be reasonable (even advisable) to use smaller values than these.
133 #define NSS_BUFSIZ 1024
135 #define NSS_LINELEN_GROUP ((NSS_BUFSIZ) * 8)
136 #define NSS_LINELEN_HOSTS ((NSS_BUFSIZ) * 8)
137 #define NSS_LINELEN_IPNODES ((NSS_BUFSIZ) * 8)
138 #define NSS_LINELEN_NETMASKS NSS_BUFSIZ
139 #define NSS_LINELEN_NETWORKS NSS_BUFSIZ
140 #define NSS_LINELEN_PASSWD NSS_BUFSIZ
141 #define NSS_LINELEN_PRINTERS NSS_BUFSIZ
142 #define NSS_LINELEN_PROJECT ((NSS_BUFSIZ) * 4)
143 #define NSS_LINELEN_PROTOCOLS NSS_BUFSIZ
144 #define NSS_LINELEN_PUBLICKEY NSS_BUFSIZ
145 #define NSS_LINELEN_RPC NSS_BUFSIZ
146 #define NSS_LINELEN_SERVICES NSS_BUFSIZ
147 #define NSS_LINELEN_SHADOW NSS_BUFSIZ
148 #define NSS_LINELEN_ETHERS NSS_BUFSIZ
149 #define NSS_LINELEN_BOOTPARAMS NSS_BUFSIZ
151 #define NSS_LINELEN_ATTRDB NSS_BUFSIZ
153 #define NSS_LINELEN_AUDITUSER NSS_LINELEN_ATTRDB
154 #define NSS_LINELEN_AUTHATTR NSS_LINELEN_ATTRDB
155 #define NSS_LINELEN_EXECATTR NSS_LINELEN_ATTRDB
156 #define NSS_LINELEN_PROFATTR NSS_LINELEN_ATTRDB
157 #define NSS_LINELEN_USERATTR NSS_LINELEN_ATTRDB
159 #define NSS_MMAPLEN_EXECATTR NSS_LINELEN_EXECATTR * 8
162 * Reasonable defaults for 'buflen' values passed to _r functions. The BSD
163 * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard-
164 * coded array sizes; the values here are meant to handle anything that
165 * those implementations handled.
166 * === These might more reasonably go in <pwd.h>, <netdb.h> et al
169 #define NSS_BUFLEN_GROUP NSS_LINELEN_GROUP
170 #define NSS_BUFLEN_HOSTS \
171 (NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
172 #define NSS_BUFLEN_IPNODES \
173 (NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
174 #define NSS_BUFLEN_NETGROUP (MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3)
175 #define NSS_BUFLEN_NETWORKS NSS_LINELEN_NETWORKS /* === ? + 35 * 4 */
176 #define NSS_BUFLEN_PASSWD NSS_LINELEN_PASSWD
177 #define NSS_BUFLEN_PROJECT (NSS_LINELEN_PROJECT + 800 * sizeof (char *))
178 #define NSS_BUFLEN_PROTOCOLS NSS_LINELEN_PROTOCOLS /* === ? + 35 * 4 */
179 #define NSS_BUFLEN_PUBLICKEY NSS_LINELEN_PUBLICKEY
180 #define NSS_BUFLEN_RPC NSS_LINELEN_RPC /* === ? + 35 * 4 */
181 #define NSS_BUFLEN_SERVICES NSS_LINELEN_SERVICES /* === ? + 35 * 4 */
182 #define NSS_BUFLEN_SHADOW NSS_LINELEN_SHADOW
183 #define NSS_BUFLEN_ETHERS NSS_LINELEN_ETHERS
184 #define NSS_BUFLEN_BOOTPARAMS NSS_LINELEN_BOOTPARAMS
186 #define NSS_BUFLEN_ATTRDB NSS_LINELEN_ATTRDB
188 #define NSS_BUFLEN_AUDITUSER NSS_BUFLEN_ATTRDB
189 #define NSS_BUFLEN_AUTHATTR NSS_BUFLEN_ATTRDB
190 #define NSS_BUFLEN_EXECATTR NSS_BUFLEN_ATTRDB
191 #define NSS_BUFLEN_PROFATTR NSS_BUFLEN_ATTRDB
192 #define NSS_BUFLEN_USERATTR ((NSS_BUFLEN_ATTRDB) * 8)
195 * Default cache door buffer size (2x largest buffer)
198 #define NSS_BUFLEN_DOOR ((NSS_BUFSIZ) * 16)
201 * Arguments and results, passed between the frontends and backends for
202 * the well-known databases. The getXbyY_r() and getXent_r() routines
203 * use a common format that is further described below; other routines
204 * use their own formats.
208 * The nss_str2ent_t routine is the data marshaller for the nsswitch.
209 * it converts 'native files' format into 'entry' format as part of the
210 * return processing for a getXbyY interface.
212 * The nss_groupstr_t routine does the real work for any backend
213 * that can supply a netgroup entry as a string in /etc/group format
215 typedef int (*nss_str2ent_t)(const char *in, int inlen,
216 void *ent, char *buf, int buflen);
218 struct nss_groupsbymem; /* forward definition */
219 typedef nss_status_t (*nss_groupstr_t)(const char *instr, int inlen,
220 struct nss_groupsbymem *);
223 * The initgroups() function [see initgroups(3c)] needs to find all the
224 * groups to which a given user belongs. To do this it calls
225 * _getgroupsbymember(), which is part of the frontend for the "group"
226 * database.
227 * We want the same effect as if we used getgrent_r() to enumerate the
228 * entire groups database (possibly from multiple sources), but getgrent_r()
229 * is too inefficient. Most backends can do better if they know they're
230 * meant to scan all groups; hence there's a separate backend operation,
231 * NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct.
232 * Note that the normal return-value from such a backend, even when it
233 * successfully finds matching group entries, is NSS_NOTFOUND, because
234 * this tells the switch engine to keep searching in any more sources.
235 * In fact, the backends only return NSS_SUCCESS if they find enough
236 * matching entries that the gid_array is completely filled, in which
237 * case the switch engine should stop searching.
238 * If the force_slow_way field is set, the backend should eschew any cached
239 * information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table)
240 * and should instead grind its way through the group map/table/whatever.
243 struct nss_groupsbymem { /* For _getgroupsbymember() */
244 /* in: */
245 const char *username;
246 gid_t *gid_array;
247 int maxgids;
248 int force_slow_way;
249 nss_str2ent_t str2ent;
250 nss_groupstr_t process_cstr;
252 /* in_out: */
253 int numgids;
257 * The netgroup routines are handled as follows:
259 * Policy decision:
260 * If netgroup A refers to netgroup B, both must occur in the same
261 * source (other choices give very confusing semantics). This
262 * assumption is deeply embedded in the frontend and backends.
264 * - setnetgrent(), despite its name, is really a getXXXbyYYY operation:
265 * it takes a name and finds a netgroup with that name (see the
266 * nss_setnetgrent_args struct below). The "result" that it returns
267 * to the frontend is an nss_backend_t for a pseudo-backend that allows
268 * one to enumerate the members of that netgroup.
270 * - getnetgrent() calls the 'getXXXent' function in the pseudo-backend;
271 * it doesn't go through the switch engine at all. It uses the
272 * nss_getnetgrent_args struct below.
274 * - innetgr() is implemented on top of __multi_innetgr(), which replaces
275 * each (char *) argument of innetgr() with a counted vector of (char *).
276 * The semantics are the same as an OR of the results of innetgr()
277 * operations on each possible 4-tuple picked from the arguments, but
278 * it's possible to implement some cases more efficiently. This is
279 * important for mountd, which used to read YP netgroup.byhost directly
280 * in order to determine efficiently whether a given host belonged to any
281 * one of a long list of netgroups. Wildcarded arguments are indicated
282 * by a count of zero.
284 * - __multi_innetgr() uses the nss_innetgr_args struct. A backend whose
285 * source contains at least one of the groups listed in the 'groups'
286 * vector will return NSS_SUCCESS and will set the 'status' field to
287 * indicate whether any 4-tuple was satisfied. A backend will only
288 * return NSS_NOTFOUND if the source contained none of the groups
289 * listed in the 'groups' vector.
292 enum nss_netgr_argn { /* We need (machine, user, domain) triples */
293 NSS_NETGR_MACHINE = 0,
294 NSS_NETGR_USER = 1,
295 NSS_NETGR_DOMAIN = 2,
296 NSS_NETGR_N = 3
299 enum nss_netgr_status { /* Status from setnetgrent, multi_innetgr */
300 NSS_NETGR_FOUND = 0,
301 NSS_NETGR_NO = 1,
302 NSS_NETGR_NOMEM = 2
305 struct nss_setnetgrent_args {
306 /* in: */
307 const char *netgroup;
308 /* out: */
309 nss_backend_t *iterator; /* <==== Explain */
312 struct nss_getnetgrent_args {
313 /* in: */
314 char *buffer;
315 int buflen;
316 /* out: */
317 enum nss_netgr_status status;
318 char *retp[NSS_NETGR_N];
321 typedef unsigned nss_innetgr_argc; /* 0 means wildcard */
322 typedef char ** nss_innetgr_argv; /* === Do we really need these? */
324 struct nss_innetgr_1arg {
325 nss_innetgr_argc argc;
326 nss_innetgr_argv argv;
329 struct nss_innetgr_args {
330 /* in: */
331 struct nss_innetgr_1arg arg[NSS_NETGR_N];
332 struct nss_innetgr_1arg groups;
333 /* out: */
334 enum nss_netgr_status status;
338 * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
339 * getXXXbyYYY_r() and getXXXent_r() routines. The (void *) value points to
340 * a struct of the appropriate type, e.g. struct passwd or struct hostent.
342 * The functions that allocate and free these structures do no locking at
343 * all, since the routines that use them are inherently MT-unsafe anyway.
346 typedef struct {
347 void *result; /* "result" parameter to getXbyY_r() */
348 char *buffer; /* "buffer" " " */
349 int buflen; /* "buflen" " " */
350 } nss_XbyY_buf_t;
352 extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
353 extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
355 #define NSS_XbyY_ALLOC(bufpp, str_size, buf_size) (\
356 (*bufpp) == 0 \
357 ? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size) \
358 : (*bufpp))
360 #define NSS_XbyY_FREE(bufpp) (_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0)
363 * The nss_XbyY_args_t struct contains all the information passed between
364 * frontends and backends for the getXbyY_r() and getXent() routines,
365 * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r).
367 * The (*str2ent)() member converts a single XXXent from ASCII text to the
368 * appropriate struct, storing any pointer data (strings, in_addrs, arrays
369 * of these) in the buffer. The ASCII text is a counted string (*not* a
370 * zero-terminated string) whose length is specified by the instr_len
371 * parameter. The text is found at the address specified by instr and
372 * the string is treated as readonly. buffer and instr must be non-
373 * intersecting memory areas.
375 * With the exception of passwd, shadow and group, the text form for these
376 * databases allows trailing comments and arbitrary whitespace. The
377 * corresponding str2ent routine assumes that comments, leading whitespace
378 * and trailing whitespace have been stripped (and thus assumes that entries
379 * consisting only of these have been discarded).
381 * The text entries for "rpc" and for the databases described in <netdb.h>
382 * follow a common format (a canonical name with a possibly empty list
383 * of aliases, and some other value), albeit with minor variations.
384 * The function _nss_netdb_aliases() does most of the generic work involved
385 * in parsing and marshalling these into the buffer.
388 typedef union nss_XbyY_key { /* No tag; backend should know what to expect */
389 uid_t uid;
390 gid_t gid;
391 projid_t projid;
392 const char *name;
393 int number;
394 struct {
395 int net;
396 int type;
397 } netaddr;
398 struct {
399 const char *addr;
400 int len;
401 int type;
402 } hostaddr;
403 struct {
404 union {
405 const char *name;
406 int port;
407 } serv;
408 const char *proto;
409 } serv;
410 void *ether;
411 struct {
412 const char *name;
413 const char *keytype;
414 } pkey;
415 struct {
416 const char *name;
417 int af_family;
418 int flags;
419 } ipnode;
420 void *attrp; /* for the new attr databases */
421 } nss_XbyY_key_t;
424 typedef int (*nss_key2str_t)(void *buffer, size_t buflen,
425 nss_XbyY_key_t *key, size_t *len);
428 typedef struct nss_XbyY_args {
430 /* IN */
431 nss_XbyY_buf_t buf;
432 int stayopen;
434 * Support for setXXXent(stayopen)
435 * Used only in hosts, protocols,
436 * networks, rpc, and services.
438 nss_str2ent_t str2ent;
439 union nss_XbyY_key key;
441 /* OUT */
442 void *returnval;
443 int erange;
444 int h_errno; /* For gethost*_r() */
445 nss_status_t status; /* from the backend last called */
446 /* NSS2 */
447 nss_key2str_t key2str; /* IN */
448 size_t returnlen; /* OUT */
450 /* NSCD/DOOR data */
452 /* ... buffer arena follows... */
453 } nss_XbyY_args_t;
458 * nss/nscd v2 interface, packed buffer format
460 * A key component of the v2 name service switch is the redirection
461 * of all activity to nscd for actual processing. In the original
462 * switch most activity took place in each application, and the nscd
463 * cache component was an add-on optional interface.
465 * The nscd v1 format was a completely private interface that
466 * implemented specific bufferiing formats on a per getXbyY API basis.
468 * The nss/nscd v2 interface uses a common header and commonalizes
469 * the buffering format as consistently as possible. The general rule
470 * of thumb is that backends are required to assemble their results in
471 * "files based" format [IE the format used on a per result basis as
472 * returned by the files backend] and then call the standard str2ent
473 * interface. This is the original intended design as used in the files
474 * and nis backends.
476 * The benefit of this is that the application side library can assemble
477 * a request and provide a header and a variable length result buffer via
478 * a doors API, and then the nscd side switch can assemble a a getXbyY
479 * request providing the result buffer and a str2ent function that copies
480 * but does not unpack the result.
482 * This results is returned back via the door, and unpacked using the
483 * native library side str2ent interface.
485 * Additionally, the common header allows extensibility to add new
486 * getXbyYs, putXbyYs or other maintenance APIs to/from nscd without
487 * changing the existing "old style" backend interfaces.
489 * Finally new style getXbyY, putXbyY and backend interfaces can be
490 * by adding new operation requests to the header, while old style
491 * backwards compatability.
495 * nss/nscd v2 callnumber definitions
499 * callnumbers are separated by categories, such as:
500 * application to nscd requests, nscd to nscd requests,
501 * smf to nscd requests, etc.
504 #define NSCDV2CATMASK (0xFF000000)
505 #define NSCDV2CALLMASK (0x00FFFFFF)
508 * nss/nscd v2 categories
511 #define NSCD_CALLCAT_APP ('a'<<24)
512 #define NSCD_CALLCAT_N2N ('n'<<24)
514 /* nscd v2 app-> nscd callnumbers */
516 #define NSCD_SEARCH (NSCD_CALLCAT_APP|0x01)
517 #define NSCD_SETENT (NSCD_CALLCAT_APP|0x02)
518 #define NSCD_GETENT (NSCD_CALLCAT_APP|0x03)
519 #define NSCD_ENDENT (NSCD_CALLCAT_APP|0x04)
520 #define NSCD_PUT (NSCD_CALLCAT_APP|0x05)
521 #define NSCD_GETHINTS (NSCD_CALLCAT_APP|0x06)
523 /* nscd v2 SETENT cookie markers */
525 #define NSCD_NEW_COOKIE 0
526 #define NSCD_LOCAL_COOKIE 1
528 /* nscd v2 header revision */
529 /* treated as 0xMMMMmmmm MMMM - Major Rev, mmmm - Minor Rev */
531 #define NSCD_HEADER_REV 0x00020000
534 * ptr/uint data type used to calculate shared nscd buffer struct sizes
535 * sizes/offsets are arbitrarily limited to 32 bits for 32/64 compatibility
536 * datatype is 64 bits for possible pointer storage and future use
539 typedef uint64_t nssuint_t;
542 * nscd v2 buffer layout overview
544 * The key interface to nscd moving forward is the doors interface
545 * between applications and nscd (NSCD_CALLCAT_APP), and nscd and
546 * it's children (NSCD_CALLCAT_N2N).
548 * Regardless of the interface used, the buffer layout is consistent.
549 * The General Layout is:
550 * [nss_pheader_t][IN key][OUT data results]{extend results}
552 * The header (nss_pheader_t) remains constant.
553 * Keys and key layouts vary between call numbers/requests
554 * NSCD_CALLCAT_APP use key layouts mimics/defines in nss_dbdefs.h
555 * NSCD_CALLCAT_NSN use layouts defined by nscd headers
556 * Data and data results vary between results
557 * NSCD_CALLCAT_APP return "file standard format" output buffers
558 * NSCD_CALLCAT_NSN return data defined by nscd headers
559 * extended results are optional and vary
564 * nss_pheader_t -- buffer header structure that contains switch data
565 * "packed" by the client into a buffer suitable for transport over
566 * nscd's door, and that can be unpacked into a native form within
567 * nscd's switch. Capable of packing and unpacking data ans results.
569 * NSCD_HEADER_REV: 0x00020000 16 x uint64 = (128 byte header)
572 typedef struct {
573 uint32_t nsc_callnumber; /* packed buffer request */
574 uint32_t nss_dbop; /* old nss dbop */
575 uint32_t p_ruid; /* real uid */
576 uint32_t p_euid; /* effective uid */
577 uint32_t p_version; /* 0xMMMMmmmm Major/minor */
578 uint32_t p_status; /* nss_status_t */
579 uint32_t p_errno; /* errno */
580 uint32_t p_herrno; /* h_errno */
581 nssuint_t libpriv; /* reserved (for lib/client) */
582 nssuint_t pbufsiz; /* buffer size */
583 nssuint_t dbd_off; /* IN: db desc off */
584 nssuint_t dbd_len; /* IN: db desc len */
585 nssuint_t key_off; /* IN: key off */
586 nssuint_t key_len; /* IN: key len */
587 nssuint_t data_off; /* OUT: data off */
588 nssuint_t data_len; /* OUT: data len */
589 nssuint_t ext_off; /* OUT: extended results off */
590 nssuint_t ext_len; /* OUT: extended results len */
591 nssuint_t nscdpriv; /* reserved (for nscd) */
592 nssuint_t reserved1; /* reserved (TBD) */
593 } nss_pheader_t;
596 * nss_pnetgr_t -- packed offset structure for holding keys used
597 * by innetgr (__multi_innetgr) key
598 * Key format is:
599 * nss_pnetgr_t
600 * (nssuint_t)[machine_argc] offsets to strings
601 * (nssuint_t)[user_argc] offsets to strings
602 * (nssuint_t)[domain_argc] offsets to strings
603 * (nssuint_t)[groups_argc] offsets to strings
604 * machine,user,domain,groups strings
607 typedef struct {
608 uint32_t machine_argc;
609 uint32_t user_argc;
610 uint32_t domain_argc;
611 uint32_t groups_argc;
612 nssuint_t machine_offv;
613 nssuint_t user_offv;
614 nssuint_t domain_offv;
615 nssuint_t groups_offv;
616 } nss_pnetgr_t;
619 /* status returned by the str2ent parsing routines */
620 #define NSS_STR_PARSE_SUCCESS 0
621 #define NSS_STR_PARSE_PARSE 1
622 #define NSS_STR_PARSE_ERANGE 2
624 #define NSS_XbyY_INIT(str, res, bufp, len, func) (\
625 (str)->buf.result = (res), \
626 (str)->buf.buffer = (bufp), \
627 (str)->buf.buflen = (len), \
628 (str)->stayopen = 0, \
629 (str)->str2ent = (func), \
630 (str)->key2str = NULL, \
631 (str)->returnval = 0, \
632 (str)->returnlen = 0, \
633 (str)->h_errno = 0, \
634 (str)->erange = 0)
636 #define NSS_XbyY_INIT_EXT(str, res, bufp, len, func, kfunc) (\
637 (str)->buf.result = (res), \
638 (str)->buf.buffer = (bufp), \
639 (str)->buf.buflen = (len), \
640 (str)->stayopen = 0, \
641 (str)->str2ent = (func), \
642 (str)->key2str = (kfunc), \
643 (str)->returnval = 0, \
644 (str)->returnlen = 0, \
645 (str)->h_errno = 0, \
646 (str)->erange = 0)
648 #define NSS_XbyY_FINI(str) _nss_XbyY_fini(str)
650 #define NSS_PACKED_CRED_CHECK(buf, ruid, euid) (\
651 ((nss_pheader_t *)(buf))->p_ruid == (ruid) && \
652 ((nss_pheader_t *)(buf))->p_euid == (euid))
654 extern void *_nss_XbyY_fini(nss_XbyY_args_t *);
655 extern char **_nss_netdb_aliases(const char *, int, char *, int);
656 extern nss_status_t nss_default_key2str(void *, size_t, nss_XbyY_args_t *,
657 const char *, int, size_t *);
658 extern nss_status_t nss_packed_arg_init(void *, size_t, nss_db_root_t *,
659 nss_db_initf_t *, int *,
660 nss_XbyY_args_t *);
661 extern nss_status_t nss_packed_context_init(void *, size_t, nss_db_root_t *,
662 nss_db_initf_t *, nss_getent_t **,
663 nss_XbyY_args_t *);
664 extern void nss_packed_set_status(void *, size_t, nss_status_t,
665 nss_XbyY_args_t *);
666 extern nss_status_t nss_packed_getkey(void *, size_t, char **, int *,
667 nss_XbyY_args_t *);
670 * nss_dbop_t values for searches with various keys; values for
671 * destructor/endent/setent/getent are defined in <nss_common.h>
675 * These are part of the "Over the wire" IE app->nscd getXbyY
676 * op for well known getXbyY's. Cannot use NSS_DBOP_X_Y directly
677 * because NSS_DBOP_next_iter is NOT an incrementing counter value
678 * it's a starting offset into an array value.
681 #define NSS_DBOP_X(x) ((x)<<16)
682 #define NSS_DBOP_XY(x, y) ((x)|(y))
684 #define NSS_DBOP_ALIASES NSS_DBOP_X(1)
685 #define NSS_DBOP_AUTOMOUNT NSS_DBOP_X(2)
686 #define NSS_DBOP_BOOTPARAMS NSS_DBOP_X(3)
687 #define NSS_DBOP_ETHERS NSS_DBOP_X(4)
688 #define NSS_DBOP_GROUP NSS_DBOP_X(5)
689 #define NSS_DBOP_HOSTS NSS_DBOP_X(6)
690 #define NSS_DBOP_IPNODES NSS_DBOP_X(7)
691 #define NSS_DBOP_NETGROUP NSS_DBOP_X(8)
692 #define NSS_DBOP_NETMASKS NSS_DBOP_X(9)
693 #define NSS_DBOP_NETWORKS NSS_DBOP_X(10)
694 #define NSS_DBOP_PASSWD NSS_DBOP_X(11)
695 #define NSS_DBOP_PRINTERS NSS_DBOP_X(12)
696 #define NSS_DBOP_PROJECT NSS_DBOP_X(13)
697 #define NSS_DBOP_PROTOCOLS NSS_DBOP_X(14)
698 #define NSS_DBOP_PUBLICKEY NSS_DBOP_X(15)
699 #define NSS_DBOP_RPC NSS_DBOP_X(16)
700 #define NSS_DBOP_SERVICES NSS_DBOP_X(17)
701 #define NSS_DBOP_AUDITUSER NSS_DBOP_X(18)
702 #define NSS_DBOP_AUTHATTR NSS_DBOP_X(19)
703 #define NSS_DBOP_EXECATTR NSS_DBOP_X(20)
704 #define NSS_DBOP_PROFATTR NSS_DBOP_X(21)
705 #define NSS_DBOP_USERATTR NSS_DBOP_X(22)
707 #define NSS_DBOP_GROUP_BYNAME (NSS_DBOP_next_iter)
708 #define NSS_DBOP_GROUP_BYGID (NSS_DBOP_GROUP_BYNAME + 1)
709 #define NSS_DBOP_GROUP_BYMEMBER (NSS_DBOP_GROUP_BYGID + 1)
711 #define NSS_DBOP_PASSWD_BYNAME (NSS_DBOP_next_iter)
712 #define NSS_DBOP_PASSWD_BYUID (NSS_DBOP_PASSWD_BYNAME + 1)
714 /* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */
715 /* (it also requires that both use key.name to pass the username). */
716 #define NSS_DBOP_SHADOW_BYNAME (NSS_DBOP_PASSWD_BYNAME)
718 #define NSS_DBOP_PROJECT_BYNAME (NSS_DBOP_next_iter)
719 #define NSS_DBOP_PROJECT_BYID (NSS_DBOP_PROJECT_BYNAME + 1)
721 #define NSS_DBOP_HOSTS_BYNAME (NSS_DBOP_next_iter)
722 #define NSS_DBOP_HOSTS_BYADDR (NSS_DBOP_HOSTS_BYNAME + 1)
724 #define NSS_DBOP_IPNODES_BYNAME (NSS_DBOP_next_iter)
725 #define NSS_DBOP_IPNODES_BYADDR (NSS_DBOP_IPNODES_BYNAME + 1)
728 * NSS_DBOP_NAME_2ADDR
729 * NSS_DBOP_ADDR_2NAME
730 * : are defines for ipv6 api's
733 #define NSS_DBOP_NAME_2ADDR (NSS_DBOP_next_ipv6_iter)
734 #define NSS_DBOP_ADDR_2NAME (NSS_DBOP_NAME_2ADDR + 1)
736 #define NSS_DBOP_RPC_BYNAME (NSS_DBOP_next_iter)
737 #define NSS_DBOP_RPC_BYNUMBER (NSS_DBOP_RPC_BYNAME + 1)
739 #define NSS_DBOP_NETWORKS_BYNAME (NSS_DBOP_next_iter)
740 #define NSS_DBOP_NETWORKS_BYADDR (NSS_DBOP_NETWORKS_BYNAME + 1)
742 #define NSS_DBOP_SERVICES_BYNAME (NSS_DBOP_next_iter)
743 #define NSS_DBOP_SERVICES_BYPORT (NSS_DBOP_SERVICES_BYNAME + 1)
745 #define NSS_DBOP_PROTOCOLS_BYNAME (NSS_DBOP_next_iter)
746 #define NSS_DBOP_PROTOCOLS_BYNUMBER (NSS_DBOP_PROTOCOLS_BYNAME + 1)
748 #define NSS_DBOP_ETHERS_HOSTTON (NSS_DBOP_next_noiter)
749 #define NSS_DBOP_ETHERS_NTOHOST (NSS_DBOP_ETHERS_HOSTTON + 1)
751 #define NSS_DBOP_BOOTPARAMS_BYNAME (NSS_DBOP_next_noiter)
752 #define NSS_DBOP_NETMASKS_BYNET (NSS_DBOP_next_noiter)
754 #define NSS_DBOP_PRINTERS_BYNAME (NSS_DBOP_next_iter)
757 * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
759 #define NSS_DBOP_NETGROUP_IN (NSS_DBOP_next_iter)
760 #define NSS_DBOP_NETGROUP_SET (NSS_DBOP_NETGROUP_IN + 1)
763 * The backend for getpublickey and getsecretkey (getkeys)
765 #define NSS_DBOP_KEYS_BYNAME (NSS_DBOP_next_iter)
768 * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
769 * any getXXXbyYYY operations, just the usual destr/end/set/get ops,
770 * so needs no definitions here.
773 #define NSS_DBOP_ATTRDB_BYNAME (NSS_DBOP_next_iter)
775 #define NSS_DBOP_AUDITUSER_BYNAME NSS_DBOP_ATTRDB_BYNAME
776 #define NSS_DBOP_AUTHATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
777 #define NSS_DBOP_EXECATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
778 #define NSS_DBOP_EXECATTR_BYID (NSS_DBOP_EXECATTR_BYNAME + 1)
779 #define NSS_DBOP_EXECATTR_BYNAMEID (NSS_DBOP_EXECATTR_BYID + 1)
780 #define NSS_DBOP_PROFATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
781 #define NSS_DBOP_USERATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
784 * Used all over in the switch code. The best home for it I can think of.
785 * Power-of-two alignments only.
787 #define ROUND_DOWN(n, align) (((uintptr_t)n) & ~((align) - 1l))
788 #define ROUND_UP(n, align) ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \
789 (align))
791 #ifdef __cplusplus
793 #endif
795 #endif /* _NSS_DBDEFS_H */