sl@0: /* $NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $ */ sl@0: /* $FreeBSD: src/include/nsswitch.h,v 1.3 2003/04/17 14:14:21 nectar Exp $ */ sl@0: sl@0: /*- sl@0: * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. sl@0: * All rights reserved. sl@0: * sl@0: * This code is derived from software contributed to The NetBSD Foundation sl@0: * by Luke Mewburn. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of The NetBSD Foundation nor the names of its sl@0: * contributors may be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS sl@0: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED sl@0: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS sl@0: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR sl@0: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF sl@0: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS sl@0: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN sl@0: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE sl@0: * POSSIBILITY OF SUCH DAMAGE. sl@0: * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: */ sl@0: sl@0: #ifndef _NSSWITCH_H sl@0: #define _NSSWITCH_H 1 sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #define NSS_MODULE_INTERFACE_VERSION 1 sl@0: sl@0: #ifndef _PATH_NS_CONF sl@0: #define _PATH_NS_CONF "/etc/nsswitch.conf" sl@0: #endif sl@0: sl@0: /* NSS source actions */ sl@0: #define NS_ACTION_CONTINUE 0 /* try the next source */ sl@0: #define NS_ACTION_RETURN 1 /* look no further */ sl@0: sl@0: #define NS_SUCCESS (1<<0) /* entry was found */ sl@0: #define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */ sl@0: #define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */ sl@0: #define NS_TRYAGAIN (1<<3) /* source busy, may respond to retry */ sl@0: #define NS_RETURN (1<<4) /* stop search, e.g. for ERANGE */ sl@0: #define NS_TERMINATE (NS_SUCCESS|NS_RETURN) /* flags that end search */ sl@0: #define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */ sl@0: sl@0: /* sl@0: * currently implemented sources sl@0: */ sl@0: #define NSSRC_FILES "files" /* local files */ sl@0: #define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */ sl@0: #define NSSRC_NIS "nis" /* YP/NIS */ sl@0: #define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */ sl@0: sl@0: /* sl@0: * currently implemented databases sl@0: */ sl@0: #define NSDB_HOSTS "hosts" sl@0: #define NSDB_GROUP "group" sl@0: #define NSDB_GROUP_COMPAT "group_compat" sl@0: #define NSDB_NETGROUP "netgroup" sl@0: #define NSDB_NETWORKS "networks" sl@0: #define NSDB_PASSWD "passwd" sl@0: #define NSDB_PASSWD_COMPAT "passwd_compat" sl@0: #define NSDB_SHELLS "shells" sl@0: sl@0: /* sl@0: * suggested databases to implement sl@0: */ sl@0: #define NSDB_ALIASES "aliases" sl@0: #define NSDB_AUTH "auth" sl@0: #define NSDB_AUTOMOUNT "automount" sl@0: #define NSDB_BOOTPARAMS "bootparams" sl@0: #define NSDB_ETHERS "ethers" sl@0: #define NSDB_EXPORTS "exports" sl@0: #define NSDB_NETMASKS "netmasks" sl@0: #define NSDB_PHONES "phones" sl@0: #define NSDB_PRINTCAP "printcap" sl@0: #define NSDB_PROTOCOLS "protocols" sl@0: #define NSDB_REMOTE "remote" sl@0: #define NSDB_RPC "rpc" sl@0: #define NSDB_SENDMAILVARS "sendmailvars" sl@0: #define NSDB_SERVICES "services" sl@0: #define NSDB_TERMCAP "termcap" sl@0: #define NSDB_TTYS "ttys" sl@0: sl@0: /* sl@0: * ns_dtab `method' function signature. sl@0: */ sl@0: typedef int (*nss_method)(void *_retval, void *_mdata, va_list _ap); sl@0: sl@0: /* sl@0: * Macro for generating method prototypes. sl@0: */ sl@0: #define NSS_METHOD_PROTOTYPE(method) \ sl@0: int method(void *, void *, va_list) sl@0: sl@0: /* sl@0: * ns_dtab - `nsswitch dispatch table' sl@0: * Contains an entry for each source and the appropriate function to sl@0: * call. ns_dtabs are used in the nsdispatch() API in order to allow sl@0: * the application to override built-in actions. sl@0: */ sl@0: typedef struct _ns_dtab { sl@0: const char *src; /* Source this entry implements */ sl@0: nss_method method; /* Method to be called */ sl@0: void *mdata; /* Data passed to method */ sl@0: } ns_dtab; sl@0: sl@0: /* sl@0: * macros to help build an ns_dtab[] sl@0: */ sl@0: #define NS_FILES_CB(F,C) { NSSRC_FILES, F, C }, sl@0: #define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, C }, sl@0: sl@0: #ifdef HESIOD sl@0: # define NS_DNS_CB(F,C) { NSSRC_DNS, F, C }, sl@0: #else sl@0: # define NS_DNS_CB(F,C) sl@0: #endif sl@0: sl@0: #ifdef YP sl@0: # define NS_NIS_CB(F,C) { NSSRC_NIS, F, C }, sl@0: #else sl@0: # define NS_NIS_CB(F,C) sl@0: #endif sl@0: sl@0: /* sl@0: * ns_src - `nsswitch source' sl@0: * used by the nsparser routines to store a mapping between a source sl@0: * and its dispatch control flags for a given database. sl@0: */ sl@0: typedef struct _ns_src { sl@0: const char *name; sl@0: u_int32_t flags; sl@0: } ns_src; sl@0: sl@0: sl@0: /* sl@0: * default sourcelist (if nsswitch.conf is missing, corrupt, sl@0: * or the requested database doesn't have an entry. sl@0: */ sl@0: extern const ns_src __nsdefaultsrc[]; sl@0: sl@0: /* sl@0: * ns_mtab - NSS method table sl@0: * An NSS module provides a mapping from (database name, method name) sl@0: * tuples to the nss_method and associated data. sl@0: */ sl@0: typedef struct _ns_mtab { sl@0: const char *database; sl@0: const char *name; sl@0: nss_method method; sl@0: void *mdata; sl@0: } ns_mtab; sl@0: sl@0: /* sl@0: * NSS module de-registration, called at module unload. sl@0: */ sl@0: typedef void (*nss_module_unregister_fn)(ns_mtab *, unsigned int); sl@0: sl@0: /* sl@0: * NSS module registration, called at module load. sl@0: */ sl@0: typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *, sl@0: nss_module_unregister_fn *); sl@0: sl@0: /* sl@0: * Many NSS interfaces follow the getXXnam, getXXid, getXXent pattern. sl@0: * Developers are encouraged to use nss_lookup_type where approriate. sl@0: */ sl@0: enum nss_lookup_type { sl@0: nss_lt_name = 1, sl@0: nss_lt_id = 2, sl@0: nss_lt_all = 3 sl@0: }; sl@0: sl@0: #ifdef _NS_PRIVATE sl@0: sl@0: /* sl@0: * private data structures for back-end nsswitch implementation sl@0: */ sl@0: sl@0: /* sl@0: * ns_dbt - `nsswitch database thang' sl@0: * for each database in /etc/nsswitch.conf there is a ns_dbt, with its sl@0: * name and a list of ns_src's containing the source information. sl@0: */ sl@0: typedef struct _ns_dbt { sl@0: const char *name; /* name of database */ sl@0: ns_src *srclist; /* list of sources */ sl@0: int srclistsize; /* size of srclist */ sl@0: } ns_dbt; sl@0: sl@0: /* sl@0: * ns_mod - NSS module sl@0: */ sl@0: typedef struct _ns_mod { sl@0: char *name; /* module name */ sl@0: void *handle; /* handle from dlopen */ sl@0: ns_mtab *mtab; /* method table */ sl@0: unsigned int mtabsize; /* count of entries in method table */ sl@0: nss_module_unregister_fn unregister; /* called to unload module */ sl@0: } ns_mod; sl@0: sl@0: #endif /* _NS_PRIVATE */ sl@0: sl@0: #endif /* !_NSSWITCH_H */