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