From: Pierangelo Masarati Date: Fri, 25 Nov 2005 22:17:24 +0000 (+0000) Subject: use LDAP_SIZELIMIT_EXCEEDED; rework the return values of slap_send_search_entry(... X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~687 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b3c8a976ec84572bef54624de74ba6677c053e53;p=openldap use LDAP_SIZELIMIT_EXCEEDED; rework the return values of slap_send_search_entry(); silence a few warnings --- diff --git a/servers/slapd/aci.c b/servers/slapd/aci.c index 50bef60b75..70e749ef0a 100644 --- a/servers/slapd/aci.c +++ b/servers/slapd/aci.c @@ -696,7 +696,7 @@ aci_init( void ) &rc, &text, LDAP_SCHEMA_ALLOW_ALL ); if ( !at ) { Debug( LDAP_DEBUG_ANY, - "%s AttributeType load failed: %s %s\n", + "aci_init: AttributeType \"%s\" parse failed: %s %s\n", aci_at.name, ldap_scherr2str( rc ), text ); return rc; } @@ -704,9 +704,9 @@ aci_init( void ) rc = at_add( at, 0, &sat, &text ); if ( rc != LDAP_SUCCESS ) { ldap_attributetype_free( at ); - fprintf( stderr, "iMUX_monitor_schema_init: " - "AttributeType load failed: %s %s\n", - scherr2str( rc ), text ); + Debug( LDAP_DEBUG_ANY, + "aci_init: AttributeType \"%s\" load failed: %s %s\n", + aci_at.name, scherr2str( rc ), text ); return rc; } ldap_memfree( at ); @@ -715,7 +715,7 @@ aci_init( void ) aci_at.ad, &text ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, - "unable to find AttributeDescription " + "aci_init: unable to find AttributeDescription " "\"%s\": %d (%s)\n", aci_at.name, rc, text ); return 1; diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 3cd2d5c9c9..5a666a4650 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -325,7 +325,7 @@ parse_acl( int pos ) { int i; - char *left, *right, *style, *next; + char *left, *right, *style; struct berval bv; AccessControl *a; Access *b; @@ -776,8 +776,6 @@ parse_acl( } else if ( strcasecmp( style, "level" ) == 0 ) { - char *next; - if ( lutil_atoi( &level, style_level ) != 0 ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: unable to parse level " diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 9b7a94f2f2..e39c23daf9 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -874,20 +874,20 @@ fetch_entry_retry: if (e) { /* safe default */ - int result = -1; rs->sr_attrs = op->oq_search.rs_attrs; rs->sr_operational_attrs = NULL; rs->sr_ctrls = NULL; rs->sr_flags = 0; rs->sr_err = LDAP_SUCCESS; - result = send_search_entry( op, rs ); + rs->sr_err = send_search_entry( op, rs ); - switch ( result ) { - case 0: /* entry sent ok */ + switch ( rs->sr_err ) { + case LDAP_SUCCESS: /* entry sent ok */ break; - case 1: /* entry not sent */ + default: /* entry not sent */ break; - default: + case LDAP_UNAVAILABLE: + case LDAP_SIZELIMIT_EXCEEDED: #ifdef SLAP_ZONE_ALLOC slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif @@ -895,16 +895,13 @@ fetch_entry_retry: &bdb->bi_cache, e, &lock); e = NULL; rs->sr_entry = NULL; - switch ( result ) { - case SLAPD_SEND_SIZELIMIT: - rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) { rs->sr_ref = rs->sr_v2ref; send_ldap_result( op, rs ); rs->sr_err = LDAP_SUCCESS; - break; - case -1: /* connection closed */ + + } else { rs->sr_err = LDAP_OTHER; - break; } goto done; } diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index eb70948b44..1a30eb6960 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -286,7 +286,6 @@ retry: } else if ( rc == LDAP_RES_SEARCH_ENTRY ) { Entry ent = { 0 }; struct berval bdn = BER_BVNULL; - int abort = 0; do_retry = 0; @@ -297,7 +296,7 @@ retry: rs->sr_attrs = op->ors_attrs; rs->sr_operational_attrs = NULL; rs->sr_flags = 0; - abort = send_search_entry( op, rs ); + rc = rs->sr_err = send_search_entry( op, rs ); if ( !BER_BVISNULL( &ent.e_name ) ) { assert( ent.e_name.bv_val != bdn.bv_val ); free( ent.e_name.bv_val ); @@ -310,11 +309,12 @@ retry: entry_clean( &ent ); } ldap_msgfree( res ); - if ( abort ) { - if ( abort == SLAPD_SEND_SIZELIMIT ) { - rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + if ( rc != LDAP_SUCCESS ) { + if ( rc == LDAP_UNAVAILABLE ) { + rc = rs->sr_err = LDAP_OTHER; + } else { + ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL ); } - ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL ); goto finish; } diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 75aa5347f7..633b7c2372 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -432,20 +432,16 @@ searchit: if ( scopeok ) { if (e) { rs->sr_flags = 0; - result = send_search_entry( op, rs ); - - switch ( result ) { - case 0: /* entry sent ok */ - break; - case 1: /* entry not sent */ - break; - case -1: /* connection closed */ + rs->sr_err = send_search_entry( op, rs ); + + switch ( rs->sr_err ) { + case LDAP_UNAVAILABLE: /* connection closed */ cache_return_entry_r( &li->li_cache, e ); rc = LDAP_SUCCESS; goto done; - case SLAPD_SEND_SIZELIMIT: + case LDAP_SIZELIMIT_EXCEEDED: cache_return_entry_r( &li->li_cache, e ); - rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + rc = rs->sr_err; rs->sr_entry = NULL; send_ldap_result( op, rs ); rc = LDAP_SUCCESS; diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index ae6e5c2616..9f76beb98e 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -456,20 +456,20 @@ really_bad:; e = ldap_first_entry( msc->msc_ld, res ); savepriv = op->o_private; op->o_private = (void *)i; - rc = meta_send_entry( op, rs, mc, i, e ); + rs->sr_err = meta_send_entry( op, rs, mc, i, e ); ldap_msgfree( res ); res = NULL; switch ( rc ) { - case SLAPD_SEND_SIZELIMIT: - rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + case LDAP_SIZELIMIT_EXCEEDED: savepriv = op->o_private; op->o_private = (void *)i; send_ldap_result( op, rs ); op->o_private = savepriv; + rs->sr_err = LDAP_SUCCESS; goto finish; - case -1: + case LDAP_UNAVAILABLE: rs->sr_err = LDAP_OTHER; goto finish; } @@ -1156,20 +1156,11 @@ next_attr:; rs->sr_entry = &ent; rs->sr_attrs = op->ors_attrs; rs->sr_flags = 0; - switch ( send_search_entry( op, rs ) ) { - case 0: - case 1: - rc = LDAP_SUCCESS; - break; - case -1: + rc = send_search_entry( op, rs ); + switch ( rc ) { + case LDAP_UNAVAILABLE: rc = LDAP_OTHER; break; - case SLAPD_SEND_SIZELIMIT: - rc = LDAP_SIZELIMIT_EXCEEDED; - break; - default: - /* trap other values when added... */ - assert( 0 ); } rs->sr_entry = NULL; rs->sr_attrs = NULL; diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c index 548a314870..3709ac18d2 100644 --- a/servers/slapd/back-perl/search.c +++ b/servers/slapd/back-perl/search.c @@ -89,11 +89,10 @@ perl_back_search( rs->sr_entry = e; rs->sr_attrs = op->ors_attrs; rs->sr_flags = REP_ENTRY_MODIFIABLE; - rc = send_search_entry( op, rs ); - switch ( rc ) { - case SLAPD_SEND_SIZELIMIT: + rs->sr_err = LDAP_SUCCESS; + rs->sr_err = send_search_entry( op, rs ); + if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) { rs->sr_entry = NULL; - rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; goto done; } } diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 58e506d3e5..efc6507224 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -2325,13 +2325,13 @@ backsql_search( Operation *op, SlapReply *rs ) rs->sr_entry = e; rs->sr_flags = ( e == &user_entry ) ? REP_ENTRY_MODIFIABLE : 0; /* FIXME: need the whole entry (ITS#3480) */ - sres = send_search_entry( op, rs ); + rs->sr_err = send_search_entry( op, rs ); rs->sr_entry = NULL; rs->sr_attrs = NULL; rs->sr_operational_attrs = NULL; - switch ( sres ) { - case -1: + switch ( rs->sr_err ) { + case LDAP_UNAVAILABLE: /* * FIXME: send_search_entry failed; * better stop @@ -2340,8 +2340,7 @@ backsql_search( Operation *op, SlapReply *rs ) "connection lost\n", 0, 0, 0 ); goto end_of_search; - case SLAPD_SEND_SIZELIMIT: - rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + case LDAP_SIZELIMIT_EXCEEDED: goto send_results; } } diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index e9c785f1a7..649f7098e0 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -234,7 +234,7 @@ glue_op_search ( Operation *op, SlapReply *rs ) BackendInfo *bi0 = op->o_bd->bd_info; int i; long stoptime = 0; - glue_state gs = {0, 0, 0, NULL, 0, NULL}; + glue_state gs = {0, 0, NULL, 0, NULL}; slap_callback cb = { NULL, glue_op_response, NULL, NULL }; int scope0, tlimit0; struct berval dn, ndn, *pdn; diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 52f4197ce4..1bd756a045 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -1489,7 +1489,6 @@ config_schema_dn(ConfigArgs *c) { static int config_sizelimit(ConfigArgs *c) { int i, rc = 0; - char *next; struct slap_limits_set *lim = &c->be->be_def_limit; if (c->op == SLAP_CONFIG_EMIT) { char buf[8192]; @@ -1541,7 +1540,6 @@ config_sizelimit(ConfigArgs *c) { static int config_timelimit(ConfigArgs *c) { int i, rc = 0; - char *next; struct slap_limits_set *lim = &c->be->be_def_limit; if (c->op == SLAP_CONFIG_EMIT) { char buf[8192]; @@ -2137,7 +2135,6 @@ static int config_syslog; static int config_loglevel(ConfigArgs *c) { int i; - char *next; if ( loglevel_ops == NULL ) { loglevel_init(); diff --git a/servers/slapd/overlays/retcode.c b/servers/slapd/overlays/retcode.c index 89ac536cd7..79db976854 100644 --- a/servers/slapd/overlays/retcode.c +++ b/servers/slapd/overlays/retcode.c @@ -114,8 +114,6 @@ retcode_send_onelevel( Operation *op, SlapReply *rs ) retcode_item_t *rdi; for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) { - int rc; - if ( op->o_abandon ) { return rs->sr_err = SLAPD_ABANDON; } @@ -135,20 +133,14 @@ retcode_send_onelevel( Operation *op, SlapReply *rs ) rs->sr_err = LDAP_SUCCESS; rs->sr_entry = &rdi->rdi_e; - rc = send_search_entry( op, rs ); + rs->sr_err = send_search_entry( op, rs ); + rs->sr_entry = NULL; - switch ( rc ) { - case 0: /* entry sent ok */ - break; - case 1: /* entry not sent */ - break; - case -1: /* connection closed */ - rs->sr_entry = NULL; + switch ( rs->sr_err ) { + case LDAP_UNAVAILABLE: /* connection closed */ rs->sr_err = LDAP_OTHER; - goto done; - case SLAPD_SEND_SIZELIMIT: - rs->sr_entry = NULL; - rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + /* fallthru */ + case LDAP_SIZELIMIT_EXCEEDED: goto done; } } diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 72889c1e3f..177273af8e 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -665,10 +665,11 @@ slap_send_ldap_intermediate( Operation *op, SlapReply *rs ) /* * returns: * - * 0 entry sent - * 1 entry not sent (other) - * -1 entry not sent (connection closed) - * SLAPD_SEND_SIZELIMIT entry not sent (caller must send sizelimitExceeded) + * LDAP_SUCCESS entry sent + * LDAP_OTHER entry not sent (other) + * LDAP_INSUFFICIENT_ACCESS entry not sent (ACL) + * LDAP_UNAVAILABLE entry not sent (connection closed) + * LDAP_SIZELIMIT_EXCEEDED entry not sent (caller must send sizelimitExceeded) */ int @@ -677,7 +678,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) BerElementBuffer berbuf; BerElement *ber = (BerElement *) &berbuf; Attribute *a; - int i, j, rc=-1, bytes; + int i, j, rc = LDAP_UNAVAILABLE, bytes; char *edn; int userattrs; AccessControlState acl_state = ACL_STATE_INIT; @@ -691,7 +692,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) char **e_flags = NULL; if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) { - return SLAPD_SEND_SIZELIMIT; + return LDAP_SIZELIMIT_EXCEEDED; } rs->sr_type = REP_SEARCH; @@ -744,7 +745,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) "send_search_entry: conn %lu access to entry (%s) not allowed\n", op->o_connid, rs->sr_entry->e_name.bv_val, 0 ); - rc = 1; + rc = LDAP_INSUFFICIENT_ACCESS; goto error_return; } @@ -790,6 +791,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" ); + rc = rs->sr_err; goto error_return; } @@ -837,6 +839,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "matched values filtering error" ); + rc = rs->sr_err; goto error_return; } } @@ -886,6 +889,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding description error"); + rc = rs->sr_err; goto error_return; } finish = 1; @@ -919,6 +923,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding description error"); + rc = rs->sr_err; goto error_return; } } @@ -930,6 +935,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding values error" ); + rc = rs->sr_err; goto error_return; } } @@ -942,6 +948,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encode end error" ); + rc = rs->sr_err; goto error_return; } } @@ -995,6 +1002,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "matched values filtering error" ); + rc = rs->sr_err; goto error_return; } } @@ -1044,6 +1052,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding description error" ); + rc = rs->sr_err; goto error_return; } @@ -1072,6 +1081,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encoding values error" ); + rc = rs->sr_err; goto error_return; } } @@ -1084,6 +1094,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encode end error" ); + rc = rs->sr_err; goto error_return; } } @@ -1118,7 +1129,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) if ( op->o_res_ber == NULL ) ber_free_buf( ber ); send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" ); - rc = 1; + rc = rs->sr_err; goto error_return; } @@ -1137,7 +1148,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) "send_search_entry: conn %lu ber write failed.\n", op->o_connid, 0, 0 ); - rc = -1; + rc = LDAP_UNAVAILABLE; goto error_return; } rs->sr_nentries++; @@ -1155,7 +1166,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 ); - rc = 0; + rc = LDAP_SUCCESS; error_return:; if ( op->o_callback ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 5de958e374..23ff59b9d6 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -153,9 +153,6 @@ LDAP_BEGIN_DECL /* unknown config file directive */ #define SLAP_CONF_UNKNOWN (-1026) -/* pseudo error code indicating caller should send sizelimitExceeded */ -#define SLAPD_SEND_SIZELIMIT (-1027) - /* We assume "C" locale, that is US-ASCII */ #define ASCII_SPACE(c) ( (c) == ' ' ) #define ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )