xref: /illumos-gate/usr/src/lib/libnisdb/nisdb_ldap.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 2001-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_NISDB_LDAP_H
28 #define	_NISDB_LDAP_H
29 
30 #include <sys/time.h>
31 #include <thread.h>
32 #include <synch.h>
33 #include <pthread.h>
34 #include <rpcsvc/nis.h>
35 
36 #include "ldap_parse.h"
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /* Types supporting rpc.nisd configuration attributes */
43 
44 /* nisplusLDAPinitialUpdate */
45 typedef enum {
46 	ini_none,
47 	from_ldap,
48 	from_ldap_update_only,
49 	to_ldap,
50 	to_ldap_update_only
51 } __nis_initial_update_t;
52 
53 /* nisplusLDAPretrieveError */
54 typedef enum {
55 	use_cached,
56 	ret_retry,
57 	try_again,
58 	ret_unavail,
59 	no_such_name,
60 	fail
61 } __nis_retrieve_error_t;
62 
63 /* nisplusLDAPstoreError */
64 typedef enum {
65 	sto_retry,
66 	system_error,
67 	sto_unavail,
68 	sto_fail
69 } __nis_store_error_t;
70 
71 /* nisplusLDAPstoreErrorDisp */
72 typedef enum {
73 	std_delete_entry,
74 	abandon
75 } __nis_store_error_disp_t;
76 
77 /* nisplusLDAPrefreshError */
78 typedef enum {
79 	continue_using,
80 	ref_retry,
81 	continue_using_retry,
82 	cache_expired,
83 	tryagain
84 } __nis_refresh_error_t;
85 
86 /* nisplusLDAPthreadCreationError */
87 typedef enum {
88 	pass_error,
89 	cre_retry
90 } __nis_thread_creation_error_t;
91 
92 /* nisplusLDAPdumpError */
93 typedef enum {
94 	de_retry,
95 	rollback,
96 	rollback_retry
97 } __nis_dump_error_t;
98 
99 /* nisplusLDAPresyncService */
100 typedef enum {
101 	from_copy,
102 	directory_locked,
103 	from_live
104 } __nis_resync_service_t;
105 
106 /* nisplusLDAPupdateBatching */
107 typedef enum {
108 	accumulate,
109 	bounded_accumulate,
110 	upd_none
111 } __nis_update_batching_t;
112 
113 /* nisplusLDAPexclusiveWaitMode */
114 typedef enum {
115 	block,
116 	ewm_tryagain
117 } __nis_exclusive_wait_mode_t;
118 
119 /* nisplusLDAPmatchFetch */
120 typedef enum {
121 	no_match_only,
122 	mat_always,
123 	mat_never
124 } __nis_match_fetch_t;
125 
126 /* Keep track of desired number of attempts and timeout */
127 typedef struct {
128 	int		attempts;
129 	time_t		timeout;
130 } __nisdb_retry_t;
131 
132 /* Table mapping (and related) information */
133 typedef struct {
134 	time_t			initTtlLo;	/* Initial lo TTL for table */
135 	time_t			initTtlHi;	/* Initial hi TTL for table */
136 	time_t			ttl;		/* TTL for table entries */
137 	time_t			*expire;	/* Expire times for entries */
138 	time_t			enumExpire;	/* Enumeration expiration */
139 	bool_t			fromLDAP;	/* Get data from LDAP ? */
140 	bool_t			toLDAP;		/* Write data to LDAP ? */
141 	bool_t			isMaster;	/* Are we master for this ? */
142 	__nis_retrieve_error_t	retrieveError;
143 	__nisdb_retry_t		retrieveErrorRetry;
144 	__nis_store_error_t	storeError;
145 	__nisdb_retry_t		storeErrorRetry;
146 	__nis_store_error_disp_t
147 				storeErrorDisp;
148 	__nis_refresh_error_t	refreshError;
149 	__nisdb_retry_t		refreshErrorRetry;
150 	__nis_match_fetch_t	matchFetch;
151 	__nis_table_mapping_t	*tm;
152 	zotypes			objType;
153 	zotypes			expireType;
154 	char			*objName;
155 	bool_t			isDeferredTable;
156 	mutex_t			enumLock;
157 	pthread_t		enumTid;
158 	int			enumStat;
159 	int			enumDeferred;
160 	uint_t			enumEntries;
161 	ulong_t			enumTime;	/* Microseconds */
162 } __nisdb_table_mapping_t;
163 
164 /*
165  * Configuration data used by the rpc.nisd proper, but not in libnisdb.
166  */
167 typedef struct {
168 	__nis_initial_update_t		initialUpdate;
169 	__nis_thread_creation_error_t	threadCreationError;
170 	__nisdb_retry_t			threadCreationErrorTimeout;
171 	__nis_dump_error_t		dumpError;
172 	__nisdb_retry_t			dumpErrorTimeout;
173 	__nis_resync_service_t		resyncService;
174 	__nis_update_batching_t		updateBatching;
175 	__nisdb_retry_t			updateBatchingTimeout;
176 	__nis_exclusive_wait_mode_t	exclusiveWaitMode;
177 	int				numberOfServiceThreads;
178 	int				emulate_yp;
179 	int				maxRPCRecordSize;
180 } __nis_config_t;
181 
182 extern __nisdb_table_mapping_t	ldapDBTableMapping;
183 extern __nis_config_t		ldapConfig;
184 
185 #ifdef	__cplusplus
186 }
187 #endif	/* __cplusplus */
188 
189 #endif	/* _NISDB_LDAP_H */
190