1 /* slap.h - stand alone ldap server include file */
12 #include <sys/types.h>
13 #include <ac/syslog.h>
22 #define ldap_debug slap_debug
27 #include "../../libraries/liblber/lber-int.h"
31 #include "lthread_rdwr.h"
34 #undef f_next /* name conflict between sys/file.h on SCO and struct filter */
44 #define MAXREMATCHES 10
48 extern int slap_debug;
54 * represents an attribute value assertion (i.e., attr=value)
58 struct berval ava_value;
62 * represents a search filter
64 typedef struct filter {
65 unsigned long f_choice; /* values taken from ldap.h */
71 /* equality, lessorequal, greaterorequal, approx */
75 struct filter *f_un_complex;
80 char *f_un_sub_initial;
85 #define f_type f_un.f_un_type
86 #define f_ava f_un.f_un_ava
87 #define f_avtype f_un.f_un_ava.ava_type
88 #define f_avvalue f_un.f_un_ava.ava_value
89 #define f_and f_un.f_un_complex
90 #define f_or f_un.f_un_complex
91 #define f_not f_un.f_un_complex
92 #define f_list f_un.f_un_complex
93 #define f_sub f_un.f_un_sub
94 #define f_sub_type f_un.f_un_sub.f_un_sub_type
95 #define f_sub_initial f_un.f_un_sub.f_un_sub_initial
96 #define f_sub_any f_un.f_un_sub.f_un_sub_any
97 #define f_sub_final f_un.f_un_sub.f_un_sub_final
99 struct filter *f_next;
103 * represents an attribute (type + values + syntax)
105 typedef struct attr {
107 struct berval **a_vals;
113 * the attr_syntax() routine returns one of these values
114 * telling what kind of syntax an attribute supports.
116 #define SYNTAX_CIS 0x01 /* case insensitive string */
117 #define SYNTAX_CES 0x02 /* case sensitive string */
118 #define SYNTAX_BIN 0x04 /* binary data */
119 #define SYNTAX_TEL 0x08 /* telephone number string */
120 #define SYNTAX_DN 0x10 /* dn string */
123 * the id used in the indexes to refer to an entry
125 typedef unsigned long ID;
126 #define NOID ((unsigned long)-1)
129 * represents an entry in core
131 typedef struct entry {
132 char *e_dn; /* DN of this entry */
133 Attribute *e_attrs; /* list of attributes + values */
135 ID e_id; /* id of this entry - this should */
136 /* really be private to back-ldbm */
137 char e_state; /* for the cache */
139 pthread_rdwr_t e_rdwr; /* reader/writer lock */
141 #define ENTRY_STATE_DELETED 1
142 #define ENTRY_STATE_CREATING 2
143 int e_refcnt; /* # threads ref'ing this entry */
144 struct entry *e_lrunext; /* for cache lru list */
145 struct entry *e_lruprev;
149 * represents an access control list
160 #ifdef SLAPD_ACLGROUPS
162 char *a_objectclassvalue;
163 char *a_groupattrname;
166 #define ACL_NONE 0x01
167 #define ACL_COMPARE 0x02
168 #define ACL_SEARCH 0x04
169 #define ACL_READ 0x08
170 #define ACL_WRITE 0x10
171 #define ACL_SELF 0x40
172 struct access *a_next;
177 /* "to" part: the entries this acl applies to */
183 /* "by" part: list of who has what access to the entries */
184 struct access *acl_access;
186 struct acl *acl_next;
192 typedef struct ldapmodlist {
193 struct ldapmod ml_mod;
194 struct ldapmodlist *ml_next;
195 #define ml_op ml_mod.mod_op
196 #define ml_type ml_mod.mod_type
197 #define ml_values ml_mod.mod_values
198 #define ml_bvalues ml_mod.mod_bvalues
202 * represents schema information for a database
209 struct objclass *oc_next;
213 * represents a "database"
216 typedef struct backend Backend;
218 char **be_suffix; /* the DN suffixes of data in this backend */
219 char **be_suffixAlias; /* the DN suffix aliases of data in this backend */
220 char *be_rootdn; /* the magic "root" dn for this db */
221 char *be_rootpw; /* the magic "root" password for this db */
222 int be_readonly; /* 1 => db is in "read only" mode */
223 int be_maxDerefDepth; /* limit for depth of an alias deref */
224 int be_sizelimit; /* size limit for this backend */
225 int be_timelimit; /* time limit for this backend */
226 struct acl *be_acl; /* access control list for this backend */
227 int be_dfltaccess; /* access given if no acl matches */
228 char **be_replica; /* replicas of this backend (in master) */
229 char *be_replogfile; /* replication log file (in master) */
230 char *be_updatedn; /* allowed to make changes (in replicas) */
231 int be_lastmod; /* keep track of lastmodified{by,time} */
232 char *be_type; /* type of database */
234 void *be_private; /* anything the backend needs */
236 /* backend routines */
237 int (*be_bind) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, int method, struct berval *cred ));
238 void (*be_unbind) LDAP_P((Backend *be, struct conn *c, struct op *o ));
239 int (*be_search) LDAP_P((Backend *be, struct conn *c, struct op *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
240 int (*be_compare)LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, Ava *ava));
241 int (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPModList *m));
242 int (*be_modrdn) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, char *newrdn, int deleteoldrdn ));
243 int (*be_add) LDAP_P((Backend *be, struct conn *c, struct op *o, Entry *e));
244 int (*be_delete) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn));
245 /* Bug: be_abandon in unused! */
246 void (*be_abandon)LDAP_P((Backend *be, struct conn *c, struct op *o, int msgid));
247 void (*be_config) LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
248 void (*be_init) LDAP_P((Backend *be));
249 void (*be_close) LDAP_P((Backend *be));
251 #ifdef SLAPD_ACLGROUPS
252 int (*be_group) LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
257 * represents an operation pending from an ldap client
261 BerElement *o_ber; /* ber of the request */
262 long o_msgid; /* msgid of the request */
263 unsigned long o_tag; /* tag of the request */
264 time_t o_time; /* time op was initiated */
265 char *o_dn; /* dn bound when op was initiated */
266 char *o_suffix; /* suffix if aliased */
267 char *o_suffixAliased; /* pending suffix translation */
268 int o_authtype; /* auth method used to bind dn */
269 /* values taken from ldap.h */
271 int o_opid; /* id of this operation */
272 int o_connid; /* id of conn initiating this op */
273 #ifdef LDAP_CONNECTIONLESS
274 int o_cldap; /* != 0 if this came in via CLDAP */
275 struct sockaddr o_clientaddr; /* client address if via CLDAP */
276 char o_searchbase; /* search base if via CLDAP */
278 struct op *o_next; /* next operation pending */
279 pthread_t o_tid; /* thread handling this op */
280 int o_abandon; /* signals op has been abandoned */
281 pthread_mutex_t o_abandonmutex; /* signals op has been abandoned */
283 int o_private; /* anything the backend needs */
287 * represents a connection from an ldap client
290 typedef struct conn {
291 Sockbuf c_sb; /* ber connection stuff */
292 char *c_dn; /* current DN bound to this conn */
293 pthread_mutex_t c_dnmutex; /* mutex for c_dn field */
294 int c_authtype; /* auth method used to bind c_dn */
296 int c_version; /* for compatibility w/2.0, 3.0 */
298 char *c_addr; /* address of client on this conn */
299 char *c_domain; /* domain of client on this conn */
300 Operation *c_ops; /* list of pending operations */
301 pthread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */
302 pthread_mutex_t c_pdumutex; /* only one pdu written at a time */
303 pthread_cond_t c_wcv; /* used to wait for sd write-ready*/
304 int c_gettingber; /* in the middle of ber_get_next */
305 BerElement *c_currentber; /* ber we're getting */
306 int c_writewaiter; /* signals write-ready sd waiter */
307 int c_pduwaiters; /* signals threads waiting 4 pdu */
308 time_t c_starttime; /* when the connection was opened */
309 int c_connid; /* id of this connection for stats*/
310 int c_opsinitiated; /* # ops initiated/next op id */
311 int c_opscompleted; /* # ops completed */
314 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
315 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
317 if ( ldap_debug & level ) \
318 fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
319 if ( ldap_syslog & level ) \
320 syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
324 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
327 #include "proto-slap.h"
331 #endif /* _slap_h_ */