os/ossrv/genericopenlibs/openenvcore/include/nsswitch.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*	$NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $	*/
sl@0
     2
/*	$FreeBSD: src/include/nsswitch.h,v 1.3 2003/04/17 14:14:21 nectar Exp $ */
sl@0
     3
sl@0
     4
/*-
sl@0
     5
 * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
sl@0
     6
 * All rights reserved.
sl@0
     7
 *
sl@0
     8
 * This code is derived from software contributed to The NetBSD Foundation
sl@0
     9
 * by Luke Mewburn.
sl@0
    10
 *
sl@0
    11
 * Redistribution and use in source and binary forms, with or without
sl@0
    12
 * modification, are permitted provided that the following conditions
sl@0
    13
 * are met:
sl@0
    14
 * 1. Redistributions of source code must retain the above copyright
sl@0
    15
 *    notice, this list of conditions and the following disclaimer.
sl@0
    16
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    17
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    18
 *    documentation and/or other materials provided with the distribution.
sl@0
    19
 * 4. Neither the name of The NetBSD Foundation nor the names of its
sl@0
    20
 *    contributors may be used to endorse or promote products derived
sl@0
    21
 *    from this software without specific prior written permission.
sl@0
    22
 *
sl@0
    23
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
sl@0
    24
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
sl@0
    25
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
sl@0
    26
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
sl@0
    27
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
sl@0
    28
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
sl@0
    29
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sl@0
    30
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sl@0
    31
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
sl@0
    32
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sl@0
    33
 * POSSIBILITY OF SUCH DAMAGE.
sl@0
    34
 * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0
    35
 */
sl@0
    36
sl@0
    37
#ifndef _NSSWITCH_H
sl@0
    38
#define _NSSWITCH_H	1
sl@0
    39
sl@0
    40
#include <sys/types.h>
sl@0
    41
#include <stdarg.h>
sl@0
    42
sl@0
    43
#define NSS_MODULE_INTERFACE_VERSION 1
sl@0
    44
sl@0
    45
#ifndef _PATH_NS_CONF
sl@0
    46
#define _PATH_NS_CONF	"/etc/nsswitch.conf"
sl@0
    47
#endif
sl@0
    48
sl@0
    49
/* NSS source actions */
sl@0
    50
#define	NS_ACTION_CONTINUE	0	/* try the next source */
sl@0
    51
#define	NS_ACTION_RETURN	1	/* look no further */
sl@0
    52
sl@0
    53
#define	NS_SUCCESS	(1<<0)		/* entry was found */
sl@0
    54
#define	NS_UNAVAIL	(1<<1)		/* source not responding, or corrupt */
sl@0
    55
#define	NS_NOTFOUND	(1<<2)		/* source responded 'no such entry' */
sl@0
    56
#define	NS_TRYAGAIN	(1<<3)		/* source busy, may respond to retry */
sl@0
    57
#define NS_RETURN	(1<<4)		/* stop search, e.g. for ERANGE */
sl@0
    58
#define NS_TERMINATE	(NS_SUCCESS|NS_RETURN) /* flags that end search */
sl@0
    59
#define	NS_STATUSMASK	0x000000ff	/* bitmask to get the status flags */
sl@0
    60
sl@0
    61
/*
sl@0
    62
 * currently implemented sources
sl@0
    63
 */
sl@0
    64
#define NSSRC_FILES	"files"		/* local files */
sl@0
    65
#define	NSSRC_DNS	"dns"		/* DNS; IN for hosts, HS for others */
sl@0
    66
#define	NSSRC_NIS	"nis"		/* YP/NIS */
sl@0
    67
#define	NSSRC_COMPAT	"compat"	/* passwd,group in YP compat mode */
sl@0
    68
sl@0
    69
/*
sl@0
    70
 * currently implemented databases
sl@0
    71
 */
sl@0
    72
#define NSDB_HOSTS		"hosts"
sl@0
    73
