2004-11-10 10:23:32 +03:00
|
|
|
/* $NetBSD: nsswitch.h,v 1.16 2004/11/10 07:23:32 lukem Exp $ */
|
1999-01-15 15:21:16 +03:00
|
|
|
|
|
|
|
/*-
|
2004-09-29 06:47:32 +04:00
|
|
|
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
|
1999-01-15 15:21:16 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Luke Mewburn.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NSSWITCH_H
|
|
|
|
#define _NSSWITCH_H 1
|
|
|
|
|
1999-04-18 05:53:15 +04:00
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Don't use va_list in prototypes. va_list is typedef'd in two places
|
1999-04-18 05:53:15 +04:00
|
|
|
* (<machine/varargs.h> and <machine/stdarg.h>), so if we include one of
|
|
|
|
* them here we may collide with the utility's includes. It's unreasonable
|
|
|
|
* for utilities to have to include one of them to include nsswitch.h, so
|
|
|
|
* we get _BSD_VA_LIST_ from <machine/ansi.h> and use it.
|
|
|
|
*/
|
|
|
|
#include <machine/ansi.h>
|
1999-01-15 15:21:16 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2004-07-24 22:42:51 +04:00
|
|
|
#define NSS_MODULE_INTERFACE_VERSION 0
|
|
|
|
|
1999-01-15 15:21:16 +03:00
|
|
|
#ifndef _PATH_NS_CONF
|
|
|
|
#define _PATH_NS_CONF "/etc/nsswitch.conf"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define NS_CONTINUE 0
|
|
|
|
#define NS_RETURN 1
|
|
|
|
|
2004-10-04 08:02:27 +04:00
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Layout of:
|
2004-10-04 08:02:27 +04:00
|
|
|
* uint32_t ns_src.flags
|
|
|
|
*/
|
|
|
|
/* nsswitch.conf status codes and nsdispatch(3) return values */
|
1999-01-15 15:21:16 +03:00
|
|
|
#define NS_SUCCESS (1<<0) /* entry was found */
|
|
|
|
#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */
|
|
|
|
#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */
|
|
|
|
#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */
|
|
|
|
#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */
|
|
|
|
|
2004-10-04 08:02:27 +04:00
|
|
|
/* internal nsdispatch(3) flags; not settable in nsswitch.conf(5) */
|
|
|
|
#define NS_FORCEALL (1<<8) /* force all methods to be invoked; */
|
|
|
|
|
1999-01-15 15:21:16 +03:00
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Currently implemented sources.
|
1999-01-15 15:21:16 +03:00
|
|
|
*/
|
|
|
|
#define NSSRC_FILES "files" /* local files */
|
|
|
|
#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */
|
1999-01-16 05:58:28 +03:00
|
|
|
#define NSSRC_NIS "nis" /* YP/NIS */
|
|
|
|
#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */
|
1999-01-15 15:21:16 +03:00
|
|
|
|
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Currently implemented databases.
|
1999-01-15 15:21:16 +03:00
|
|
|
*/
|
|
|
|
#define NSDB_HOSTS "hosts"
|
|
|
|
#define NSDB_GROUP "group"
|
|
|
|
#define NSDB_GROUP_COMPAT "group_compat"
|
|
|
|
#define NSDB_NETGROUP "netgroup"
|
1999-01-16 05:58:28 +03:00
|
|
|
#define NSDB_NETWORKS "networks"
|
1999-01-15 15:21:16 +03:00
|
|
|
#define NSDB_PASSWD "passwd"
|
|
|
|
#define NSDB_PASSWD_COMPAT "passwd_compat"
|
|
|
|
#define NSDB_SHELLS "shells"
|
|
|
|
|
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Suggested databases to implement.
|
1999-01-15 15:21:16 +03:00
|
|
|
*/
|
|
|
|
#define NSDB_ALIASES "aliases"
|
|
|
|
#define NSDB_AUTH "auth"
|
|
|
|
#define NSDB_AUTOMOUNT "automount"
|
|
|
|
#define NSDB_BOOTPARAMS "bootparams"
|
|
|
|
#define NSDB_ETHERS "ethers"
|
|
|
|
#define NSDB_EXPORTS "exports"
|
|
|
|
#define NSDB_NETMASKS "netmasks"
|
|
|
|
#define NSDB_PHONES "phones"
|
|
|
|
#define NSDB_PRINTCAP "printcap"
|
|
|
|
#define NSDB_PROTOCOLS "protocols"
|
|
|
|
#define NSDB_REMOTE "remote"
|
|
|
|
#define NSDB_RPC "rpc"
|
|
|
|
#define NSDB_SENDMAILVARS "sendmailvars"
|
|
|
|
#define NSDB_SERVICES "services"
|
|
|
|
#define NSDB_TERMCAP "termcap"
|
|
|
|
#define NSDB_TTYS "ttys"
|
|
|
|
|
2004-07-24 22:42:51 +04:00
|
|
|
/*
|
|
|
|
* ns_dtab `callback' function signature.
|
|
|
|
*/
|
|
|
|
typedef int (*nss_method)(void *, void *, _BSD_VA_LIST_);
|
|
|
|
|
1999-01-15 15:21:16 +03:00
|
|
|
/*
|
|
|
|
* ns_dtab - `nsswitch dispatch table'
|
2004-11-10 10:23:32 +03:00
|
|
|
* Contains an entry for each source and the appropriate function to call.
|
1999-01-15 15:21:16 +03:00
|
|
|
*/
|
1999-01-19 10:55:14 +03:00
|
|
|
typedef struct {
|
1999-01-15 15:21:16 +03:00
|
|
|
const char *src;
|
2004-07-24 22:42:51 +04:00
|
|
|
nss_method callback;
|
1999-01-15 15:21:16 +03:00
|
|
|
void *cb_data;
|
|
|
|
} ns_dtab;
|
|
|
|
|
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Macros to help build an ns_dtab[]
|
1999-01-15 15:21:16 +03:00
|
|
|
*/
|
1999-01-19 10:55:14 +03:00
|
|
|
#define NS_FILES_CB(F,C) { NSSRC_FILES, F, C },
|
1999-01-26 04:04:07 +03:00
|
|
|
#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, C },
|
1999-01-15 15:21:16 +03:00
|
|
|
|
|
|
|
#ifdef HESIOD
|
1999-01-19 10:55:14 +03:00
|
|
|
# define NS_DNS_CB(F,C) { NSSRC_DNS, F, C },
|
1999-01-15 15:21:16 +03:00
|
|
|
#else
|
1999-01-19 10:55:14 +03:00
|
|
|
# define NS_DNS_CB(F,C)
|
1999-01-15 15:21:16 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef YP
|
1999-01-19 10:55:14 +03:00
|
|
|
# define NS_NIS_CB(F,C) { NSSRC_NIS, F, C },
|
1999-01-15 15:21:16 +03:00
|
|
|
#else
|
1999-01-19 10:55:14 +03:00
|
|
|
# define NS_NIS_CB(F,C)
|
1999-01-15 15:21:16 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ns_src - `nsswitch source'
|
2004-11-10 10:23:32 +03:00
|
|
|
* Used by the nsparser routines to store a mapping between a source
|
1999-01-15 15:21:16 +03:00
|
|
|
* and its dispatch control flags for a given database.
|
|
|
|
*/
|
1999-01-19 10:55:14 +03:00
|
|
|
typedef struct {
|
1999-01-15 15:21:16 +03:00
|
|
|
const char *name;
|
2004-10-04 08:02:27 +04:00
|
|
|
uint32_t flags;
|
1999-01-15 15:21:16 +03:00
|
|
|
} ns_src;
|
|
|
|
|
1999-01-19 10:55:14 +03:00
|
|
|
|
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Default sourcelists (if nsswitch.conf is missing, corrupt,
|
|
|
|
* or the requested database doesn't have an entry)
|
1999-01-19 10:55:14 +03:00
|
|
|
*/
|
|
|
|
extern const ns_src __nsdefaultsrc[];
|
2004-11-10 10:23:32 +03:00
|
|
|
extern const ns_src __nsdefaultcompat[];
|
|
|
|
extern const ns_src __nsdefaultcompat_forceall[];
|
|
|
|
extern const ns_src __nsdefaultfiles[];
|
|
|
|
extern const ns_src __nsdefaultfiles_forceall[];
|
|
|
|
extern const ns_src __nsdefaultnis[];
|
|
|
|
extern const ns_src __nsdefaultnis_forceall[];
|
1999-01-19 10:55:14 +03:00
|
|
|
|
|
|
|
|
2004-07-24 22:42:51 +04:00
|
|
|
/*
|
|
|
|
* ns_mtab - `nsswitch method table'
|
|
|
|
* An nsswitch module provides a mapping from (database name, method name)
|
|
|
|
* tuples to the nss_method and associated callback data. Effectively,
|
|
|
|
* ns_dtab, but used for dynamically loaded modules.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
const char *database;
|
|
|
|
const char *name;
|
|
|
|
nss_method method;
|
|
|
|
void *mdata;
|
|
|
|
} ns_mtab;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* nss_module_register_fn - module registration function
|
|
|
|
* called at module load
|
|
|
|
* nss_module_unregister_fn - module un-registration function
|
|
|
|
* called at module unload
|
|
|
|
*/
|
|
|
|
typedef void (*nss_module_unregister_fn)(ns_mtab *, u_int);
|
|
|
|
typedef ns_mtab *(*nss_module_register_fn)(const char *, u_int *,
|
|
|
|
nss_module_unregister_fn *);
|
|
|
|
|
1999-01-19 10:55:14 +03:00
|
|
|
#ifdef _NS_PRIVATE
|
|
|
|
|
|
|
|
/*
|
2004-11-10 10:23:32 +03:00
|
|
|
* Private data structures for back-end nsswitch implementation.
|
1999-01-19 10:55:14 +03:00
|
|
|
*/
|
|
|
|
|
1999-01-15 15:21:16 +03:00
|
|
|
/*
|
|
|
|
* ns_dbt - `nsswitch database thang'
|
2004-11-10 10:23:32 +03:00
|
|
|
* For each database in /etc/nsswitch.conf there is a ns_dbt, with its
|
1999-01-15 15:21:16 +03:00
|
|
|
* name and a list of ns_src's containing the source information.
|
|
|
|
*/
|
1999-01-19 10:55:14 +03:00
|
|
|
typedef struct {
|
1999-01-15 15:21:16 +03:00
|
|
|
const char *name; /* name of database */
|
|
|
|
ns_src *srclist; /* list of sources */
|
2004-07-24 22:42:51 +04:00
|
|
|
u_int srclistsize; /* size of srclist */
|
1999-01-15 15:21:16 +03:00
|
|
|
} ns_dbt;
|
|
|
|
|
2004-07-24 22:42:51 +04:00
|
|
|
/*
|
|
|
|
* ns_mod - `nsswitch module'
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
const char *name; /* module name */
|
|
|
|
void *handle; /* handle from dlopen() */
|
|
|
|
ns_mtab *mtab; /* method table */
|
|
|
|
u_int mtabsize; /* size of mtab */
|
|
|
|
/* called to unload module */
|
|
|
|
nss_module_unregister_fn unregister;
|
|
|
|
} ns_mod;
|
|
|
|
|
1999-01-15 15:21:16 +03:00
|
|
|
#endif /* _NS_PRIVATE */
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
2000-06-13 05:21:52 +04:00
|
|
|
int nsdispatch __P((void *, const ns_dtab [], const char *,
|
|
|
|
const char *, const ns_src [], ...));
|
1999-01-15 15:21:16 +03:00
|
|
|
|
|
|
|
#ifdef _NS_PRIVATE
|
2000-06-13 05:21:52 +04:00
|
|
|
int _nsdbtaddsrc __P((ns_dbt *, const ns_src *));
|
|
|
|
void _nsdbtdump __P((const ns_dbt *));
|
|
|
|
int _nsdbtput __P((const ns_dbt *));
|
|
|
|
void _nsyyerror __P((const char *));
|
|
|
|
int _nsyylex __P((void));
|
1999-01-15 15:21:16 +03:00
|
|
|
#endif /* _NS_PRIVATE */
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* !_NSSWITCH_H */
|