From 2b82d4f4863c3e54352bd9213baac6fd0c5243ab Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 22 Sep 2000 01:40:57 +0000 Subject: [PATCH] remove lint update bdb codes --- build/main.dsw | 24 +++++++++++ include/ldap_pvt.h | 4 ++ libraries/libldap/cyrus.c | 3 +- libraries/libldap/getattr.c | 2 + servers/slapd/back-bdb/back-bdb.h | 6 +++ servers/slapd/back-bdb/backbdb.dsp | 8 ++++ servers/slapd/back-bdb/external.h | 2 +- servers/slapd/back-bdb/idl.c | 6 --- servers/slapd/back-bdb/init.c | 64 +++++++++++++++--------------- servers/slapd/back-bdb/nextid.c | 23 +++++++++-- servers/slapd/back-bdb/proto-bdb.h | 27 ++++++++++++- servers/slapd/back-bdb/tools.c | 2 +- servers/slapd/backend.c | 2 +- servers/slapd/config.c | 4 +- servers/slapd/connection.c | 25 ++++++------ servers/slapd/libslapd.dsp | 4 ++ servers/slapd/proto-slap.h | 19 ++++++++- servers/slapd/sasl.c | 4 +- servers/slapd/saslauthz.c | 9 +++-- 19 files changed, 168 insertions(+), 70 deletions(-) diff --git a/build/main.dsw b/build/main.dsw index 043192ba0d..2226ef1f65 100644 --- a/build/main.dsw +++ b/build/main.dsw @@ -39,6 +39,18 @@ Package=<4> ############################################################################### +Project: "backbdb"="..\servers\slapd\back-bdb\backbdb.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "backldbm"="..\servers\slapd\back-ldbm\backldbm.dsp" - Package Owner=<4> Package=<5> @@ -518,6 +530,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name liblunicode End Project Dependency + Begin Project Dependency + Project_Dep_Name backbdb + End Project Dependency }}} ############################################################################### @@ -557,6 +572,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name liblunicode End Project Dependency + Begin Project Dependency + Project_Dep_Name backbdb + End Project Dependency }}} ############################################################################### @@ -599,6 +617,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name liblunicode End Project Dependency + Begin Project Dependency + Project_Dep_Name backbdb + End Project Dependency }}} ############################################################################### @@ -638,6 +659,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name liblunicode End Project Dependency + Begin Project Dependency + Project_Dep_Name backbdb + End Project Dependency }}} ############################################################################### diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h index 40ad5029b9..c145046f29 100644 --- a/include/ldap_pvt.h +++ b/include/ldap_pvt.h @@ -141,6 +141,10 @@ LDAP_F (int) ldap_pvt_sasl_install LDAP_P(( struct sockbuf *, void * )); #define LDAP_PVT_SASL_LOCAL_SSF 71 /* SSF for Unix Domain Sockets */ +struct ldap; +LDAP_F (int) ldap_open_internal_connection LDAP_P(( + struct ldap **ldp, ber_socket_t *fdp )); + /* search.c */ LDAP_F( char * ) ldap_pvt_find_wildcard LDAP_P(( const char *s )); diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index f0f8875b5e..5930e84b23 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -210,7 +210,8 @@ sb_sasl_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) /* Grow the packet buffer if neccessary */ if ( ( p->sec_buf_in.buf_size < ret ) && - ber_pvt_sb_grow_buffer( &p->sec_buf_in, ret ) < 0 ) { + ber_pvt_sb_grow_buffer( &p->sec_buf_in, ret ) < 0 ) + { errno = ENOMEM; return -1; } diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index ae645534fb..2c78f230b3 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -24,7 +24,9 @@ char * ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **berout ) { +#if LBER_SEQORSET_AVOID_OVERRUN int rc; +#endif ber_tag_t tag; ber_len_t len; char *attr; diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 0cda387daf..7efbfcb4b7 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -15,6 +15,12 @@ LDAP_BEGIN_DECL +#define BDB_IDL_SIZE (1<<16) +#define BDB_IDL_MAX (BDB_IDL_SIZE-16) +#define BDB_IDL_ALLOC (BDB_IDL_MAX * sizeof(ID)) + +#define BDB_IS_ALLIDS(ids) ((ids)[0] == NOID) + #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX #define DN_ONE_PREFIX '%' #define DN_SUBTREE_PREFIX '@' diff --git a/servers/slapd/back-bdb/backbdb.dsp b/servers/slapd/back-bdb/backbdb.dsp index ab0beaa5be..cb8048b048 100644 --- a/servers/slapd/back-bdb/backbdb.dsp +++ b/servers/slapd/back-bdb/backbdb.dsp @@ -127,6 +127,10 @@ LIB32=link.exe -lib # Name "backbdb - Win32 Single Release" # Begin Source File +SOURCE=.\add.c +# End Source File +# Begin Source File + SOURCE=".\back-bdb.h" # End Source File # Begin Source File @@ -159,6 +163,10 @@ SOURCE=".\proto-bdb.h" # End Source File # Begin Source File +SOURCE=.\search.c +# End Source File +# Begin Source File + SOURCE=.\tools.c # End Source File # End Target diff --git a/servers/slapd/back-bdb/external.h b/servers/slapd/back-bdb/external.h index c08b9db81e..fbbc8806bb 100644 --- a/servers/slapd/back-bdb/external.h +++ b/servers/slapd/back-bdb/external.h @@ -9,7 +9,7 @@ LDAP_BEGIN_DECL -extern int bdb_back_initialize LDAP_P(( BackendInfo *bi )); +extern int bdb_initialize LDAP_P(( BackendInfo *bi )); LDAP_END_DECL diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index d68fe317bf..e1a36ed165 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -14,12 +14,6 @@ #include "back-bdb.h" -#define BDB_IDL_SIZE (1<<16) -#define BDB_IDL_MAX (BDB_IDL_SIZE-16) -#define BDB_IDL_ALLOC (BDB_IDL_MAX * sizeof(ID)) - -#define BDB_IS_ALLIDS(ids) ((ids)[0] == NOID) - #define IDL_CMP(x,y) ( x < y ? -1 : ( x > y ? 1 : 0 ) ) static int idl_search( ID *ids, ID id ) diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index ea4021aef5..74d56e6801 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -14,32 +14,39 @@ #include "back-bdb.h" -static char *bdbi_dbnames[BDB_INDICES] = { - "nextid", "id2entry", "dn2entry" +static struct bdbi_database { + char *file; + char *name; + int type; + int flags; +} bdbi_databases[BDB_INDICES] = { + { "nextid", "nextid", DB_BTREE, 0 }, + { "id2entry", "id2entry", DB_BTREE, 0 }, + { "dn2entry", "dn2entry", DB_BTREE, 0 } }; static int -bi_back_destroy( BackendInfo *bi ) +bdb_destroy( BackendInfo *bi ) { return 0; } static int -bi_back_open( BackendInfo *bi ) +bdb_open( BackendInfo *bi ) { /* initialize the underlying database system */ return 0; } static int -bi_back_close( BackendInfo *bi ) +bdb_close( BackendInfo *bi ) { /* terminate the underlying database system */ return 0; } static int -bi_back_db_init( Backend *be ) +bdb_db_init( Backend *be ) { struct bdb_info *bdb; @@ -56,7 +63,7 @@ bi_back_db_init( Backend *be ) } static int -bi_back_db_open( BackendDB *be ) +bdb_db_open( BackendDB *be ) { int rc, i; struct bdb_info *bdb = (struct bdb_info *) be->be_private; @@ -130,16 +137,7 @@ bi_back_db_open( BackendDB *be ) return rc; } - flags = DB_THREAD; - -#if 0 - if( be->be_read_only ) { - flags |= DB_RDONLY; - } else -#endif - { - flags |= DB_CREATE; - } + flags = DB_THREAD | DB_CREATE; /* open (and create) main database */ for( i = 0; i < BDB_INDICES; i++ ) { @@ -156,10 +154,10 @@ bi_back_db_open( BackendDB *be ) } rc = db->bdi_db->open( db->bdi_db, - bdbi_dbnames[i], - bdbi_dbnames[i], - DB_BTREE, - flags, + bdbi_databases[i].file, + bdbi_databases[i].name, + bdbi_databases[i].type, + bdbi_databases[i].flags | flags, bdb->bi_dbenv_mode ); if( rc != 0 ) { @@ -177,7 +175,7 @@ bi_back_db_open( BackendDB *be ) } static int -bi_back_db_close( BackendDB *be ) +bdb_db_close( BackendDB *be ) { int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; @@ -200,7 +198,7 @@ bi_back_db_close( BackendDB *be ) } static int -bi_back_db_destroy( BackendDB *be ) +bdb_db_destroy( BackendDB *be ) { int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; @@ -224,7 +222,7 @@ int back_bdb_LTX_init_module( int argc, char *argv[] ) { memset( &bi, '\0', sizeof(bi) ); bi.bi_type = "bdb"; - bi.bi_init = bi_back_initialize; + bi.bi_init = bdb_initialize; backend_add( &bi ); return 0; @@ -232,7 +230,7 @@ int back_bdb_LTX_init_module( int argc, char *argv[] ) { #endif /* SLAPD_BDB_DYNAMIC */ int -bdb_back_initialize( +bdb_initialize( BackendInfo *bi ) { @@ -255,22 +253,22 @@ bdb_back_initialize( "\tgot: %s \n", version, 0, 0 ); } - Debug( LDAP_DEBUG_ANY, "bi_back_initialize: %s\n", + Debug( LDAP_DEBUG_ANY, "bdb_initialize: %s\n", version, 0, 0 ); } bi->bi_controls = controls; - bi->bi_open = bi_back_open; - bi->bi_close = bi_back_close; + bi->bi_open = bdb_open; + bi->bi_close = bdb_close; bi->bi_config = 0; - bi->bi_destroy = bi_back_destroy; + bi->bi_destroy = bdb_destroy; - bi->bi_db_init = bi_back_db_init; + bi->bi_db_init = bdb_db_init; bi->bi_db_config = 0; - bi->bi_db_open = bi_back_db_open; - bi->bi_db_close = bi_back_db_close; - bi->bi_db_destroy = bi_back_db_destroy; + bi->bi_db_open = bdb_db_open; + bi->bi_db_close = bdb_db_close; + bi->bi_db_destroy = bdb_db_destroy; #if 0 bi->bi_op_bind = bi_back_bind; diff --git a/servers/slapd/back-bdb/nextid.c b/servers/slapd/back-bdb/nextid.c index 92af935603..acf15046c7 100644 --- a/servers/slapd/back-bdb/nextid.c +++ b/servers/slapd/back-bdb/nextid.c @@ -21,6 +21,12 @@ int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *out ) ID kid = NOID; ID id; DBT key, data; + DB_TXN *ltid; + + rc = txn_begin( bdb->bi_dbenv, tid, <id, 0 ); + if( rc != 0 ) { + return rc; + } DBTzero( &key ); key.data = (char *) &kid; @@ -33,26 +39,35 @@ int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *out ) /* get exiting value (with write lock) */ rc = bdb->bi_entries->bdi_db->get( bdb->bi_nextid->bdi_db, - tid, &key, &data, DB_RMW ); + ltid, &key, &data, DB_RMW ); if( rc == DB_NOTFOUND ) { /* must be first add */ id = NOID; } else if( rc != 0 ) { - return rc; + goto done; } else if ( data.size != sizeof(ID) ) { /* size mismatch! */ - return -1; + rc = -1; + goto done; } id++; /* store new value */ rc = bdb->bi_entries->bdi_db->put( bdb->bi_nextid->bdi_db, - tid, &key, &data, 0 ); + ltid, &key, &data, 0 ); *out = id; + +done: + if( rc != 0 ) { + (void) txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } + return rc; } diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 5ab0c07f68..e87da339fc 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -9,10 +9,22 @@ LDAP_BEGIN_DECL + /* - * error.c + * alias.c */ -void bdb_errcall( const char *pfx, char * msg ); +Entry *bdb_deref_internal_r LDAP_P(( + Backend *be, + Entry *e, + const char *dn, + int *err, + Entry **matched, + const char **text )); + +#define deref_entry_r( be, e, err, matched, text ) \ + bdb_deref_internal_r( be, e, NULL, err, matched, text ) +#define deref_dn_r( be, dn, err, matched, text ) \ + bdb_deref_internal_r( be, NULL, dn, err, matched, text) /* * dn2id.c @@ -23,6 +35,17 @@ int bdb_index_dn_add( const char *dn, ID id ); +Entry * bdb_dn2entry_rw LDAP_P(( Backend *be, DB_TXN *tid, + const char *dn, Entry **matched, int rw )); + +#define dn2entry_r(be, tid, dn, m) bdb_dn2entry_rw((be), (tid), (dn), (m), 0) +#define dn2entry_w(be, tid, dn, m) bdb_dn2entry_rw((be), (tid), (dn), (m), 1) + +/* + * error.c + */ +void bdb_errcall( const char *pfx, char * msg ); + /* * idl.c */ diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 113a5e33e6..686fd9ff6e 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -198,7 +198,7 @@ int bdb_tool_entry_reindex( Debug( LDAP_DEBUG_ANY, "bdb_tool_entry_reindex:: could not locate id=%ld\n", (long) id, 0, 0 ); - txn_abort( bdi->bdi_db_env ); + txn_abort( tid ); return -1; } diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index e3da050191..441e1eb38d 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -51,7 +51,7 @@ static BackendInfo binfo[] = { #if defined(SLAPD_BDB) && !defined(SLAPD_BDB_DYNAMIC) - {"bdb", bdb_back_initialize}, + {"bdb", bdb_initialize}, #endif #if defined(SLAPD_DNSSRV) && !defined(SLAPD_DNSSRV_DYNAMIC) {"dnssrv", dnssrv_back_initialize}, diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 56246ad5ac..992d5ff658 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -314,6 +314,7 @@ read_config( const char *fname ) } } else if ( !strcasecmp( cargv[0], "saslregexp" ) ) { + int rc; if ( cargc != 3 ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: need 2 args in \"saslregexp \"\n", @@ -321,8 +322,9 @@ read_config( const char *fname ) return( 1 ); } rc = slap_sasl_regexp_config( cargv[1], cargv[2] ); - if ( rc ) + if ( rc ) { return rc; + } /* SASL security properties */ } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) { diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 4341567d0d..67f20d9f25 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -16,6 +16,7 @@ #include #include "ldap_pvt.h" +#include "lutil.h" #include "slap.h" /* protected by connections_mutex */ @@ -291,7 +292,7 @@ long connection_init( const char* sockname, int use_tls, slap_ssf_t ssf, - char *authid ) + const char *authid ) { unsigned long id; Connection *c; @@ -1264,26 +1265,26 @@ int connection_write(ber_socket_t s) * one another, for the front end to use for searches on arbitrary back ends. */ -int connection_internal_open( Connection **conn, LDAP **ldp, char *id ) +int connection_internal_open( Connection **conn, LDAP **ldp, const char *id ) { int rc; ber_socket_t fd[2] = {-1,-1}; Operation *op; - *conn=NULL; *ldp=NULL; - rc = pipe( fd ); - if( rc == -1 ) - return( LDAP_OPERATIONS_ERROR ); + rc = lutil_pair( fd ); + if( rc == -1 ) { + return LDAP_OTHER; + } rc = connection_init( fd[1], "INT", "localhost", "localhost:0", "localhost:00", 0, 256, id ); if( rc < 0 ) { - close( fd[0] ); - close( fd[1] ); - return( LDAP_OPERATIONS_ERROR ); + tcp_close( fd[0] ); + tcp_close( fd[1] ); + return LDAP_OTHER; } slapd_add_internal( fd[1] ); @@ -1300,14 +1301,14 @@ int connection_internal_open( Connection **conn, LDAP **ldp, char *id ) /* Create the client side of the connection */ rc = ldap_open_internal_connection( ldp, &(fd[0]) ); if( rc != LDAP_SUCCESS ) { - close( fd[0] ); - return( LDAP_OPERATIONS_ERROR ); + tcp_close( fd[0] ); + return LDAP_OTHER; } /* The connection_get() will have locked the connection's mutex */ ldap_pvt_thread_mutex_unlock( &((*conn)->c_mutex) ); - return( LDAP_SUCCESS ); + return LDAP_SUCCESS; } diff --git a/servers/slapd/libslapd.dsp b/servers/slapd/libslapd.dsp index 700b29c4bc..f1bc3d36c6 100644 --- a/servers/slapd/libslapd.dsp +++ b/servers/slapd/libslapd.dsp @@ -288,6 +288,10 @@ SOURCE=.\sasl.c # End Source File # Begin Source File +SOURCE=.\saslauthz.c +# End Source File +# Begin Source File + SOURCE=.\schema.c # End Source File # Begin Source File diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index c8b8ea2e34..ae4fb17e56 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -272,7 +272,7 @@ LDAP_SLAPD_F (long) connection_init LDAP_P(( const char* sockname, int use_tls, slap_ssf_t ssf, - char *id )); + const char *id )); LDAP_SLAPD_F (void) connection_closing LDAP_P(( Connection *c )); LDAP_SLAPD_F (int) connection_state_closing LDAP_P(( Connection *c )); @@ -289,6 +289,10 @@ LDAP_SLAPD_F (void) connection_done LDAP_P((Connection *)); LDAP_SLAPD_F (void) connection2anonymous LDAP_P((Connection *)); +LDAP_SLAPD_F (int) connection_internal_open( + Connection **conn, LDAP **ldp, const char *id ); +LDAP_SLAPD_F (void) connection_internal_close( Connection *conn ); + /* * dn.c */ @@ -534,7 +538,7 @@ LDAP_SLAPD_F (char **) slap_sasl_mechs( Connection *c ); LDAP_SLAPD_F (int) slap_sasl_external( Connection *c, slap_ssf_t ssf, /* relative strength of external security */ - char *authid ); /* asserted authenication id */ + const char *authid ); /* asserted authenication id */ LDAP_SLAPD_F (int) slap_sasl_reset( Connection *c ); LDAP_SLAPD_F (int) slap_sasl_close( Connection *c ); @@ -545,6 +549,16 @@ LDAP_SLAPD_F (int) slap_sasl_bind LDAP_P(( struct berval *cred, char **edn, slap_ssf_t *ssf )); +/* + * saslauthz.c + */ +LDAP_SLAPD_F (int) slap_sasl_authorized LDAP_P(( + Connection *conn, + const char *authcid, + const char *authzid )); +LDAP_SLAPD_F (int) slap_sasl_regexp_config LDAP_P(( + const char *match, const char *replace )); + /* oc.c */ LDAP_SLAPD_F (int) oc_schema_info( Entry *e ); @@ -823,6 +837,7 @@ LDAP_SLAPD_F (int) slap_destroy LDAP_P((void)); struct sockaddr_in; +LDAP_SLAPD_F (void) slapd_add_internal(ber_socket_t s); LDAP_SLAPD_F (int) slapd_daemon_init( const char *urls ); LDAP_SLAPD_F (int) slapd_daemon_destroy(void); LDAP_SLAPD_F (int) slapd_daemon(void); diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index af9687f753..ba37d59ea7 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -288,7 +288,7 @@ int slap_sasl_open( Connection *conn ) int slap_sasl_external( Connection *conn, slap_ssf_t ssf, - char *auth_id ) + const char *auth_id ) { #ifdef HAVE_CYRUS_SASL int sc; @@ -301,7 +301,7 @@ int slap_sasl_external( memset( &extprops, '\0', sizeof(extprops) ); extprops.ssf = ssf; - extprops.auth_id = auth_id; + extprops.auth_id = (char *) auth_id; sc = sasl_setprop( ctx, SASL_SSF_EXTERNAL, (void *) &extprops ); diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 1caa446ff7..48a3bb7a05 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -52,7 +52,7 @@ int slap_parseURI( char *uri, char **searchbase, int *scope, Filter **filter ) return( LDAP_SUCCESS ); } - end = index( uri + 7, '/' ); + end = strchr( uri + 7, '/' ); if ( end == NULL ) return( LDAP_PROTOCOL_ERROR ); @@ -60,7 +60,7 @@ int slap_parseURI( char *uri, char **searchbase, int *scope, Filter **filter ) /* Grab the searchbase */ start = end+1; - end = index( start, '?' ); + end = strchr( start, '?' ); if( end == NULL ) { *searchbase = ch_strdup( start ); dn_normalize( *searchbase ); @@ -73,7 +73,7 @@ int slap_parseURI( char *uri, char **searchbase, int *scope, Filter **filter ) /* Skip the attrs */ start = end+1; - end = index( start, '?' ); + end = strchr( start, '?' ); if( end == NULL ) { return( LDAP_SUCCESS ); } @@ -489,7 +489,8 @@ COMPLETE: /* Check if a bind can SASL authorize to another identity. */ -int slap_sasl_authorized( Connection *conn, char *authcid, char *authzid ) +int slap_sasl_authorized( Connection *conn, + const char *authcid, const char *authzid ) { int rc; char *saslname=NULL,*authcDN=NULL,*realm=NULL, *authzDN=NULL; -- 2.39.5