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