X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackend.c;h=987eb8832c67d62f7126888403fc0df32a47f4b0;hb=919274432b0603c7726ca398ad9e11bb08c1a0e2;hp=a9d5253785d82ff7fa097fc12912c75f1d59eaf1;hpb=6107ba67d2fd7eadb23ffdd1d284306011ef4013;p=openldap diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index a9d5253785..987eb8832c 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -254,34 +254,32 @@ int backend_startup(Backend *be) if ( be->bd_info->bi_open ) { rc = be->bd_info->bi_open( be->bd_info ); - } - - if(rc != 0) { + if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG( BACKEND, CRIT, "backend_startup: bi_open failed!\n", 0, 0, 0 ); + LDAP_LOG( BACKEND, CRIT, "backend_startup: bi_open failed!\n", 0, 0, 0 ); #else - Debug( LDAP_DEBUG_ANY, - "backend_startup: bi_open failed!\n", - 0, 0, 0 ); + Debug( LDAP_DEBUG_ANY, + "backend_startup: bi_open failed!\n", + 0, 0, 0 ); #endif - return rc; + return rc; + } } if ( be->bd_info->bi_db_open ) { rc = be->bd_info->bi_db_open( be ); - } - - if(rc != 0) { + if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG( BACKEND, CRIT, - "backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 ); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 ); #else - Debug( LDAP_DEBUG_ANY, - "backend_startup: bi_db_open failed! (%d)\n", - rc, 0, 0 ); + Debug( LDAP_DEBUG_ANY, + "backend_startup: bi_db_open failed! (%d)\n", + rc, 0, 0 ); #endif - return rc; + return rc; + } } return rc; @@ -297,18 +295,17 @@ int backend_startup(Backend *be) if( backendInfo[i].bi_open ) { rc = backendInfo[i].bi_open( &backendInfo[i] ); - } - - if(rc != 0) { + if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG( BACKEND, CRIT, - "backend_startup: bi_open %d failed!\n", i, 0, 0 ); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_open %d failed!\n", i, 0, 0 ); #else - Debug( LDAP_DEBUG_ANY, - "backend_startup: bi_open %d failed!\n", - i, 0, 0 ); + Debug( LDAP_DEBUG_ANY, + "backend_startup: bi_open %d failed!\n", + i, 0, 0 ); #endif - return rc; + return rc; + } } } @@ -320,18 +317,17 @@ int backend_startup(Backend *be) if ( backendDB[i].bd_info->bi_db_open ) { rc = backendDB[i].bd_info->bi_db_open( &backendDB[i] ); - } - - if(rc != 0) { + if ( rc != 0 ) { #ifdef NEW_LOGGING - LDAP_LOG( BACKEND, CRIT, - "backend_startup: bi_db_open(%d) failed! (%d)\n", i, rc, 0 ); + LDAP_LOG( BACKEND, CRIT, + "backend_startup: bi_db_open(%d) failed! (%d)\n", i, rc, 0 ); #else - Debug( LDAP_DEBUG_ANY, - "backend_startup: bi_db_open(%d) failed! (%d)\n", - i, rc, 0 ); + Debug( LDAP_DEBUG_ANY, + "backend_startup: bi_db_open(%d) failed! (%d)\n", + i, rc, 0 ); #endif - return rc; + return rc; + } } } @@ -589,7 +585,7 @@ be_issuffix( int i; for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i].bv_val != NULL; i++ ) { - if ( ber_bvcmp( &be->be_nsuffix[i], bvsuffix ) == 0 ) { + if ( bvmatch( &be->be_nsuffix[i], bvsuffix ) ) { return( 1 ); } } @@ -746,9 +742,14 @@ backend_check_controls( return LDAP_SUCCESS; } + if ( be->be_controls == NULL ) { + *text = "control unavailable in context"; + return LDAP_UNAVAILABLE_CRITICAL_EXTENSION; + } + for( ; *ctrls != NULL ; ctrls++ ) { if( (*ctrls)->ldctl_iscritical && - !charray_inlist( be->be_controls, (*ctrls)->ldctl_oid ) ) + !ldap_charray_inlist( be->be_controls, (*ctrls)->ldctl_oid ) ) { *text = "control unavailable in context"; return LDAP_UNAVAILABLE_CRITICAL_EXTENSION; @@ -820,7 +821,7 @@ backend_check_restrictions( { struct berval bv = BER_BVC( LDAP_EXOP_START_TLS ); - if( ber_bvcmp( opdata, &bv ) == 0 ) { + if( bvmatch( opdata, &bv ) ) { session++; starttls++; break; @@ -829,7 +830,7 @@ backend_check_restrictions( { struct berval bv = BER_BVC( LDAP_EXOP_X_WHO_AM_I ); - if( ber_bvcmp( opdata, &bv ) == 0 ) { + if( bvmatch( opdata, &bv ) ) { break; } } @@ -909,7 +910,7 @@ backend_check_restrictions( if( op->o_ndn.bv_len == 0 ) { *text = "modifications require authentication"; - return LDAP_OPERATIONS_ERROR; + return LDAP_STRONG_AUTH_REQUIRED; } } } @@ -1026,6 +1027,7 @@ backend_group( } ldap_pvt_thread_mutex_lock( &conn->c_mutex ); + for (g = conn->c_groups; g; g=g->ga_next) { if (g->ga_be != be || g->ga_oc != group_oc || g->ga_at != group_at || g->ga_len != gr_ndn->bv_len) @@ -1033,7 +1035,9 @@ backend_group( if (strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0) break; } + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + if (g) { return g->ga_res; } @@ -1043,7 +1047,7 @@ backend_group( target, gr_ndn, op_ndn, group_oc, group_at ); - if (op->o_tag != LDAP_REQ_BIND) { + if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache ) { g = ch_malloc(sizeof(GroupAssertion) + gr_ndn->bv_len); g->ga_be = be; g->ga_oc = group_oc; @@ -1102,16 +1106,18 @@ Attribute *backend_operational( { Attribute *a = NULL, **ap = &a; -#ifdef SLAPD_SCHEMA_DN - *ap = slap_operational_subschemaSubentry(); - ap = &(*ap)->a_next; -#endif - /* * If operational attributes (allegedly) are required, * and the backend supports specific operational attributes, * add them to the attribute list */ +#ifdef SLAPD_SCHEMA_DN + if ( opattrs || ( attrs && + ad_inlist( slap_schema.si_ad_subschemaSubentry, attrs )) ) { + *ap = slap_operational_subschemaSubentry( be ); + ap = &(*ap)->a_next; + } +#endif if ( ( opattrs || attrs ) && be && be->be_operational != NULL ) { ( void )be->be_operational( be, conn, op, e, attrs, opattrs, ap ); }