Commit 37235b71 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

SLAPD_SCHEMA_NOT_COMPAT: working cn=schema

parent aa08287e
......@@ -984,7 +984,7 @@ aci_group_member (
char *grpoc;
char *grpat;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *grpad;
AttributeDescription *grpad = NULL;
char *text;
#else
char *grpad;
......@@ -1133,7 +1133,7 @@ aci_mask(
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 );
......
......@@ -554,20 +554,25 @@ at_schema_info( Entry *e )
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;
}
......
......@@ -39,7 +39,7 @@ get_filter(
ber_len_t len;
int err;
Filter *f;
char *ftmp;
char *ftmp = NULL;
Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 );
......@@ -157,7 +157,6 @@ get_filter(
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
*fstr = ch_malloc( sizeof("(<=)")
+ f->f_av_desc->ad_cname->bv_len
+ f->f_av_value->bv_len );
......@@ -205,6 +204,7 @@ get_filter(
+ 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;
......@@ -247,10 +247,10 @@ get_filter(
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:
......@@ -259,10 +259,10 @@ get_filter(
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:
......@@ -272,25 +272,27 @@ get_filter(
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;
}
......@@ -303,6 +305,8 @@ get_filter(
*filt = f;
}
free( ftmp );
Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 );
return( err );
}
......@@ -599,7 +603,8 @@ filter_print( Filter *f )
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;
......@@ -610,7 +615,8 @@ filter_print( Filter *f )
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;
......@@ -621,7 +627,8 @@ filter_print( Filter *f )
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;
......@@ -632,7 +639,8 @@ filter_print( Filter *f )
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;
......@@ -642,18 +650,22 @@ filter_print( Filter *f )
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;
......@@ -663,7 +675,8 @@ filter_print( Filter *f )
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;
......@@ -680,7 +693,7 @@ filter_print( Filter *f )
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" :
......@@ -688,7 +701,7 @@ filter_print( Filter *f )
break;
default:
fprintf( stderr, "(unknown filter %lu)", f->f_choice );
fprintf( stderr, "(unknown-filter=%lu)", f->f_choice );
break;
}
}
......
......@@ -298,7 +298,7 @@ int slap_modlist2mods(
for( ; ml != NULL; ml = ml->ml_next ) {
Modifications *mod;
AttributeDescription *ad;
AttributeDescription *ad = NULL;
mod = (Modifications *)
ch_calloc( 1, sizeof(Modifications) );
......@@ -384,7 +384,6 @@ int slap_mods_opattrs(
char timebuf[22];
struct tm *ltm;
Modifications *mod;
AttributeDescription *ad;
int mop = op->o_tag == LDAP_REQ_ADD
? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
......@@ -405,49 +404,19 @@ int slap_mods_opattrs(
}
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( &timestamp );
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( &timestamp );
mod->sml_bvalues[1] = NULL;
......@@ -455,6 +424,24 @@ int slap_mods_opattrs(
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( &timestamp );
mod->sml_bvalues[1] = NULL;
*modtail = mod;
modtail = &mod->sml_next;
return LDAP_SUCCESS;
}
......
......@@ -194,20 +194,27 @@ int mr_schema_info( Entry *e )
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;
}
......
......@@ -23,7 +23,7 @@ int is_entry_objectclass(
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
......@@ -440,20 +440,25 @@ oc_schema_info( Entry *e )
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;
}
......
......@@ -129,7 +129,7 @@ struct berval **get_entry_referrals(
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
......@@ -901,8 +901,8 @@ send_search_reference(
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";
......
......@@ -22,6 +22,12 @@
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];
......@@ -37,17 +43,59 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
(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 );
}
......@@ -63,22 +111,6 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
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,
......
......@@ -41,15 +41,15 @@ entry_schema_check(
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 );
......
......@@ -650,6 +650,15 @@ struct slap_schema_ad_map {
{ "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) },
......
......@@ -161,27 +161,27 @@ do_search(
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;
}
......
......@@ -161,20 +161,25 @@ syn_schema_info( Entry *e )
struct berval *vals[2];
Syntax *syn;
#ifdef SLAPD_SCHEMA_NOT_COMPAT