Back to index

openldap  2.4.31
Classes | Defines | Functions | Variables
schema_prep.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"

Go to the source code of this file.

Classes

struct  slap_schema_oc_map
struct  slap_schema_ad_map
struct  slap_schema_mr_map
struct  slap_schema_syn_map

Defines

#define OCDEBUG   0
#define objectSubClassFilter   octetStringFilter

Functions

static int oidValidate (Syntax *syntax, struct berval *in)
static int objectClassPretty (Syntax *syntax, struct berval *in, struct berval *out, void *ctx)
static int attributeTypeMatch (int *matchp, slap_mask_t flags, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue)
static int matchingRuleMatch (int *matchp, slap_mask_t flags, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue)
static int objectClassMatch (int *matchp, slap_mask_t flags, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue)
static int objectSubClassMatch (int *matchp, slap_mask_t flags, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue)
static int objectSubClassIndexer (slap_mask_t use, slap_mask_t mask, Syntax *syntax, MatchingRule *mr, struct berval *prefix, BerVarray values, BerVarray *keysp, void *ctx)
int slap_schema_load (void)
int slap_schema_check (void)
static int rootDseObjectClass (Backend *be, Entry *e, ObjectClass *oc, const char **text, char *textbuf, size_t textlen)
static int aliasObjectClass (Backend *be, Entry *e, ObjectClass *oc, const char **text, char *textbuf, size_t textlen)
static int referralObjectClass (Backend *be, Entry *e, ObjectClass *oc, const char **text, char *textbuf, size_t textlen)
static int subentryObjectClass (Backend *be, Entry *e, ObjectClass *oc, const char **text, char *textbuf, size_t textlen)
static int dynamicObjectClass (Backend *be, Entry *e, ObjectClass *oc, const char **text, char *textbuf, size_t textlen)
static int rootDseAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)
static int aliasAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)
static int referralAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)
static int subentryAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)
static int administrativeRoleAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)
static int dynamicAttribute (Backend *be, Entry *e, Attribute *attr, const char **text, char *textbuf, size_t textlen)

Variables

int schema_init_done = 0
static ObjectClassSchemaCheckFN rootDseObjectClass
static ObjectClassSchemaCheckFN aliasObjectClass
static ObjectClassSchemaCheckFN referralObjectClass
static ObjectClassSchemaCheckFN subentryObjectClass
static ObjectClassSchemaCheckFN dynamicObjectClass
static struct slap_schema_oc_map oc_map []
static AttributeTypeSchemaCheckFN rootDseAttribute
static AttributeTypeSchemaCheckFN aliasAttribute
static AttributeTypeSchemaCheckFN referralAttribute
static AttributeTypeSchemaCheckFN subentryAttribute
static AttributeTypeSchemaCheckFN administrativeRoleAttribute
static AttributeTypeSchemaCheckFN dynamicAttribute
static struct slap_schema_ad_map ad_map []
static AttributeType slap_at_undefined
static AttributeType slap_at_proxied
static struct slap_schema_mr_map mr_map []
static struct slap_schema_syn_map syn_map []

Class Documentation

struct slap_schema_oc_map

Definition at line 323 of file schema_prep.c.

Class Members
ObjectClassSchemaCheckFN * ssom_check
char * ssom_defn
slap_mask_t ssom_flags
char * ssom_name
size_t ssom_offset
struct slap_schema_ad_map

Definition at line 422 of file schema_prep.c.

Class Members
AttributeTypeSchemaCheckFN * ssam_check
char * ssam_defn
slap_mask_t ssam_flags
slap_mr_convert_func * ssam_mr_convert
slap_mr_filter_func * ssam_mr_filter
slap_mr_indexer_func * ssam_mr_indexer
slap_mr_match_func * ssam_mr_match
slap_mr_normalize_func * ssam_mr_normalize
char * ssam_name
size_t ssam_offset
slap_syntax_transform_func * ssam_syn_pretty
slap_syntax_validate_func * ssam_syn_validate
struct slap_schema_mr_map

Definition at line 1051 of file schema_prep.c.

Class Members
char * ssmm_name
size_t ssmm_offset
struct slap_schema_syn_map

Definition at line 1086 of file schema_prep.c.

