]>
Commit | Line | Data |
---|---|---|
3bdf9aae | 1 | /* $NetBSD: nsswitch.h,v 1.20 2008/04/28 20:22:54 martin Exp $ */\r |
2 | \r | |
3 | /*-\r | |
4 | * Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.\r | |
5 | * All rights reserved.\r | |
6 | *\r | |
7 | * This code is derived from software contributed to The NetBSD Foundation\r | |
8 | * by Luke Mewburn.\r | |
9 | *\r | |
10 | * Redistribution and use in source and binary forms, with or without\r | |
11 | * modification, are permitted provided that the following conditions\r | |
12 | * are met:\r | |
13 | * 1. Redistributions of source code must retain the above copyright\r | |
14 | * notice, this list of conditions and the following disclaimer.\r | |
15 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
16 | * notice, this list of conditions and the following disclaimer in the\r | |
17 | * documentation and/or other materials provided with the distribution.\r | |
18 | *\r | |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\r | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\r | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r | |
29 | * POSSIBILITY OF SUCH DAMAGE.\r | |
30 | */\r | |
31 | \r | |
32 | #ifndef _NSSWITCH_H\r | |
33 | #define _NSSWITCH_H 1\r | |
34 | \r | |
35 | /*\r | |
36 | * Don't use va_list in prototypes. va_list is typedef'd in two places\r | |
37 | * (<machine/varargs.h> and <machine/stdarg.h>), so if we include one of\r | |
38 | * them here we may collide with the utility's includes. It's unreasonable\r | |
39 | * for utilities to have to include one of them to include nsswitch.h, so\r | |
40 | * we get _BSD_VA_LIST_ from <machine/ansi.h> and use it.\r | |
41 | */\r | |
42 | #include <machine/ansi.h>\r | |
43 | #include <sys/types.h>\r | |
44 | \r | |
45 | #define NSS_MODULE_INTERFACE_VERSION 0\r | |
46 | \r | |
47 | #ifndef _PATH_NS_CONF\r | |
48 | #define _PATH_NS_CONF "/etc/nsswitch.conf"\r | |
49 | #endif\r | |
50 | \r | |
51 | #define NS_CONTINUE 0\r | |
52 | #define NS_RETURN 1\r | |
53 | \r | |
54 | /*\r | |
55 | * Layout of:\r | |
56 | * uint32_t ns_src.flags\r | |
57 | */ \r | |
58 | /* nsswitch.conf status codes and nsdispatch(3) return values */\r | |
59 | #define NS_SUCCESS (1<<0) /* entry was found */\r | |
60 | #define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */\r | |
61 | #define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */\r | |
62 | #define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */\r | |
63 | #define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */\r | |
64 | \r | |
65 | /* internal nsdispatch(3) flags; not settable in nsswitch.conf(5) */\r | |
66 | #define NS_FORCEALL (1<<8) /* force all methods to be invoked; */\r | |
67 | \r | |
68 | /*\r | |
69 | * Currently implemented sources.\r | |
70 | */\r | |
71 | #define NSSRC_FILES "files" /* local files */\r | |
72 | #define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */\r | |
73 | #define NSSRC_NIS "nis" /* YP/NIS */\r | |
74 | #define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */\r | |
75 | \r | |
76 | /*\r | |
77 | * Currently implemented databases.\r | |
78 | */\r | |
79 | #define NSDB_HOSTS "hosts"\r | |
80 | #define NSDB_GROUP "group"\r | |
81 | #define NSDB_GROUP_COMPAT "group_compat"\r | |
82 | #define NSDB_NETGROUP "netgroup"\r | |
83 | #define NSDB_NETWORKS "networks"\r | |
84 | #define NSDB_PASSWD "passwd"\r | |
85 | #define NSDB_PASSWD_COMPAT "passwd_compat"\r | |
86 | #define NSDB_SHELLS "shells"\r | |
87 | \r | |
88 | /*\r | |
89 | * Suggested databases to implement.\r | |
90 | */\r | |
91 | #define NSDB_ALIASES "aliases"\r | |
92 | #define NSDB_AUTH "auth"\r | |
93 | #define NSDB_AUTOMOUNT "automount"\r | |
94 | #define NSDB_BOOTPARAMS "bootparams"\r | |
95 | #define NSDB_ETHERS "ethers"\r | |
96 | #define NSDB_EXPORTS "exports"\r | |
97 | #define NSDB_NETMASKS "netmasks"\r | |
98 | #define NSDB_PHONES "phones"\r | |
99 | #define NSDB_PRINTCAP "printcap"\r | |
100 | #define NSDB_PROTOCOLS "protocols"\r | |
101 | #define NSDB_REMOTE "remote"\r | |
102 | #define NSDB_RPC "rpc"\r | |
103 | #define NSDB_SENDMAILVARS "sendmailvars"\r | |
104 | #define NSDB_SERVICES "services"\r | |
105 | #define NSDB_TERMCAP "termcap"\r | |
106 | #define NSDB_TTYS "ttys"\r | |
107 | \r | |
108 | /*\r | |
109 | * ns_dtab `callback' function signature.\r | |
110 | */\r | |
111 | typedef int (*nss_method)(void *, void *, _BSD_VA_LIST_);\r | |
112 | \r | |
113 | /*\r | |
114 | * ns_dtab - `nsswitch dispatch table'\r | |
115 | * Contains an entry for each source and the appropriate function to call.\r | |
116 | */\r | |
117 | typedef struct {\r | |
118 | const char *src;\r | |
119 | nss_method callback;\r | |
120 | void *cb_data;\r | |
121 | } ns_dtab;\r | |
122 | \r | |
123 | /*\r | |
124 | * Macros to help build an ns_dtab[]\r | |
125 | */\r | |
126 | #define NS_FILES_CB(F,C) { NSSRC_FILES, F, __UNCONST(C) },\r | |
127 | #define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, __UNCONST(C) },\r | |
128 | \r | |
129 | #ifdef HESIOD\r | |
130 | # define NS_DNS_CB(F,C) { NSSRC_DNS, F, __UNCONST(C) },\r | |
131 | #else\r | |
132 | # define NS_DNS_CB(F,C)\r | |
133 | #endif\r | |
134 | \r | |
135 | #ifdef YP\r | |
136 | # define NS_NIS_CB(F,C) { NSSRC_NIS, F, __UNCONST(C) },\r | |
137 | #else\r | |
138 | # define NS_NIS_CB(F,C)\r | |
139 | #endif\r | |
140 | #define NS_NULL_CB { NULL, NULL, NULL },\r | |
141 | \r | |
142 | /*\r | |
143 | * ns_src - `nsswitch source'\r | |
144 | * Used by the nsparser routines to store a mapping between a source\r | |
145 | * and its dispatch control flags for a given database.\r | |
146 | */\r | |
147 | typedef struct {\r | |
148 | const char *name;\r | |
149 | uint32_t flags;\r | |
150 | } ns_src;\r | |
151 | \r | |
152 | \r | |
153 | /*\r | |
154 | * Default sourcelists (if nsswitch.conf is missing, corrupt,\r | |
155 | * or the requested database doesn't have an entry)\r | |
156 | */\r | |
157 | extern const ns_src __nsdefaultsrc[];\r | |
158 | extern const ns_src __nsdefaultcompat[];\r | |
159 | extern const ns_src __nsdefaultcompat_forceall[];\r | |
160 | extern const ns_src __nsdefaultfiles[];\r | |
161 | extern const ns_src __nsdefaultfiles_forceall[];\r | |
162 | extern const ns_src __nsdefaultnis[];\r | |
163 | extern const ns_src __nsdefaultnis_forceall[];\r | |
164 | \r | |
165 | \r | |
166 | /*\r | |
167 | * ns_mtab - `nsswitch method table'\r | |
168 | * An nsswitch module provides a mapping from (database name, method name)\r | |
169 | * tuples to the nss_method and associated callback data. Effectively,\r | |
170 | * ns_dtab, but used for dynamically loaded modules.\r | |
171 | */\r | |
172 | typedef struct {\r | |
173 | const char *database;\r | |
174 | const char *name;\r | |
175 | nss_method method;\r | |
176 | void *mdata;\r | |
177 | } ns_mtab;\r | |
178 | \r | |
179 | /*\r | |
180 | * nss_module_register_fn - module registration function\r | |
181 | * called at module load\r | |
182 | * nss_module_unregister_fn - module un-registration function\r | |
183 | * called at module unload\r | |
184 | */\r | |
185 | typedef void (*nss_module_unregister_fn)(ns_mtab *, u_int);\r | |
186 | typedef ns_mtab *(*nss_module_register_fn)(const char *, u_int *,\r | |
187 | nss_module_unregister_fn *);\r | |
188 | \r | |
189 | #ifdef _NS_PRIVATE\r | |
190 | \r | |
191 | /*\r | |
192 | * Private data structures for back-end nsswitch implementation.\r | |
193 | */\r | |
194 | \r | |
195 | /*\r | |
196 | * ns_dbt - `nsswitch database thang'\r | |
197 | * For each database in /etc/nsswitch.conf there is a ns_dbt, with its\r | |
198 | * name and a list of ns_src's containing the source information.\r | |
199 | */\r | |
200 | typedef struct {\r | |
201 | const char *name; /* name of database */\r | |
202 | ns_src *srclist; /* list of sources */\r | |
203 | u_int srclistsize; /* size of srclist */\r | |
204 | } ns_dbt;\r | |
205 | \r | |
206 | /*\r | |
207 | * ns_mod - `nsswitch module'\r | |
208 | */\r | |
209 | typedef struct {\r | |
210 | const char *name; /* module name */\r | |
211 | void *handle; /* handle from dlopen() */\r | |
212 | ns_mtab *mtab; /* method table */\r | |
213 | u_int mtabsize; /* size of mtab */\r | |
214 | /* called to unload module */\r | |
215 | nss_module_unregister_fn unregister;\r | |
216 | } ns_mod;\r | |
217 | \r | |
218 | #endif /* _NS_PRIVATE */\r | |
219 | \r | |
220 | \r | |
221 | #include <sys/cdefs.h>\r | |
222 | \r | |
223 | __BEGIN_DECLS\r | |
224 | int nsdispatch(void *, const ns_dtab [], const char *,\r | |
225 | const char *, const ns_src [], ...);\r | |
226 | \r | |
227 | #ifdef _NS_PRIVATE\r | |
228 | int _nsdbtaddsrc(ns_dbt *, const ns_src *);\r | |
229 | void _nsdbtdump(const ns_dbt *);\r | |
230 | int _nsdbtput(const ns_dbt *);\r | |
231 | void _nsyyerror(const char *);\r | |
232 | int _nsyylex(void);\r | |
233 | #endif /* _NS_PRIVATE */\r | |
234 | \r | |
235 | __END_DECLS\r | |
236 | \r | |
237 | #endif /* !_NSSWITCH_H */\r |