xref: /titanic_53/usr/src/head/nsswitch.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1991-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  * nsswitch.h
29*7c478bd9Sstevel@tonic-gate  *
30*7c478bd9Sstevel@tonic-gate  * Low-level interface to the name-service switch.  The interface defined
31*7c478bd9Sstevel@tonic-gate  * in <nss_common.h> should be used in preference to this.
32*7c478bd9Sstevel@tonic-gate  *
33*7c478bd9Sstevel@tonic-gate  * This is a Project Private interface.  It may change in future releases.
34*7c478bd9Sstevel@tonic-gate  *	==== ^^^^^^^^^^^^^^^ ?
35*7c478bd9Sstevel@tonic-gate  */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifndef _NSSWITCH_H
38*7c478bd9Sstevel@tonic-gate #define	_NSSWITCH_H
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
43*7c478bd9Sstevel@tonic-gate extern "C" {
44*7c478bd9Sstevel@tonic-gate #endif
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #define	__NSW_CONFIG_FILE	"/etc/nsswitch.conf"
47*7c478bd9Sstevel@tonic-gate #define	__NSW_DEFAULT_FILE	"/etc/default/nss"
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	__NSW_HOSTS_DB		"hosts"
50*7c478bd9Sstevel@tonic-gate #define	__NSW_PASSWD_DB		"passwd"
51*7c478bd9Sstevel@tonic-gate #define	__NSW_GROUP_DB		"group"
52*7c478bd9Sstevel@tonic-gate #define	__NSW_NETGROUP_DB	"netgroup"
53*7c478bd9Sstevel@tonic-gate #define	__NSW_NETWORKS_DB	"networks"
54*7c478bd9Sstevel@tonic-gate #define	__NSW_PROTOCOLS_DB	"protocols"
55*7c478bd9Sstevel@tonic-gate #define	__NSW_RPC_DB		"rpc"
56*7c478bd9Sstevel@tonic-gate #define	__NSW_SERVICES_DB	"services"
57*7c478bd9Sstevel@tonic-gate #define	__NSW_ETHERS_DB		"ethers"
58*7c478bd9Sstevel@tonic-gate #define	__NSW_BOOTPARAMS_DB	"bootparams"
59*7c478bd9Sstevel@tonic-gate #define	__NSW_NETMASKS_DB	"netmasks"
60*7c478bd9Sstevel@tonic-gate #define	__NSW_BROADCASTADDRS_DB	"broadcastaddrs"
61*7c478bd9Sstevel@tonic-gate #define	__NSW_MAIL_ALIASES_DB	"aliases"
62*7c478bd9Sstevel@tonic-gate #define	__NSW_AUDITUSER_DB	"audit_user"
63*7c478bd9Sstevel@tonic-gate #define	__NSW_AUTHATTR_DB	"auth_attr"
64*7c478bd9Sstevel@tonic-gate #define	__NSW_EXECATTR_DB	"exec_attr"
65*7c478bd9Sstevel@tonic-gate #define	__NSW_PROFATTR_DB	"prof_attr"
66*7c478bd9Sstevel@tonic-gate #define	__NSW_USERATTR_DB	"user_attr"
67*7c478bd9Sstevel@tonic-gate #define	__NSW_PROJECT_DB	"project"
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #define	__NSW_STD_ERRS	4	/* number of reserved errors that follow */
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #define	__NSW_SUCCESS	0	/* found the required data */
72*7c478bd9Sstevel@tonic-gate #define	__NSW_NOTFOUND	1	/* the naming service returned lookup failure */
73*7c478bd9Sstevel@tonic-gate #define	__NSW_UNAVAIL	2	/* could not call the naming service */
74*7c478bd9Sstevel@tonic-gate #define	__NSW_TRYAGAIN	3	/* bind error to suggest a retry */
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate typedef unsigned char action_t;
77*7c478bd9Sstevel@tonic-gate #define	__NSW_CONTINUE	0	/* the action is to continue to next service */
78*7c478bd9Sstevel@tonic-gate #define	__NSW_RETURN	1	/* the action is to return to the user */
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_RETURN	"return"
81*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_CONTINUE	"continue"
82*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_SUCCESS	"success"
83*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_NOTFOUND	"notfound"
84*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_UNAVAIL	"unavail"
85*7c478bd9Sstevel@tonic-gate #define	__NSW_STR_TRYAGAIN	"tryagain"
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /* prefix for all switch shared objects */
88*7c478bd9Sstevel@tonic-gate #define	__NSW_LIB	"nsw"
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate enum __nsw_parse_err {
91*7c478bd9Sstevel@tonic-gate 	__NSW_CONF_PARSE_SUCCESS = 0,	/* parser found the required policy */
92*7c478bd9Sstevel@tonic-gate 	__NSW_CONF_PARSE_NOFILE = 1,	/* the policy files does not exist */
93*7c478bd9Sstevel@tonic-gate 	__NSW_CONF_PARSE_NOPOLICY = 2,	/* the required policy is not set */
94*7c478bd9Sstevel@tonic-gate 					/* in the file */
95*7c478bd9Sstevel@tonic-gate 	__NSW_CONF_PARSE_SYSERR = 3	/* system error in the parser */
96*7c478bd9Sstevel@tonic-gate };
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate struct __nsw_long_err {
100*7c478bd9Sstevel@tonic-gate 	int nsw_errno;
101*7c478bd9Sstevel@tonic-gate 	action_t action;
102*7c478bd9Sstevel@tonic-gate 	struct __nsw_long_err *next;
103*7c478bd9Sstevel@tonic-gate };
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate struct __nsw_lookup {
106*7c478bd9Sstevel@tonic-gate 	char *service_name;
107*7c478bd9Sstevel@tonic-gate 	action_t actions[__NSW_STD_ERRS];
108*7c478bd9Sstevel@tonic-gate 	struct __nsw_long_err *long_errs;
109*7c478bd9Sstevel@tonic-gate 	struct __nsw_lookup *next;
110*7c478bd9Sstevel@tonic-gate };
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate struct __nsw_switchconfig {
113*7c478bd9Sstevel@tonic-gate 	int vers;
114*7c478bd9Sstevel@tonic-gate 	char *dbase;
115*7c478bd9Sstevel@tonic-gate 	int num_lookups;
116*7c478bd9Sstevel@tonic-gate 	struct __nsw_lookup *lookups;
117*7c478bd9Sstevel@tonic-gate };
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate #define	__NSW_ACTION(lkp, err) 	\
120*7c478bd9Sstevel@tonic-gate 	((lkp)->next == NULL ? \
121*7c478bd9Sstevel@tonic-gate 		__NSW_RETURN \
122*7c478bd9Sstevel@tonic-gate 	: \
123*7c478bd9Sstevel@tonic-gate 		((err) >= 0 && (err) < __NSW_STD_ERRS ? \
124*7c478bd9Sstevel@tonic-gate 			(lkp)->actions[err] \
125*7c478bd9Sstevel@tonic-gate 		: \
126*7c478bd9Sstevel@tonic-gate 			__nsw_extended_action(lkp, err)))
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate struct __nsw_switchconfig *__nsw_getconfig
131*7c478bd9Sstevel@tonic-gate 	(const char *, enum __nsw_parse_err *);
132*7c478bd9Sstevel@tonic-gate int __nsw_freeconfig(struct __nsw_switchconfig *);
133*7c478bd9Sstevel@tonic-gate action_t __nsw_extended_action(struct __nsw_lookup *, int);
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate #else
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate struct __nsw_switchconfig *__nsw_getconfig();
138*7c478bd9Sstevel@tonic-gate int __nsw_freeconfig();
139*7c478bd9Sstevel@tonic-gate action_t __nsw_extended_action();
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
144*7c478bd9Sstevel@tonic-gate }
145*7c478bd9Sstevel@tonic-gate #endif
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate #endif /* _NSSWITCH_H */
148