Class Members
char * sssm_name
size_t sssm_offset

Define Documentation

Definition at line 313 of file schema_prep.c.

#define OCDEBUG   0

Definition at line 27 of file schema_prep.c.


Function Documentation

static int administrativeRoleAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1566 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_SUBENTRIES(be) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" not supported in context",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       snprintf( textbuf, textlen,
              "attribute \"%s\" not supported!",
              attr->a_desc->ad_cname.bv_val );
       return LDAP_OBJECT_CLASS_VIOLATION;
}
static int aliasAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1488 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_ALIASES(be) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" not supported in context",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       if( !is_entry_alias( e ) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" only allowed in the alias",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int aliasObjectClass ( Backend be,
Entry e,
ObjectClass oc,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1382 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_ALIASES(be) ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" not supported in context",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int attributeTypeMatch ( int matchp,
slap_mask_t  flags,
Syntax syntax,
MatchingRule mr,
struct berval value,
void assertedValue 
) [static]

Definition at line 105 of file schema_prep.c.

{
       struct berval *a = (struct berval *) assertedValue;
       AttributeType *at = at_bvfind( value );
       AttributeType *asserted = at_bvfind( a );

       if( asserted == NULL ) {
              if( OID_LEADCHAR( *a->bv_val ) ) {
                     /* OID form, return FALSE */
                     *matchp = 1;
                     return LDAP_SUCCESS;
              }

              /* desc form, return undefined */
              return LDAP_INVALID_SYNTAX;
       }

       if ( at == NULL ) {
              /* unrecognized stored value */
              return LDAP_INVALID_SYNTAX;
       }

       *matchp = ( asserted != at );
       return LDAP_SUCCESS;
}

Here is the call graph for this function:

static int dynamicAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1589 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_DYNAMIC(be) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" not supported in context",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       if( !is_entry_dynamicObject( e ) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" only allowed in dynamic object",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int dynamicObjectClass ( Backend be,
Entry e,
ObjectClass oc,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1447 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_DYNAMIC(be) ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" not supported in context",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int matchingRuleMatch ( int matchp,
slap_mask_t  flags,
Syntax syntax,
MatchingRule mr,
struct berval value,
void assertedValue 
) [static]

Definition at line 138 of file schema_prep.c.

{
       struct berval *a = (struct berval *) assertedValue;
       MatchingRule *mrv = mr_bvfind( value );
       MatchingRule *asserted = mr_bvfind( a );

       if( asserted == NULL ) {
              if( OID_LEADCHAR( *a->bv_val ) ) {
                     /* OID form, return FALSE */
                     *matchp = 1;
                     return LDAP_SUCCESS;
              }

              /* desc form, return undefined */
              return LDAP_INVALID_SYNTAX;
       }

       if ( mrv == NULL ) {
              /* unrecognized stored value */
              return LDAP_INVALID_SYNTAX;
       }

       *matchp = ( asserted != mrv );
       return LDAP_SUCCESS;
}

Here is the call graph for this function:

static int objectClassMatch ( int matchp,
slap_mask_t  flags,
Syntax syntax,
MatchingRule mr,
struct berval value,
void assertedValue 
) [static]

Definition at line 171 of file schema_prep.c.

{
       struct berval *a = (struct berval *) assertedValue;
       ObjectClass *oc = oc_bvfind( value );
       ObjectClass *asserted = oc_bvfind( a );

       if( asserted == NULL ) {
              if( OID_LEADCHAR( *a->bv_val ) ) {
                     /* OID form, return FALSE */
                     *matchp = 1;
                     return LDAP_SUCCESS;
              }

              /* desc form, return undefined */
              return LDAP_INVALID_SYNTAX;
       }

       if ( oc == NULL ) {
              /* unrecognized stored value */
              return LDAP_INVALID_SYNTAX;
       }

       *matchp = ( asserted != oc );
       return LDAP_SUCCESS;
}

Here is the call graph for this function:

static int objectClassPretty ( Syntax syntax,
struct berval in,
struct berval out,
void ctx 
) [static]

Definition at line 87 of file schema_prep.c.

{
       ObjectClass *oc;

       if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;

       oc = oc_bvfind( in );
       if( oc == NULL ) return LDAP_INVALID_SYNTAX;

       ber_dupbv_x( out, &oc->soc_cname, ctx );
       return LDAP_SUCCESS;
}

Here is the call graph for this function:

static int objectSubClassIndexer ( slap_mask_t  use,
slap_mask_t  mask,
Syntax syntax,
MatchingRule mr,
struct berval prefix,
BerVarray  values,
BerVarray keysp,
void ctx 
) [static]

Definition at line 241 of file schema_prep.c.

{
       int rc, noc, i;
       BerVarray ocvalues;
       ObjectClass **socs;
       
       for( noc=0; values[noc].bv_val != NULL; noc++ ) {
              /* just count em */;
       }

       /* over allocate */
       socs = slap_sl_malloc( (noc+16) * sizeof( ObjectClass * ), ctx );

       /* initialize */
       for( i=0; i<noc; i++ ) {
              socs[i] = oc_bvfind( &values[i] );
       }

       /* expand values */
       for( i=0; i<noc; i++ ) {
              int j;
              ObjectClass *oc = socs[i];
              if( oc == NULL || oc->soc_sups == NULL ) continue;
              
              for( j=0; oc->soc_sups[j] != NULL; j++ ) {
                     int found = 0;
                     ObjectClass *sup = oc->soc_sups[j];
                     int k;

                     for( k=0; k<noc; k++ ) {
                            if( sup == socs[k] ) {
                                   found++;
                                   break;
                            }
                     }

                     if( !found ) {
                            socs = slap_sl_realloc( socs,
                                   sizeof( ObjectClass * ) * (noc+2), ctx );

                            assert( k == noc );
                            socs[noc++] = sup;
                     }
              }
       }

       ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+1), ctx );
       /* copy values */
       for( i=0; i<noc; i++ ) {
              if ( socs[i] )
                     ocvalues[i] = socs[i]->soc_cname;
              else
                     ocvalues[i] = values[i];
       }
       BER_BVZERO( &ocvalues[i] );

       rc = octetStringIndexer( use, mask, syntax, mr,
              prefix, ocvalues, keysp, ctx );

       slap_sl_free( ocvalues, ctx );
       slap_sl_free( socs, ctx );
       return rc;
}

Here is the call graph for this function:

static int objectSubClassMatch ( int matchp,
slap_mask_t  flags,
Syntax syntax,
MatchingRule mr,
struct berval value,
void assertedValue 
) [static]

Definition at line 204 of file schema_prep.c.

{
       struct berval *a = (struct berval *) assertedValue;
       ObjectClass *oc = oc_bvfind( value );
       ObjectClass *asserted = oc_bvfind( a );

       if( asserted == NULL ) {
              if( OID_LEADCHAR( *a->bv_val ) ) {
                     /* OID form, return FALSE */
                     *matchp = 1;
                     return LDAP_SUCCESS;
              }

              /* desc form, return undefined */
              return LDAP_INVALID_SYNTAX;
       }

       if ( oc == NULL ) {
              /* unrecognized stored value */
              return LDAP_INVALID_SYNTAX;
       }

       if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
              *matchp = ( asserted != oc );
       } else {
              *matchp = !is_object_subclass( asserted, oc );
       }

       return LDAP_SUCCESS;
}

Here is the call graph for this function:

static int oidValidate ( Syntax syntax,
struct berval in 
) [static]

Definition at line 34 of file schema_prep.c.

{
       struct berval val = *in;

       if( val.bv_len == 0 ) {
              /* disallow empty strings */
              return LDAP_INVALID_SYNTAX;
       }

       if( DESC_LEADCHAR( val.bv_val[0] ) ) {
              val.bv_val++;
              val.bv_len--;
              if ( val.bv_len == 0 ) return LDAP_SUCCESS;

              while( DESC_CHAR( val.bv_val[0] ) ) {
                     val.bv_val++;
                     val.bv_len--;

                     if ( val.bv_len == 0 ) return LDAP_SUCCESS;
              }

       } else {
              int sep = 0;
              while( OID_LEADCHAR( val.bv_val[0] ) ) {
                     val.bv_val++;
                     val.bv_len--;

                     if ( val.bv_val[-1] != '0' ) {
                            while ( OID_LEADCHAR( val.bv_val[0] )) {
                                   val.bv_val++;
                                   val.bv_len--;
                            }
                     }

                     if( val.bv_len == 0 ) {
                            if( sep == 0 ) break;
                            return LDAP_SUCCESS;
                     }

                     if( !OID_SEPARATOR( val.bv_val[0] )) break;

                     sep++;
                     val.bv_val++;
                     val.bv_len--;
              }
       }

       return LDAP_INVALID_SYNTAX;
}

Here is the caller graph for this function:

static int referralAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1514 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_REFERRALS(be) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" not supported in context",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       if( !is_entry_referral( e ) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" only allowed in the referral",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int referralObjectClass ( Backend be,
Entry e,
ObjectClass oc,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1401 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_REFERRALS(be) ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" not supported in context",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int rootDseAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1467 of file schema_prep.c.

{
       *text = textbuf;

       if( e->e_nname.bv_len ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" only allowed in the root DSE",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       /* we should not be called for the root DSE */
       assert( 0 );
       return LDAP_SUCCESS;
}
static int rootDseObjectClass ( Backend be,
Entry e,
ObjectClass oc,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1361 of file schema_prep.c.

{
       *text = textbuf;

       if( e->e_nname.bv_len ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" only allowed in the root DSE",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       /* we should not be called for the root DSE */
       assert( 0 );
       return LDAP_SUCCESS;
}

Definition at line 1345 of file schema_prep.c.

{
       /* we should only be called once after schema_init() was called */
       assert( schema_init_done == 1 );

       /*
        * cycle thru attributeTypes to build matchingRuleUse
        */
       if ( matching_rule_use_init() ) {
              return LDAP_OTHER;
       }

       ++schema_init_done;
       return LDAP_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1118 of file schema_prep.c.

{
       int i;

       for( i=0; syn_map[i].sssm_name; i++ ) {
              Syntax ** synp = (Syntax **)
                     &(((char *) &slap_schema)[syn_map[i].sssm_offset]);

              assert( *synp == NULL );

              *synp = syn_find( syn_map[i].sssm_name );

              if( *synp == NULL ) {
                     fprintf( stderr, "slap_schema_load: Syntax: "
                            "No syntax \"%s\" defined in schema\n",
                            syn_map[i].sssm_name );
                     return LDAP_INVALID_SYNTAX;
              }
       }

       for( i=0; mr_map[i].ssmm_name; i++ ) {
              MatchingRule ** mrp = (MatchingRule **)
                     &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);

              assert( *mrp == NULL );

              *mrp = mr_find( mr_map[i].ssmm_name );

              if( *mrp == NULL ) {
                     fprintf( stderr, "slap_schema_load: MatchingRule: "
                            "No matching rule \"%s\" defined in schema\n",
                            mr_map[i].ssmm_name );
                     return LDAP_INAPPROPRIATE_MATCHING;
              }
       }

       slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
       slap_schema.si_at_undefined = &slap_at_undefined;

       slap_at_proxied.sat_equality = mr_find( "octetStringMatch" );
       slap_at_proxied.sat_approx = mr_find( "octetStringMatch" );
       slap_at_proxied.sat_ordering = mr_find( "octetStringOrderingMatch" );
       slap_at_proxied.sat_substr = mr_find( "octetStringSubstringsMatch" );
       slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString;
       slap_schema.si_at_proxied = &slap_at_proxied;

       ldap_pvt_thread_mutex_init( &ad_index_mutex );
       ldap_pvt_thread_mutex_init( &ad_undef_mutex );
       ldap_pvt_thread_mutex_init( &oc_undef_mutex );

       for( i=0; ad_map[i].ssam_name; i++ ) {
              assert( ad_map[i].ssam_defn != NULL );
              {
                     LDAPAttributeType *at;
                     int           code;
                     const char    *err;

                     at = ldap_str2attributetype( ad_map[i].ssam_defn,
                            &code, &err, LDAP_SCHEMA_ALLOW_ALL );
                     if ( !at ) {
                            fprintf( stderr,
                                   "slap_schema_load: AttributeType \"%s\": %s before %s\n",
                                    ad_map[i].ssam_name, ldap_scherr2str(code), err );
                            return code;
                     }

                     if ( at->at_oid == NULL ) {
                            fprintf( stderr, "slap_schema_load: "
                                   "AttributeType \"%s\": no OID\n",
                                   ad_map[i].ssam_name );
                            ldap_attributetype_free( at );
                            return LDAP_OTHER;
                     }

                     code = at_add( at, 0, NULL, NULL, &err );
                     if ( code ) {
                            ldap_attributetype_free( at );
                            fprintf( stderr, "slap_schema_load: AttributeType "
                                   "\"%s\": %s: \"%s\"\n",
                                    ad_map[i].ssam_name, scherr2str(code), err );
                            return code;
                     }
                     ldap_memfree( at );
              }
              {
                     int rc;
                     const char *text;
                     Syntax *syntax = NULL;

                     AttributeDescription ** adp = (AttributeDescription **)
                            &(((char *) &slap_schema)[ad_map[i].ssam_offset]);

                     assert( *adp == NULL );

                     rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
                     if( rc != LDAP_SUCCESS ) {
                            fprintf( stderr, "slap_schema_load: AttributeType \"%s\": "
                                   "not defined in schema\n",
                                   ad_map[i].ssam_name );
                            return rc;
                     }

                     if( ad_map[i].ssam_check ) {
                            /* install check routine */
                            (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
                     }
                     /* install flags */
                     (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;

                     /* install custom syntax routines */
                     if( ad_map[i].ssam_syn_validate ||
                            ad_map[i].ssam_syn_pretty )
                     {
                            Syntax *syn;

                            syntax = (*adp)->ad_type->sat_syntax;

                            syn = ch_malloc( sizeof( Syntax ) );
                            *syn = *syntax;

                            if( ad_map[i].ssam_syn_validate ) {
                                   syn->ssyn_validate = ad_map[i].ssam_syn_validate;
                            }
                            if( ad_map[i].ssam_syn_pretty ) {
                                   syn->ssyn_pretty = ad_map[i].ssam_syn_pretty;
                            }

                            (*adp)->ad_type->sat_syntax = syn;
                     }

                     /* install custom rule routines */
                     if( syntax != NULL ||
                            ad_map[i].ssam_mr_convert ||
                            ad_map[i].ssam_mr_normalize ||
                            ad_map[i].ssam_mr_match ||
                            ad_map[i].ssam_mr_indexer ||
                            ad_map[i].ssam_mr_filter )
                     {
                            MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
                            *mr = *(*adp)->ad_type->sat_equality;

                            if ( syntax != NULL ) {
                                   mr->smr_syntax = (*adp)->ad_type->sat_syntax;
                            }
                            if ( ad_map[i].ssam_mr_convert ) {
                                   mr->smr_convert = ad_map[i].ssam_mr_convert;
                            }
                            if ( ad_map[i].ssam_mr_normalize ) {
                                   mr->smr_normalize = ad_map[i].ssam_mr_normalize;
                            }
                            if ( ad_map[i].ssam_mr_match ) {
                                   mr->smr_match = ad_map[i].ssam_mr_match;
                            }
                            if ( ad_map[i].ssam_mr_indexer ) {
                                   mr->smr_indexer = ad_map[i].ssam_mr_indexer;
                            }
                            if ( ad_map[i].ssam_mr_filter ) {
                                   mr->smr_filter = ad_map[i].ssam_mr_filter;
                            }

                            (*adp)->ad_type->sat_equality = mr;
                     }
              }
       }

       for( i=0; oc_map[i].ssom_name; i++ ) {
              assert( oc_map[i].ssom_defn != NULL );
              {
                     LDAPObjectClass *oc;
                     int           code;
                     const char    *err;

                     oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
                            LDAP_SCHEMA_ALLOW_ALL );
                     if ( !oc ) {
                            fprintf( stderr, "slap_schema_load: ObjectClass "
                                   "\"%s\": %s before %s\n",
                                   oc_map[i].ssom_name, ldap_scherr2str(code), err );
                            return code;
                     }

                     if ( oc->oc_oid == NULL ) {
                            fprintf( stderr, "slap_schema_load: ObjectClass "
                                   "\"%s\": no OID\n",
                                   oc_map[i].ssom_name );
                            ldap_objectclass_free( oc );
                            return LDAP_OTHER;
                     }

                     code = oc_add(oc,0,NULL,NULL,&err);
                     if ( code ) {
                            ldap_objectclass_free( oc );
                            fprintf( stderr, "slap_schema_load: ObjectClass "
                                   "\"%s\": %s: \"%s\"\n",
                                   oc_map[i].ssom_name, scherr2str(code), err);
                            return code;
                     }
                     ldap_memfree(oc);

              }
              {
                     ObjectClass ** ocp = (ObjectClass **)
                            &(((char *) &slap_schema)[oc_map[i].ssom_offset]);

                     assert( *ocp == NULL );

                     *ocp = oc_find( oc_map[i].ssom_name );
                     if( *ocp == NULL ) {
                            fprintf( stderr, "slap_schema_load: "
                                   "ObjectClass \"%s\": not defined in schema\n",
                                   oc_map[i].ssom_name );
                            return LDAP_OBJECT_CLASS_VIOLATION;
                     }

                     if( oc_map[i].ssom_check ) {
                            /* install check routine */
                            (*ocp)->soc_check = oc_map[i].ssom_check;
                     }
                     /* install flags */
                     (*ocp)->soc_flags |= oc_map[i].ssom_flags;
              }
       }

       return LDAP_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int subentryAttribute ( Backend be,
Entry e,
Attribute attr,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1540 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_SUBENTRIES(be) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" not supported in context",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       if( !is_entry_subentry( e ) ) {
              snprintf( textbuf, textlen,
                     "attribute \"%s\" only allowed in the subentry",
                     attr->a_desc->ad_cname.bv_val );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}
static int subentryObjectClass ( Backend be,
Entry e,
ObjectClass oc,
const char **  text,
char *  textbuf,
size_t  textlen 
) [static]

Definition at line 1420 of file schema_prep.c.

{
       *text = textbuf;

       if( !SLAP_SUBENTRIES(be) ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" not supported in context",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       if( oc != slap_schema.si_oc_subentry && !is_entry_subentry( e ) ) {
              snprintf( textbuf, textlen,
                     "objectClass \"%s\" only allowed in subentries",
                     oc->soc_oid );
              return LDAP_OBJECT_CLASS_VIOLATION;
       }

       return LDAP_SUCCESS;
}

Variable Documentation

struct slap_schema_ad_map ad_map[] [static]

Definition at line 417 of file schema_prep.c.

Definition at line 414 of file schema_prep.c.

Definition at line 316 of file schema_prep.c.

Definition at line 419 of file schema_prep.c.

Definition at line 320 of file schema_prep.c.

struct slap_schema_mr_map mr_map[] [static]
struct slap_schema_oc_map oc_map[] [static]

Definition at line 415 of file schema_prep.c.

Definition at line 317 of file schema_prep.c.

Definition at line 413 of file schema_prep.c.

Definition at line 315 of file schema_prep.c.

Definition at line 29 of file schema_prep.c.

Initial value:
 {
       { "1.1.1", NULL, "Catchall for undefined proxied attribute types", 1, NULL,
              NULL, NULL, NULL, NULL,
              0, 0, 0, 0, LDAP_SCHEMA_USER_APPLICATIONS, NULL }, 
       BER_BVC("PROXIED"), 
       NULL, 
       NULL, 
       NULL, NULL, NULL, NULL,     
       NULL, 
       NULL, 
       NULL, 
       NULL, 
       SLAP_AT_ABSTRACT|SLAP_AT_FINAL,    
       { NULL }, 
       NULL 
       
}

Definition at line 1033 of file schema_prep.c.

Initial value:
 {
       { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
              NULL, NULL, NULL, NULL,
              0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, 
       BER_BVC("UNDEFINED"), 
       NULL, 
       NULL, 
       NULL, NULL, NULL, NULL,     
       NULL, 
       NULL, 
       NULL, 
       NULL, 
       SLAP_AT_ABSTRACT|SLAP_AT_FINAL,    
       { NULL }, 
       NULL 
       
}

Definition at line 1015 of file schema_prep.c.

Definition at line 416 of file schema_prep.c.

Definition at line 318 of file schema_prep.c.

struct slap_schema_syn_map syn_map[] [static]