X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslap.h;h=37c0a5adfe348c393597d2bac660f03749479b5d;hb=433e8ad64544c9abacdc5727a39a1fbc5d826f55;hp=f5dee02400a728e06155cd0c69bf1fc019e93b76;hpb=b76c56ba3f45576b9c418ea9fe7f7b3440052904;p=openldap diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index f5dee02400..37c0a5adfe 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -3,10 +3,12 @@ #ifndef _SLDAPD_H_ #define _SLDAPD_H_ -#include "portable.h" - #include +#ifndef LDAP_SYSLOG +#define LDAP_SYSLOG 1 +#endif + #include #include #include @@ -15,11 +17,21 @@ #include #include "avl.h" -#include "lber.h" + +#ifndef ldap_debug +#define ldap_debug slap_debug +#endif + +#include "ldap_log.h" + +#include "../../libraries/liblber/lber-int.h" #include "ldap.h" -#include "lthread.h" -#include "lthread_rdwr.h" + +#include "ldap_pvt_thread.h" #include "ldif.h" +#ifdef f_next +#undef f_next /* name conflict between sys/file.h on SCO and struct filter */ +#endif #define DN_DNS 0 #define DN_X500 1 @@ -30,8 +42,22 @@ #define MAXREMATCHES 10 +#define DNSEPARATOR(c) ((c) == ',' || (c) == ';') +#define SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+') +#define SPACE(c) ((c) == ' ' || (c) == '\n') +#define NEEDSESCAPE(c) ((c) == '\\' || (c) == '"') + LDAP_BEGIN_DECL +extern int slap_debug; + +#ifdef SLAPD_BDB2 +extern int bdb2i_do_timing; +#endif + +struct slap_op; +struct slap_conn; + /* * represents an attribute value assertion (i.e., attr=value) */ @@ -112,13 +138,14 @@ typedef unsigned long ID; */ typedef struct entry { char *e_dn; /* DN of this entry */ + char *e_ndn; /* normalized DN of this entry */ Attribute *e_attrs; /* list of attributes + values */ ID e_id; /* id of this entry - this should */ /* really be private to back-ldbm */ char e_state; /* for the cache */ - pthread_rdwr_t e_rdwr; /* reader/writer lock */ + ldap_pvt_thread_rdwr_t e_rdwr; /* reader/writer lock */ #define ENTRY_STATE_DELETED 1 #define ENTRY_STATE_CREATING 2 @@ -133,22 +160,24 @@ typedef struct entry { /* the "by" part */ struct access { - char *a_dnpat; - char *a_addrpat; - char *a_domainpat; - char *a_dnattr; - long a_access; - -#ifdef SLAPD_ACLGROUP - char *a_group; -#endif - #define ACL_NONE 0x01 #define ACL_COMPARE 0x02 #define ACL_SEARCH 0x04 #define ACL_READ 0x08 #define ACL_WRITE 0x10 #define ACL_SELF 0x40 + int a_access; + + char *a_dnpat; + char *a_addrpat; + char *a_domainpat; + char *a_dnattr; + +#ifdef SLAPD_ACLGROUPS + char *a_group; + char *a_objectclassvalue; + char *a_groupattrname; +#endif struct access *a_next; }; @@ -166,6 +195,18 @@ struct acl { struct acl *acl_next; }; +/* + * A list of LDAPMods + */ +typedef struct ldapmodlist { + struct ldapmod ml_mod; + struct ldapmodlist *ml_next; +#define ml_op ml_mod.mod_op +#define ml_type ml_mod.mod_type +#define ml_values ml_mod.mod_values +#define ml_bvalues ml_mod.mod_bvalues +} LDAPModList; + /* * represents schema information for a database */ @@ -181,51 +222,81 @@ struct objclass { * represents a "database" */ -typedef struct backend { +typedef struct backend Backend; +struct backend { char **be_suffix; /* the DN suffixes of data in this backend */ - char *be_rootdn; /* the magic "root" dn for this db */ - char *be_rootpw; /* the magic "root" password for this db */ + char **be_suffixAlias; /* the DN suffix aliases of data in this backend */ + char *be_root_dn; /* the magic "root" dn for this db */ + char *be_root_ndn; /* the magic "root" normalized dn for this db */ + char *be_root_pw; /* the magic "root" password for this db */ int be_readonly; /* 1 => db is in "read only" mode */ + int be_maxDerefDepth; /* limit for depth of an alias deref */ int be_sizelimit; /* size limit for this backend */ int be_timelimit; /* time limit for this backend */ struct acl *be_acl; /* access control list for this backend */ int be_dfltaccess; /* access given if no acl matches */ char **be_replica; /* replicas of this backend (in master) */ char *be_replogfile; /* replication log file (in master) */ - char *be_updatedn; /* allowed to make changes (in replicas) */ + char *be_update_ndn; /* allowed to make changes (in replicas) */ int be_lastmod; /* keep track of lastmodified{by,time} */ char *be_type; /* type of database */ void *be_private; /* anything the backend needs */ - IFP be_bind; /* backend bind routine */ - IFP be_unbind; /* backend unbind routine */ - IFP be_search; /* backend search routine */ - IFP be_compare; /* backend compare routine */ - IFP be_modify; /* backend modify routine */ - IFP be_modrdn; /* backend modrdn routine */ - IFP be_add; /* backend add routine */ - IFP be_delete; /* backend delete routine */ - IFP be_abandon; /* backend abandon routine */ - IFP be_config; /* backend config routine */ - IFP be_init; /* backend init routine */ - IFP be_close; /* backend close routine */ - -#ifdef ACLGROUP - IFP be_group; /* backend group member test */ + /* backend routines */ + int (*be_bind) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *dn, int method, struct berval *cred, char** edn )); + void (*be_unbind) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o )); + int (*be_search) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *base, int scope, int deref, int slimit, int tlimit, + Filter *f, char *filterstr, char **attrs, int attrsonly)); + int (*be_compare)LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *dn, Ava *ava)); + int (*be_modify) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *dn, LDAPModList *m)); + int (*be_modrdn) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *dn, char *newrdn, int deleteoldrdn )); + int (*be_add) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + Entry *e)); + int (*be_delete) LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + char *dn)); + /* Bug: be_abandon in unused! */ + void (*be_abandon)LDAP_P((Backend *be, + struct slap_conn *c, struct slap_op *o, + int msgid)); + void (*be_config) LDAP_P((Backend *be, + char *fname, int lineno, int argc, char **argv )); + void (*be_init) LDAP_P((Backend *be)); + void (*be_startup) LDAP_P((Backend *be)); + void (*be_shutdown) LDAP_P((Backend *be)); + void (*be_close) LDAP_P((Backend *be)); + +#ifdef SLAPD_ACLGROUPS + int (*be_group) LDAP_P((Backend *be, Entry *e, + char *bdn, char *edn, + char *objectclassValue, char *groupattrName )); #endif -} Backend; +}; /* * represents an operation pending from an ldap client */ -typedef struct op { +typedef struct slap_op { BerElement *o_ber; /* ber of the request */ long o_msgid; /* msgid of the request */ unsigned long o_tag; /* tag of the request */ time_t o_time; /* time op was initiated */ char *o_dn; /* dn bound when op was initiated */ + char *o_ndn; /* normalized dn bound when op was initiated */ int o_authtype; /* auth method used to bind dn */ /* values taken from ldap.h */ /* LDAP_AUTH_* */ @@ -236,22 +307,24 @@ typedef struct op { struct sockaddr o_clientaddr; /* client address if via CLDAP */ char o_searchbase; /* search base if via CLDAP */ #endif - struct op *o_next; /* next operation pending */ - pthread_t o_tid; /* thread handling this op */ + struct slap_op *o_next; /* next operation pending */ + ldap_pvt_thread_t o_tid; /* thread handling this op */ int o_abandon; /* signals op has been abandoned */ - pthread_mutex_t o_abandonmutex; /* signals op has been abandoned */ + ldap_pvt_thread_mutex_t o_abandonmutex; /* signals op has been abandoned */ - int o_private; /* anything the backend needs */ + void *o_private; /* anything the backend needs */ } Operation; /* * represents a connection from an ldap client */ -typedef struct conn { +typedef struct slap_conn { Sockbuf c_sb; /* ber connection stuff */ - char *c_dn; /* current DN bound to this conn */ - pthread_mutex_t c_dnmutex; /* mutex for c_dn field */ + char *c_cdn; /* DN provided by the client */ + char *c_dn; /* DN bound to this conn */ + ldap_pvt_thread_mutex_t c_dnmutex; /* mutex for c_dn field */ + int c_protocol; /* version of the LDAP protocol used by client */ int c_authtype; /* auth method used to bind c_dn */ #ifdef LDAP_COMPAT int c_version; /* for compatibility w/2.0, 3.0 */ @@ -259,9 +332,9 @@ typedef struct conn { char *c_addr; /* address of client on this conn */ char *c_domain; /* domain of client on this conn */ Operation *c_ops; /* list of pending operations */ - pthread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */ - pthread_mutex_t c_pdumutex; /* only one pdu written at a time */ - pthread_cond_t c_wcv; /* used to wait for sd write-ready*/ + ldap_pvt_thread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */ + ldap_pvt_thread_mutex_t c_pdumutex; /* only one pdu written at a time */ + ldap_pvt_thread_cond_t c_wcv; /* used to wait for sd write-ready*/ int c_gettingber; /* in the middle of ber_get_next */ BerElement *c_currentber; /* ber we're getting */ int c_writewaiter; /* signals write-ready sd waiter */ @@ -277,7 +350,7 @@ typedef struct conn { { \ if ( ldap_debug & level ) \ fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\ - if ( ldap_syslog & level ) \ + if ( 0 && (ldap_syslog & level) ) \ syslog( ldap_syslog_level, fmt, connid, opid, arg1, \ arg2, arg3 ); \ }