xref: /titanic_50/usr/src/head/nsswitch.h (revision 0e42dee69ed771bf604dd1789fca9d77b5bbe302)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1991-2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 /*
28  * nsswitch.h
29  *
30  * Low-level interface to the name-service switch.  The interface defined
31  * in <nss_common.h> should be used in preference to this.
32  *
33  * This is a Project Private interface.  It may change in future releases.
34  *	==== ^^^^^^^^^^^^^^^ ?
35  */
36 
37 #ifndef _NSSWITCH_H
38 #define	_NSSWITCH_H
39 
40 #pragma ident	"%Z%%M%	%I%	%E% SMI"
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 #define	__NSW_CONFIG_FILE	"/etc/nsswitch.conf"
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