char *grpoc;
char *grpat;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *grpad;
+ AttributeDescription *grpad = NULL;
char *text;
#else
char *grpad;
Attribute *at;
char *dnattr = aci_bvstrdup(&sdn);
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *dnad;
+ AttributeDescription *dnad = NULL;
char *text;
rc = slap_str2ad( dnattr, &dnad, &text );
ch_free( dnattr );
struct berval *vals[2];
AttributeType *at;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *ad_attributeTypes = slap_schema.si_ad_attributeTypes;
+#else
+ char *ad_attributeTypes = "attributeTypes";
+#endif
+
vals[0] = &val;
vals[1] = NULL;
for ( at = attr_list; at; at = at->sat_next ) {
val.bv_val = ldap_attributetype2str( &at->sat_atype );
- if ( val.bv_val ) {
- val.bv_len = strlen( val.bv_val );
- Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
- attr_merge( e, "attributeTypes", vals );
- ldap_memfree( val.bv_val );
- } else {
+ if ( val.bv_val == NULL ) {
return -1;
}
+ val.bv_len = strlen( val.bv_val );
+ Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n",
+ (long) val.bv_len, val.bv_val, 0 );
+ attr_merge( e, ad_attributeTypes, vals );
+ ldap_memfree( val.bv_val );
}
return 0;
}
ber_len_t len;
int err;
Filter *f;
- char *ftmp;
+ char *ftmp = NULL;
Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 );
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
-
*fstr = ch_malloc( sizeof("(<=)")
+ f->f_av_desc->ad_cname->bv_len
+ f->f_av_value->bv_len );
+ f->f_desc->ad_cname->bv_len );
sprintf( *fstr, "(%s=*)",
f->f_desc->ad_cname->bv_val );
+
#else
f->f_type = type.bv_val;
err = LDAP_SUCCESS;
if ( err != LDAP_SUCCESS ) {
break;
}
- if (ftmp == NULL) ftmp = ch_strdup("");
- *fstr = ch_malloc( 4 + strlen( ftmp ) );
- sprintf( *fstr, "(&%s)", ftmp );
- free( ftmp );
+ *fstr = ch_malloc( sizeof("(&)")
+ + ( ftmp == NULL ? 0 : strlen( ftmp ) ) );
+ sprintf( *fstr, "(&%s)",
+ ftmp == NULL ? "" : ftmp );
break;
case LDAP_FILTER_OR:
if ( err != LDAP_SUCCESS ) {
break;
}
- if (ftmp == NULL) ftmp = ch_strdup("");
- *fstr = ch_malloc( 4 + strlen( ftmp ) );
- sprintf( *fstr, "(|%s)", ftmp );
- free( ftmp );
+ *fstr = ch_malloc( sizeof("(!)")
+ + ( ftmp == NULL ? 0 : strlen( ftmp ) ) );
+ sprintf( *fstr, "(|%s)",
+ ftmp == NULL ? "" : ftmp );
break;
case LDAP_FILTER_NOT:
if ( err != LDAP_SUCCESS ) {
break;
}
- if (ftmp == NULL) ftmp = ch_strdup("");
- *fstr = ch_malloc( 4 + strlen( ftmp ) );
- sprintf( *fstr, "(!%s)", ftmp );
- free( ftmp );
+ *fstr = ch_malloc( sizeof("(!)")
+ + ( ftmp == NULL ? 0 : strlen( ftmp ) ) );
+ sprintf( *fstr, "(!%s)",
+ ftmp == NULL ? "" : ftmp );
break;
case LDAP_FILTER_EXT:
/* not yet implemented */
Debug( LDAP_DEBUG_ANY, "extensible match not yet implemented.\n",
f->f_choice, 0, 0 );
- err = LDAP_PROTOCOL_ERROR;
- *text = "extensible match not yet implemented";
+ f->f_choice = SLAPD_FILTER_COMPUTED;
+ f->f_result = SLAPD_COMPARE_UNDEFINED;
+ *fstr = ch_strdup( "(extended)" );
break;
default:
Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n",
f->f_choice, 0, 0 );
- err = LDAP_PROTOCOL_ERROR;
- *text = "unknown filter type";
+ f->f_choice = SLAPD_FILTER_COMPUTED;
+ f->f_result = SLAPD_COMPARE_UNDEFINED;
+ *fstr = ch_strdup( "(undefined)" );
break;
}
*filt = f;
}
+ free( ftmp );
+
Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 );
return( err );
}
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
#else
- fprintf( stderr, "(%s=%s)", f->f_ava.ava_type,
+ fprintf( stderr, "(%s=%s)",
+ f->f_ava.ava_type,
f->f_ava.ava_value.bv_val );
#endif
break;
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
#else
- fprintf( stderr, "(%s>=%s)", f->f_ava.ava_type,
+ fprintf( stderr, "(%s>=%s)",
+ f->f_ava.ava_type,
f->f_ava.ava_value.bv_val );
#endif
break;
f->f_ava->aa_desc->ad_cname->bv_val,
f->f_ava->aa_value->bv_val );
#else
- fprintf( stderr, "(%s<=%s)", f->f_ava.ava_type,
+ fprintf( stderr, "(%s<=%s)",
+ f->f_ava.ava_type,
f->f_ava.ava_value.bv_val );
#endif
break;
f->f_ava->aa_desc->ad_cname->bv_val,
f->f_ava->aa_value->bv_val );
#else
- fprintf( stderr, "(%s~=%s)", f->f_ava.ava_type,
+ fprintf( stderr, "(%s~=%s)",
+ f->f_ava.ava_type,
f->f_ava.ava_value.bv_val );
#endif
break;
fprintf( stderr, "(%s=" /*)*/,
f->f_sub_desc->ad_cname->bv_val );
#else
- fprintf( stderr, "(%s=" /*)*/, f->f_sub_type );
+ fprintf( stderr, "(%s=" /*)*/,
+ f->f_sub_type );
#endif
if ( f->f_sub_initial != NULL ) {
- fprintf( stderr, "%s", f->f_sub_initial->bv_val );
+ fprintf( stderr, "%s",
+ f->f_sub_initial->bv_val );
}
if ( f->f_sub_any != NULL ) {
for ( i = 0; f->f_sub_any[i] != NULL; i++ ) {
- fprintf( stderr, "*%s", f->f_sub_any[i]->bv_val );
+ fprintf( stderr, "*%s",
+ f->f_sub_any[i]->bv_val );
}
}
if ( f->f_sub_final != NULL ) {
- fprintf( stderr, "*%s", f->f_sub_final->bv_val );
+ fprintf( stderr,
+ "*%s", f->f_sub_final->bv_val );
}
fprintf( stderr, /*(*/ ")" );
break;
fprintf( stderr, "(%s=*)",
f->f_desc->ad_cname->bv_val );
#else
- fprintf( stderr, "(%s=*)", f->f_type );
+ fprintf( stderr, "(%s=*)",
+ f->f_type );
#endif
break;
break;
case SLAPD_FILTER_COMPUTED:
- fprintf( stderr, "(%s)",
+ fprintf( stderr, "(?=%s)",
f->f_result == LDAP_COMPARE_FALSE ? "false" :
f->f_result == LDAP_COMPARE_TRUE ? "true" :
f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" :
break;
default:
- fprintf( stderr, "(unknown filter %lu)", f->f_choice );
+ fprintf( stderr, "(unknown-filter=%lu)", f->f_choice );
break;
}
}
for( ; ml != NULL; ml = ml->ml_next ) {
Modifications *mod;
- AttributeDescription *ad;
+ AttributeDescription *ad = NULL;
mod = (Modifications *)
ch_calloc( 1, sizeof(Modifications) );
char timebuf[22];
struct tm *ltm;
Modifications *mod;
- AttributeDescription *ad;
int mop = op->o_tag == LDAP_REQ_ADD
? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
}
if( op->o_tag == LDAP_REQ_ADD ) {
- rc = slap_str2ad( "creatorsName", &ad, text );
- if( rc == LDAP_SUCCESS ) {
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_desc = ad;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( &name );
- mod->sml_bvalues[1] = NULL;
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
-
- rc = slap_str2ad( "createTimeStamp", &ad, text );
- if( rc == LDAP_SUCCESS ) {
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_desc = ad;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( ×tamp );
- mod->sml_bvalues[1] = NULL;
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
-
- rc = slap_str2ad( "modifiersName", &ad, text );
- if( rc == LDAP_SUCCESS ) {
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
- mod->sml_desc = ad;
+ mod->sml_desc = slap_schema.si_ad_creatorsName;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
mod->sml_bvalues[0] = ber_bvdup( &name );
mod->sml_bvalues[1] = NULL;
+
*modtail = mod;
modtail = &mod->sml_next;
- }
- rc = slap_str2ad( "modifyTimeStamp", &ad, text );
- if( rc == LDAP_SUCCESS ) {
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
- mod->sml_desc = ad;
+ mod->sml_desc = slap_schema.si_ad_createTimestamp;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
mod->sml_bvalues[0] = ber_bvdup( ×tamp );
mod->sml_bvalues[1] = NULL;
modtail = &mod->sml_next;
}
+ mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod->sml_op = mop;
+ mod->sml_desc = slap_schema.si_ad_modifiersName;
+ mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
+ mod->sml_bvalues[0] = ber_bvdup( &name );
+ mod->sml_bvalues[1] = NULL;
+ *modtail = mod;
+ modtail = &mod->sml_next;
+
+ mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod->sml_op = mop;
+ mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
+ mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
+ mod->sml_bvalues[0] = ber_bvdup( ×tamp );
+ mod->sml_bvalues[1] = NULL;
+ *modtail = mod;
+ modtail = &mod->sml_next;
+
return LDAP_SUCCESS;
}
struct berval *vals[2];
MatchingRule *mr;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *ad_matchingRules = slap_schema.si_ad_matchingRules;
+#else
+ char *ad_matchingRules = "matchingRules";
+#endif
+
vals[0] = &val;
vals[1] = NULL;
for ( mr = mr_list; mr; mr = mr->smr_next ) {
val.bv_val = ldap_matchingrule2str( &mr->smr_mrule );
- if ( val.bv_val ) {
- val.bv_len = strlen( val.bv_val );
- Debug( LDAP_DEBUG_TRACE, "Merging mr [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
- attr_merge( e, "matchingRules", vals );
- ldap_memfree( val.bv_val );
- } else {
+
+ if ( val.bv_val == NULL ) {
return -1;
}
+
+ val.bv_len = strlen( val.bv_val );
+ Debug( LDAP_DEBUG_TRACE, "Merging mr [%ld] %s\n",
+ (long) val.bv_len, val.bv_val, 0 );
+ attr_merge( e, ad_matchingRules, vals );
+ ldap_memfree( val.bv_val );
}
return 0;
}
Attribute *attr;
struct berval bv;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- static AttributeDescription *objectClass = NULL;
+ AttributeDescription *objectClass = slap_schema.si_ad_objectClass;
#else
static const char *objectClass = "objectclass";
#endif
struct berval *vals[2];
ObjectClass *oc;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *ad_objectClasses = slap_schema.si_ad_objectClasses;
+#else
+ char *ad_objectClasses = "objectClasses";
+#endif
+
vals[0] = &val;
vals[1] = NULL;
for ( oc = oc_list; oc; oc = oc->soc_next ) {
val.bv_val = ldap_objectclass2str( &oc->soc_oclass );
- if ( val.bv_val ) {
- val.bv_len = strlen( val.bv_val );
- Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
- attr_merge( e, "objectClasses", vals );
- ldap_memfree( val.bv_val );
- } else {
+ if ( val.bv_val == NULL ) {
return -1;
}
+ val.bv_len = strlen( val.bv_val );
+ Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
+ (long) val.bv_len, val.bv_val, 0 );
+ attr_merge( e, ad_objectClasses, vals );
+ ldap_memfree( val.bv_val );
}
return 0;
}
unsigned i, j;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- static AttributeDescription *ref = NULL;
+ AttributeDescription *ref = slap_schema.si_ad_ref;
#else
static const char *ref = "ref";
#endif
int bytes;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- static AttributeDescription *ref = NULL;
- static AttributeDescription *entry = NULL;
+ AttributeDescription *ref = slap_schema.si_ad_ref;
+ AttributeDescription *entry = slap_schema.si_ad_entry;
#else
static const char *ref = "ref";
static const char *entry = "entry";
void
schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
{
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
+#else
+ char *ad_objectClass = "objectClass";
+#endif
+
Entry *e;
struct berval val;
struct berval *vals[2];
(void) dn_normalize( e->e_ndn );
e->e_private = NULL;
+ val.bv_val = "top";
+ val.bv_len = sizeof("top")-1;
+ attr_merge( e, ad_objectClass, vals );
+
+ val.bv_val = "LDAPsubentry";
+ val.bv_len = sizeof("LDAPsubentry")-1;
+ attr_merge( e, ad_objectClass, vals );
+
+ val.bv_val = "subschema";
+ val.bv_len = sizeof("subschema")-1;
+ attr_merge( e, ad_objectClass, vals );
+
+ val.bv_val = "extensibleObject";
+ val.bv_len = sizeof("extensibleObject")-1;
+ attr_merge( e, ad_objectClass, vals );
+
{
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ int rc;
+ char *text;
+ AttributeDescription *desc = NULL;
+#else
+ char *desc;
+#endif
char *rdn = ch_strdup( SLAPD_SCHEMA_DN );
val.bv_val = strchr( rdn, '=' );
- if( val.bv_val != NULL ) {
- *val.bv_val = '\0';
- val.bv_len = strlen( ++val.bv_val );
+ if( val.bv_val == NULL ) {
+ send_ldap_result( conn, op, LDAP_OTHER,
+ NULL, "improperly configured subschema subentry",
+ NULL, NULL );
+ free( rdn );
+ return;
+ }
- attr_merge( e, rdn, vals );
+ *val.bv_val = '\0';
+ val.bv_len = strlen( ++val.bv_val );
+
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ rc = slap_str2ad( rdn, &desc, &text );
+
+ if( rc != LDAP_SUCCESS ) {
+ send_ldap_result( conn, op, LDAP_OTHER,
+ NULL, "improperly configured subschema subentry",
+ NULL, NULL );
+ free( rdn );
+ return;
}
+#else
+ desc = rdn;
+#endif
+ attr_merge( e, desc, vals );
free( rdn );
}
return;
}
- val.bv_val = "top";
- val.bv_len = sizeof("top")-1;
- attr_merge( e, "objectClass", vals );
-
- val.bv_val = "LDAPsubentry";
- val.bv_len = sizeof("LDAPsubentry")-1;
- attr_merge( e, "objectClass", vals );
-
- val.bv_val = "subschema";
- val.bv_len = sizeof("subschema")-1;
- attr_merge( e, "objectClass", vals );
-
- val.bv_val = "extensibleObject";
- val.bv_len = sizeof("extensibleObject")-1;
- attr_merge( e, "objectClass", vals );
-
send_search_entry( &backends[0], conn, op,
e, attrs, attrsonly, NULL );
send_search_result( conn, op, LDAP_SUCCESS,
int i;
int ret;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- static AttributeDescription *objectClass = NULL;
+ AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
#else
- static const char *objectClass = "objectclass";
+ static const char *ac_objectClass = "objectclass";
#endif
if( !global_schemacheck ) return LDAP_SUCCESS;
/* find the object class attribute - could error out here */
- if ( (aoc = attr_find( e->e_attrs, objectClass )) == NULL ) {
+ if ( (aoc = attr_find( e->e_attrs, ad_objectClass )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n",
e->e_dn, 0, 0 );
{ "supportedSASLMechanisms",
offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
+ { "attributeTypes",
+ offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
+ { "ldapSyntaxes",
+ offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
+ { "matchingRules",
+ offsetof(struct slap_internal_schema, si_ad_matchingRules) },
+ { "objectClasses",
+ offsetof(struct slap_internal_schema, si_ad_objectClasses) },
+
{ "ref",
offsetof(struct slap_internal_schema, si_ad_ref) },
if ( scope == LDAP_SCOPE_BASE ) {
#if defined( SLAPD_MONITOR_DN )
- if ( strcmp( nbase, SLAPD_MONITOR_DN ) == 0 ) {
+ if ( strcasecmp( nbase, SLAPD_MONITOR_DN ) == 0 ) {
monitor_info( conn, op, attrs, attrsonly );
goto return_results;
}
#endif
#if defined( SLAPD_CONFIG_DN )
- if ( strcmp( nbase, SLAPD_CONFIG_DN ) == 0 ) {
+ if ( strcasecmp( nbase, SLAPD_CONFIG_DN ) == 0 ) {
config_info( conn, op, attrs, attrsonly );
goto return_results;
}
#endif
#if defined( SLAPD_SCHEMA_DN )
- if ( strcmp( nbase, SLAPD_SCHEMA_DN ) == 0 ) {
+ if ( strcasecmp( nbase, SLAPD_SCHEMA_DN ) == 0 ) {
schema_info( conn, op, attrs, attrsonly );
goto return_results;
}
#endif
- if ( strcmp( nbase, LDAP_ROOT_DSE ) == 0 ) {
+ if ( strcasecmp( nbase, LDAP_ROOT_DSE ) == 0 ) {
root_dse_info( conn, op, attrs, attrsonly );
goto return_results;
}
struct berval *vals[2];
Syntax *syn;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *ad_ldapSyntaxes = slap_schema.si_ad_ldapSyntaxes;
+#else
+ char *ad_ldapSyntaxes = "ldapSyntaxes";
+#endif
+
vals[0] = &val;
vals[1] = NULL;
for ( syn = syn_list; syn; syn = syn->ssyn_next ) {
val.bv_val = ldap_syntax2str( &syn->ssyn_syn );
- if ( val.bv_val ) {
- val.bv_len = strlen( val.bv_val );
- Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
- attr_merge( e, "ldapSyntaxes", vals );
- ldap_memfree( val.bv_val );
- } else {
+ if ( val.bv_val == NULL ) {
return -1;
}
+ val.bv_len = strlen( val.bv_val );
+ Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n",
+ (long) val.bv_len, val.bv_val, 0 );
+ attr_merge( e, ad_ldapSyntaxes, vals );
+ ldap_memfree( val.bv_val );
}
return 0;
}