#define NSDB_GROUP		"group"
sl@0
    74
#define NSDB_GROUP_COMPAT	"group_compat"
sl@0
    75
#define NSDB_NETGROUP		"netgroup"
sl@0
    76
#define NSDB_NETWORKS		"networks"
sl@0
    77
#define NSDB_PASSWD		"passwd"
sl@0
    78
#define NSDB_PASSWD_COMPAT	"passwd_compat"
sl@0
    79
#define NSDB_SHELLS		"shells"
sl@0
    80
sl@0
    81
/*
sl@0
    82
 * suggested databases to implement
sl@0
    83
 */
sl@0
    84
#define NSDB_ALIASES		"aliases"
sl@0
    85
#define NSDB_AUTH		"auth"
sl@0
    86
#define NSDB_AUTOMOUNT		"automount"
sl@0
    87
#define NSDB_BOOTPARAMS		"bootparams"
sl@0
    88
#define NSDB_ETHERS		"ethers"
sl@0
    89
#define NSDB_EXPORTS		"exports"
sl@0
    90
#define NSDB_NETMASKS		"netmasks"
sl@0
    91
#define NSDB_PHONES		"phones"
sl@0
    92
#define NSDB_PRINTCAP		"printcap"
sl@0
    93
#define NSDB_PROTOCOLS		"protocols"
sl@0
    94
#define NSDB_REMOTE		"remote"
sl@0
    95
#define NSDB_RPC		"rpc"
sl@0
    96
#define NSDB_SENDMAILVARS	"sendmailvars"
sl@0
    97
#define NSDB_SERVICES		"services"
sl@0
    98
#define NSDB_TERMCAP		"termcap"
sl@0
    99
#define NSDB_TTYS		"ttys"
sl@0
   100
sl@0
   101
/*
sl@0
   102
 * ns_dtab `method' function signature.
sl@0
   103
 */ 
sl@0
   104
typedef int (*nss_method)(void *_retval, void *_mdata, va_list _ap);
sl@0
   105
sl@0
   106
/*
sl@0
   107
 * Macro for generating method prototypes.
sl@0
   108
 */
sl@0
   109
#define NSS_METHOD_PROTOTYPE(method) \
sl@0
   110
	int method(void *, void *, va_list)
sl@0
   111
sl@0
   112
/*
sl@0
   113
 * ns_dtab - `nsswitch dispatch table'
sl@0
   114
 * Contains an entry for each source and the appropriate function to
sl@0
   115
 * call.  ns_dtabs are used in the nsdispatch() API in order to allow
sl@0
   116
 * the application to override built-in actions.
sl@0
   117
 */
sl@0
   118
typedef struct _ns_dtab {
sl@0
   119
	const char	 *src;		/* Source this entry implements */
sl@0
   120
	nss_method	  method;	/* Method to be called */
sl@0
   121
	void		 *mdata;	/* Data passed to method */
sl@0
   122
} ns_dtab;
sl@0
   123
sl@0
   124
/*
sl@0
   125
 * macros to help build an ns_dtab[]
sl@0
   126
 */
sl@0
   127
#define NS_FILES_CB(F,C)	{ NSSRC_FILES,	F,	C },
sl@0
   128
#define NS_COMPAT_CB(F,C)	{ NSSRC_COMPAT,	F,	C },
sl@0
   129
 
sl@0
   130
#ifdef HESIOD
sl@0
   131
#   define NS_DNS_CB(F,C)	{ NSSRC_DNS,	F,	C },
sl@0
   132
#else
sl@0
   133
#   define NS_DNS_CB(F,C)
sl@0
   134
#endif
sl@0
   135
sl@0
   136
#ifdef YP
sl@0
   137
#   define NS_NIS_CB(F,C)	{ NSSRC_NIS,	F,	C },
sl@0
   138
#else
sl@0
   139
#   define NS_NIS_CB(F,C)
sl@0
   140
