/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2005-2007 The OpenLDAP Foundation.
+ * Copyright 2005-2012 The OpenLDAP Foundation.
* Portions Copyright 2005-2006 SysNet s.n.c.
* All rights reserved.
*
int rc;
char *extra = "";
- connection_fake_init( &conn, &opbuf, ctx );
+ connection_fake_init2( &conn, &opbuf, ctx, 0 );
op = &opbuf.ob_op;
op->o_tag = LDAP_REQ_SEARCH;
op->ors_slimit = SLAP_NO_LIMIT;
op->ors_attrs = slap_anlist_no_attrs;
- expire = slap_get_time() + di->di_tolerance;
+ expire = slap_get_time() - di->di_tolerance;
ts.bv_val = tsbuf;
ts.bv_len = sizeof( tsbuf );
slap_timestamp( &expire, &ts );
done_search:;
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
- filter_free_x( op, op->ors_filter );
+ filter_free_x( op, op->ors_filter, 1 );
rc = rs.sr_err;
switch ( rs.sr_err ) {
de->de_ndn.bv_val, rs.sr_err );
break;
}
-
+
if ( de != NULL ) {
*dep = de->de_next;
- dep = &de->de_next;
op->o_tmpfree( de, op->o_tmpmemctx );
}
}
}
} else if ( mod->sml_desc == slap_schema.si_ad_entryTtl ) {
- unsigned long ttl;
+ unsigned long uttl;
+ time_t ttl;
int rc;
switch ( mod->sml_op ) {
case LDAP_MOD_DELETE:
+ case SLAP_MOD_SOFTDEL: /* FIXME? */
if ( mod->sml_values != NULL ) {
if ( BER_BVISEMPTY( &bv_entryTtl )
|| !bvmatch( &bv_entryTtl, &mod->sml_values[ 0 ] ) )
entryTtl = -1;
/* fallthru */
- case SLAP_MOD_SOFTADD: /* FIXME? */
case LDAP_MOD_ADD:
+ case SLAP_MOD_SOFTADD: /* FIXME? */
+ case SLAP_MOD_ADD_IF_NOT_PRESENT: /* FIXME? */
assert( mod->sml_values != NULL );
assert( BER_BVISNULL( &mod->sml_values[ 1 ] ) );
goto done;
}
- rc = lutil_atoul( &ttl, mod->sml_values[ 0 ].bv_val );
+ rc = lutil_atoul( &uttl, mod->sml_values[ 0 ].bv_val );
+ ttl = (time_t)uttl;
assert( rc == 0 );
if ( ttl > DDS_RF2589_MAX_TTL ) {
rs->sr_err = LDAP_PROTOCOL_ERROR;
goto done;
}
- entryTtl = (time_t)ttl;
+ entryTtl = ttl;
bv_entryTtl.bv_len = mod->sml_values[ 0 ].bv_len;
AC_MEMCPY( bv_entryTtl.bv_val, mod->sml_values[ 0 ].bv_val, bv_entryTtl.bv_len );
bv_entryTtl.bv_val[ bv_entryTtl.bv_len ] = '\0';
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
- if ( rs->sr_err == LDAP_SUCCESS ) {
- ber_init_w_nullc( ber, LBER_USE_DER );
+ ber_init_w_nullc( ber, LBER_USE_DER );
- rc = ber_printf( ber, "{tiN}", LDAP_TAG_EXOP_REFRESH_RES_TTL, (int)ttl );
+ rc = ber_printf( ber, "{tiN}", LDAP_TAG_EXOP_REFRESH_RES_TTL, (int)ttl );
- if ( rc < 0 ) {
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "internal error";
-
- } else {
- (void)ber_flatten( ber, &rs->sr_rspdata );
- rs->sr_rspoid = ch_strdup( slap_EXOP_REFRESH.bv_val );
+ if ( rc < 0 ) {
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "internal error";
- Log3( LDAP_DEBUG_TRACE, LDAP_LEVEL_INFO,
- "%s REFRESH dn=\"%s\" TTL=%ld\n",
- op->o_log_prefix, op->o_req_ndn.bv_val, ttl );
- }
+ } else {
+ (void)ber_flatten( ber, &rs->sr_rspdata );
+ rs->sr_rspoid = ch_strdup( slap_EXOP_REFRESH.bv_val );
- ber_free_buf( ber );
+ Log3( LDAP_DEBUG_TRACE, LDAP_LEVEL_INFO,
+ "%s REFRESH dn=\"%s\" TTL=%ld\n",
+ op->o_log_prefix, op->o_req_ndn.bv_val, ttl );
}
+
+ ber_free_buf( ber );
}
return rs->sr_err;
if ( t < DDS_RF2589_DEFAULT_TTL || t > DDS_RF2589_MAX_TTL ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
- "DDS invalid dds-max-ttl=%ld; must be between %d and %d",
+ "DDS invalid dds-max-ttl=%lu; must be between %d and %d",
t, DDS_RF2589_DEFAULT_TTL, DDS_RF2589_MAX_TTL );
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
"%s: %s.\n", c->log, c->cr_msg );
return 1;
}
- if ( t < 0 || t > DDS_RF2589_MAX_TTL ) {
+ if ( t > DDS_RF2589_MAX_TTL ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
- "DDS invalid dds-min-ttl=%ld",
+ "DDS invalid dds-min-ttl=%lu",
t );
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
"%s: %s.\n", c->log, c->cr_msg );
return 1;
}
- if ( t < 0 || t > DDS_RF2589_MAX_TTL ) {
+ if ( t > DDS_RF2589_MAX_TTL ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
- "DDS invalid dds-default-ttl=%ld",
+ "DDS invalid dds-default-ttl=%lu",
t );
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
"%s: %s.\n", c->log, c->cr_msg );
if ( t <= 0 ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
- "DDS invalid dds-interval=%ld",
+ "DDS invalid dds-interval=%lu",
t );
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
"%s: %s.\n", c->log, c->cr_msg );
return 1;
}
- if ( t < 0 || t > DDS_RF2589_MAX_TTL ) {
+ if ( t > DDS_RF2589_MAX_TTL ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
- "DDS invalid dds-tolerance=%ld",
+ "DDS invalid dds-tolerance=%lu",
t );
Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
"%s: %s.\n", c->log, c->cr_msg );
int rc;
char *extra = "";
- connection_fake_init( &conn, &opbuf, ctx );
+ connection_fake_init2( &conn, &opbuf, ctx, 0 );
op = &opbuf.ob_op;
op->o_tag = LDAP_REQ_SEARCH;
done_search:;
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
- filter_free_x( op, op->ors_filter );
+ filter_free_x( op, op->ors_filter, 1 );
rc = rs.sr_err;
switch ( rs.sr_err ) {
int rc = 0;
void *thrctx = ldap_pvt_thread_pool_context();
+ if ( slapMode & SLAP_TOOL_MODE )
+ return 0;
+
if ( DDS_OFF( di ) ) {
goto done;
}
op->o_req_dn = op->o_req_ndn;
op->o_bd = select_backend( &op->o_req_ndn, 0 );
+ if ( op->o_bd == NULL ) {
+ send_ldap_error( op, rs, LDAP_NO_SUCH_OBJECT,
+ "no global superior knowledge" );
+ goto done;
+ }
+
if ( !SLAP_DYNAMIC( op->o_bd ) ) {
send_ldap_error( op, rs, LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
"backend does not support dynamic directory services" );