Commit 1f22cd31 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

import small fixes from HEAD

parent b84eb0f4
......@@ -6,6 +6,7 @@ OpenLDAP 2.3.26 Release
Fixed slapd incorrect rebuilding of replica URI (ITS#4633)
Fixed slapd DN X.509 normalization crash (ITS#4644)
Fixed slapd-monitor operations order via callbacks (ITS#4631)
Fixed slapd-sql undefined filter handling (ITS#4604)
Fixed slapo-accesslog purge task during shutdown
Fixed slapo-ppolicy handling of default policy (ITS#4634)
Fixed slapo-ppolicy logging verbosity when using default policy
......
......@@ -1141,15 +1141,6 @@ backsql_add( Operation *op, SlapReply *rs )
}
}
if ( get_assert( op ) &&
( test_filter( op, op->oq_add.rs_e, get_assertion( op ) )
!= LDAP_COMPARE_TRUE ) )
{
rs->sr_err = LDAP_ASSERTION_FAILED;
e = op->ora_e;
goto done;
}
/*
* create_proc is executed; if expect_return is set, then
* an output parameter is bound, which should contain
......@@ -1470,6 +1461,7 @@ done:;
SQLUSMALLINT CompletionType = SQL_ROLLBACK;
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
assert( e == NULL );
CompletionType = SQL_COMMIT;
}
......@@ -1514,6 +1506,10 @@ done:;
}
#endif /* SLAP_ACL_HONOR_DISCLOSE */
if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = LDAP_X_NO_OPERATION;
}
send_ldap_result( op, rs );
slap_graduate_commit_csn( op );
......
......@@ -441,6 +441,7 @@ backsql_delete( Operation *op, SlapReply *rs )
SQLUSMALLINT CompletionType = SQL_ROLLBACK;
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
assert( e == NULL );
CompletionType = SQL_COMMIT;
}
......@@ -464,6 +465,10 @@ done:;
}
#endif /* SLAP_ACL_HONOR_DISCLOSE */
if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = LDAP_X_NO_OPERATION;
}
send_ldap_result( op, rs );
Debug( LDAP_DEBUG_TRACE, "<==backsql_delete()\n", 0, 0, 0 );
......
......@@ -90,7 +90,7 @@ backsql_dn2id(
{
backsql_info *bi = op->o_bd->be_private;
SQLHSTMT sth = SQL_NULL_HSTMT;
BACKSQL_ROW_NTS row;
BACKSQL_ROW_NTS row = { 0 };
RETCODE rc;
int res;
struct berval realndn = BER_BVNULL;
......@@ -648,6 +648,11 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
"error preparing query: %s\n", at->bam_query, 0, 0 );
backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
#ifdef BACKSQL_COUNTQUERY
if ( append ) {
attr_free( attr );
}
#endif /* BACKSQL_COUNTQUERY */
return 1;
}
......@@ -656,6 +661,11 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_vals(): "
"error binding key value parameter\n", 0, 0, 0 );
#ifdef BACKSQL_COUNTQUERY
if ( append ) {
attr_free( attr );
}
#endif /* BACKSQL_COUNTQUERY */
return 1;
}
......@@ -678,6 +688,11 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
at->bam_query, 0, 0 );
backsql_PrintErrors( bi->sql_db_env, bsi->bsi_dbh, sth, rc );
SQLFreeStmt( sth, SQL_DROP );
#ifdef BACKSQL_COUNTQUERY
if ( append ) {
attr_free( attr );
}
#endif /* BACKSQL_COUNTQUERY */
return 1;
}
......
......@@ -36,10 +36,8 @@ sql_back_initialize(
static char *controls[] = {
LDAP_CONTROL_ASSERT,
LDAP_CONTROL_MANAGEDSAIT,
#if 0 /* needs improvements */
LDAP_CONTROL_NOOP,
#endif
#ifdef SLAP_CONTROL_X_TREE_DELETE
#if 0 /* SLAP_CONTROL_X_TREE_DELETE */
SLAP_CONTROL_X_TREE_DELETE,
#endif /* SLAP_CONTROL_X_TREE_DELETE */
NULL
......
......@@ -168,6 +168,7 @@ do_transact:;
* Commit only if all operations succeed
*/
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
assert( e == NULL );
CompletionType = SQL_COMMIT;
}
......@@ -190,6 +191,10 @@ done:;
}
#endif /* SLAP_ACL_HONOR_DISCLOSE */
if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = LDAP_X_NO_OPERATION;
}
send_ldap_result( op, rs );
slap_graduate_commit_csn( op );
......@@ -205,6 +210,11 @@ done:;
op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
}
if ( rs->sr_ref ) {
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
}
Debug( LDAP_DEBUG_TRACE, "<==backsql_modify()\n", 0, 0, 0 );
return rs->sr_err;
......
......@@ -533,6 +533,10 @@ done:;
SQLTransact( SQL_NULL_HENV, dbh, CompletionType );
}
if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = LDAP_X_NO_OPERATION;
}
send_ldap_result( op, rs );
slap_graduate_commit_csn( op );
......@@ -583,6 +587,11 @@ done:;
backsql_entry_clean( op, &n );
}
if ( rs->sr_ref ) {
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
}
Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 );
return rs->sr_err;
......
......@@ -120,7 +120,7 @@ example=> <control-D>
3.1.5) Run the test:
[root@localhost]# cd $SOURCES/tests
[root@localhost]# SLAPD_USE_SQL=pgsql ./run test031
[root@localhost]# SLAPD_USE_SQL=pgsql ./run sql-test000
3.2) MySQL
......@@ -149,7 +149,7 @@ mysql> exit;
3.2.5) Run the test:
[root@localhost]# cd $SOURCES/tests
[root@localhost]# SLAPD_USE_SQL=mysql ./run test031
[root@localhost]# SLAPD_USE_SQL=mysql ./run sql-test000
3.3) IBM db2
[n.a.]
......@@ -173,7 +173,7 @@ in auto-commit mode (-c)
3.3.5) Run the test:
[root@localhost]# cd $SOURCES/tests
[root@localhost]# SLAPD_USE_SQL=ibmdb2 ./run test031
[root@localhost]# SLAPD_USE_SQL=ibmdb2 ./run sql-test000
4) Cleanup:
The test is basically readonly; this can be performed by all RDBMSes
......
......@@ -319,6 +319,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
const char *text = NULL;
struct berval bv;
struct berbuf bb = BB_NULL;
AttributeDescription *ad = NULL;
Debug( LDAP_DEBUG_TRACE,
"attributeType:\n"
......@@ -336,10 +337,7 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
/* TimesTen */
Debug( LDAP_DEBUG_TRACE, "\tsel_expr_u=\"%s\"\n",
at_row.cols[ 8 ], 0, 0 );
at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) );
rc = slap_str2ad( at_row.cols[ 0 ],
&at_map->bam_ad, &text );
rc = slap_str2ad( at_row.cols[ 0 ], &ad, &text );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_attr_mapping(): "
"attribute \"%s\" for objectClass \"%s\" "
......@@ -349,6 +347,9 @@ backsql_oc_get_attr_mapping( void *v_oc, void *v_bas )
bas->bas_rc = LDAP_CONSTRAINT_VIOLATION;
return BACKSQL_AVL_STOP;
}
at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) );
at_map->bam_ad = ad;
ber_str2bv( at_row.cols[ 1 ], 0, 1, &at_map->bam_sel_expr );
if ( at_row.value_len[ 8 ] < 0 ) {
......
......@@ -314,9 +314,7 @@ backsql_init_search(
}
} else {
rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, scope );
rc = rs->sr_err = LDAP_REFERRAL;
rs->sr_err = rc;
}
}
}
......@@ -654,9 +652,35 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
Debug( LDAP_DEBUG_TRACE, "==>backsql_process_filter()\n", 0, 0, 0 );
if ( f->f_choice == SLAPD_FILTER_COMPUTED ) {
struct berval flt;
char *msg = NULL;
switch ( f->f_result ) {
case LDAP_COMPARE_TRUE:
BER_BVSTR( &flt, "10=10" );
msg = "TRUE";
break;
case LDAP_COMPARE_FALSE:
BER_BVSTR( &flt, "11=0" );
msg = "FALSE";
break;
case SLAPD_COMPARE_UNDEFINED:
BER_BVSTR( &flt, "12=0" );
msg = "UNDEFINED";
break;
default:
rc = -1;
goto done;
}
Debug( LDAP_DEBUG_TRACE, "backsql_process_filter(): "
"invalid filter\n", 0, 0, 0 );
rc = -1;
"filter computed (%s)\n", msg, 0, 0 );
backsql_strfcat_x( &bsi->bsi_flt_where,
bsi->bsi_op->o_tmpmemctx, "b", &flt );
rc = 1;
goto done;
}
......@@ -1517,16 +1541,16 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
BER_BVZERO( query );
}
free( bsi->bsi_sel.bb_val.bv_val );
bsi->bsi_op->o_tmpfree( bsi->bsi_sel.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
BER_BVZERO( &bsi->bsi_sel.bb_val );
bsi->bsi_sel.bb_len = 0;
free( bsi->bsi_from.bb_val.bv_val );
bsi->bsi_op->o_tmpfree( bsi->bsi_from.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
BER_BVZERO( &bsi->bsi_from.bb_val );
bsi->bsi_from.bb_len = 0;
free( bsi->bsi_join_where.bb_val.bv_val );
bsi->bsi_op->o_tmpfree( bsi->bsi_join_where.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
BER_BVZERO( &bsi->bsi_join_where.bb_val );
bsi->bsi_join_where.bb_len = 0;
free( bsi->bsi_flt_where.bb_val.bv_val );
bsi->bsi_op->o_tmpfree( bsi->bsi_flt_where.bb_val.bv_val, bsi->bsi_op->o_tmpmemctx );
BER_BVZERO( &bsi->bsi_flt_where.bb_val );
bsi->bsi_flt_where.bb_len = 0;
......@@ -1620,7 +1644,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi )
query.bv_val, 0, 0 );
rc = backsql_Prepare( bsi->bsi_dbh, &sth, query.bv_val, 0 );
free( query.bv_val );
bsi->bsi_op->o_tmpfree( query.bv_val, bsi->bsi_op->o_tmpmemctx );
BER_BVZERO( &query );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
......@@ -1970,7 +1994,7 @@ backsql_search( Operation *op, SlapReply *rs )
default:
#ifdef SLAP_ACL_HONOR_DISCLOSE
if ( !BER_BVISNULL( &base_entry.e_nname )
&& ! access_allowed( op, &base_entry,
&& !access_allowed( op, &base_entry,
slap_schema.si_ad_entry, NULL,
ACL_DISCLOSE, NULL ) )
{
......@@ -1991,6 +2015,10 @@ backsql_search( Operation *op, SlapReply *rs )
rs->sr_ref = NULL;
}
if ( !BER_BVISNULL( &base_entry.e_nname ) ) {
entry_clean( &base_entry );
}
goto done;
}
#ifdef SLAP_ACL_HONOR_DISCLOSE
......
......@@ -48,12 +48,11 @@ backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc )
Debug( LDAP_DEBUG_TRACE, "Return code: %d\n", rc, 0, 0 );
for ( ; rc = SQLError( henv, hdbc, sth, state, &iSqlCode, msg,
SQL_MAX_MESSAGE_LENGTH - 1, &len ), BACKSQL_SUCCESS( rc ); ) {
SQL_MAX_MESSAGE_LENGTH - 1, &len ), BACKSQL_SUCCESS( rc ); )
{
Debug( LDAP_DEBUG_TRACE,
" Native error code: %d\n"
" SQL engine state: %s\n"
" Message: %s\n",
(int)iSqlCode, state, msg );
" nativeErrCode=%d SQLengineState=%s msg=\"%s\"\n",
(int)iSqlCode, state, msg );
}
}
......@@ -163,12 +162,26 @@ backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx )
row->col_names = (BerVarray)ber_memcalloc_x( row->ncols + 1,
sizeof( struct berval ), ctx );
if ( !row->col_names ) goto nomem3;
row->cols = (char **)ber_memcalloc_x( row->ncols + 1,
sizeof( char * ), ctx );
if ( !row->cols ) goto nomem2;
row->col_prec = (UDWORD *)ber_memcalloc_x( row->ncols,
sizeof( UDWORD ), ctx );
if ( !row->col_prec ) goto nomem1;
row->value_len = (SQLINTEGER *)ber_memcalloc_x( row->ncols,
sizeof( SQLINTEGER ), ctx );
if ( !row->value_len ) {
ber_memfree_x( row->col_prec, ctx );
row->col_prec = NULL;
nomem1: ber_memfree_x( row->cols, ctx );
row->cols = NULL;
nomem2: ber_memfree_x( row->col_names, ctx );
row->col_names = NULL;
nomem3: Debug( LDAP_DEBUG_ANY, "backsql_BindRowAsStrings: "
"out of memory\n", 0, 0, 0 );
return LDAP_NO_MEMORY;
}
for ( i = 1; i <= row->ncols; i++ ) {
rc = SQLDescribeCol( sth, (SQLSMALLINT)i, &colname[ 0 ],
(SQLUINTEGER)( sizeof( colname ) - 1 ),
......
......@@ -382,6 +382,15 @@ objectClass: dcObject
o: Example
dc: example
# Testing undefined attribute in filter...
# refldap://localhost:9012/dc=example,dc=com??sub
dn: dc=example,dc=com
objectClass: organization
objectClass: dcObject
o: Example
dc: example
# Testing objectClass inheritance in filter...
dn: cn=Mitya Kovalev,dc=example,dc=com
objectClass: inetOrgPerson
......
......@@ -326,6 +326,19 @@ if test $RC != 0 ; then
exit $RC
fi
# ITS#4604
echo "Testing undefined attribute in filter..."
echo "# Testing undefined attribute in filter..." >> $SEARCHOUT
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
"(|(o=example)(foobar=x))" >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
echo "Testing objectClass inheritance in filter..."
echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment