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