#endif
sl@0
   141
sl@0
   142
/*
sl@0
   143
 * ns_src - `nsswitch source'
sl@0
   144
 * used by the nsparser routines to store a mapping between a source
sl@0
   145
 * and its dispatch control flags for a given database.
sl@0
   146
 */
sl@0
   147
typedef struct _ns_src {
sl@0
   148
	const char	*name;
sl@0
   149
	u_int32_t	 flags;
sl@0
   150
} ns_src;
sl@0
   151
sl@0
   152
sl@0
   153
/*
sl@0
   154
 * default sourcelist (if nsswitch.conf is missing, corrupt,
sl@0
   155
 * or the requested database doesn't have an entry.
sl@0
   156
 */
sl@0
   157
extern const ns_src __nsdefaultsrc[];
sl@0
   158
sl@0
   159
/*
sl@0
   160
 * ns_mtab - NSS method table
sl@0
   161
 * An NSS module provides a mapping from (database name, method name)
sl@0
   162
 * tuples to the nss_method and associated data.
sl@0
   163
 */
sl@0
   164
typedef struct _ns_mtab {
sl@0
   165
	const char	*database;
sl@0
   166
	const char	*name;
sl@0
   167
	nss_method	 method;
sl@0
   168
	void		*mdata;
sl@0
   169
} ns_mtab;
sl@0
   170
sl@0
   171
/*
sl@0
   172
 * NSS module de-registration, called at module unload.
sl@0
   173
 */
sl@0
   174
typedef void	 (*nss_module_unregister_fn)(ns_mtab *, unsigned int);
sl@0
   175
sl@0
   176
/*
sl@0
   177
 * NSS module registration, called at module load.
sl@0
   178
 */
sl@0
   179
typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *,
sl@0
   180
		       nss_module_unregister_fn *);
sl@0
   181
sl@0
   182
/* 
sl@0
   183
 * Many NSS interfaces follow the getXXnam, getXXid, getXXent pattern.
sl@0
   184
 * Developers are encouraged to use nss_lookup_type where approriate.
sl@0
   185
 */
sl@0
   186
enum nss_lookup_type {
sl@0
   187
	nss_lt_name = 1,
sl@0
   188
	nss_lt_id   = 2,
sl@0
   189
	nss_lt_all  = 3
sl@0
   190
};
sl@0
   191
sl@0
   192
#ifdef _NS_PRIVATE
sl@0
   193
sl@0
   194
/*
sl@0
   195
 * private data structures for back-end nsswitch implementation
sl@0
   196
 */
sl@0
   197
sl@0
   198
/*
sl@0
   199
 * ns_dbt - `nsswitch database thang'
sl@0
   200
 * for each database in /etc/nsswitch.conf there is a ns_dbt, with its
sl@0
   201
 * name and a list of ns_src's containing the source information.
sl@0
   202
 */
sl@0
   203
typedef struct _ns_dbt {
sl@0
   204
	const char	*name;		/* name of database */
sl@0
   205
	ns_src		*srclist;	/* list of sources */
sl@0
   206
	int		 srclistsize;	/* size of srclist */
sl@0
   207
} ns_dbt;
sl@0
   208
sl@0
   209
/*
sl@0
   210
 * ns_mod - NSS module
sl@0
   211
 */
sl@0
   212
typedef struct _ns_mod {
sl@0
   213
	char		*name;		/* module name */
sl@0
   214
	void		*handle;	/* handle from dlopen */
sl@0
   215
	ns_mtab		*mtab;		/* method table */
sl@0
   216
	unsigned int	 mtabsize;	/* count of entries in method table */
sl@0
   217
	nss_module_unregister_fn unregister; /* called to unload module */
sl@0
   218
} ns_mod;
sl@0
   219
sl@0
   220
#endif /* _NS_PRIVATE */
sl@0
   221
sl@0
   222
#endif /* !_NSSWITCH_H */