int
attr_merge(
Entry *e,
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ AttributeDescription *desc,
+#else
const char *type,
+#endif
struct berval **vals )
{
Attribute **a;
LDAP_BEGIN_DECL
#ifdef SLAPD_SCHEMA_NOT_COMPAT
-LIBSLAPD_F( AttributeDescription * ) slap_ad_entry;
-LIBSLAPD_F( AttributeDescription * ) slap_ad_children;
+LIBSLAPD_F( struct slap_internal_schema ) slap_schema;
LIBSLAPD_F (int) slap_str2ad LDAP_P((
const char *,
LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type,
struct berval **vals, int nvals, int naddvals, int *maxvals,
Attribute ***a ));
-LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, const char *type,
- struct berval **vals ));
#ifdef SLAPD_SCHEMA_NOT_COMPAT
+LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e,
+ AttributeDescription *desc,
+ struct berval **vals ));
LIBSLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription *desc ));
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, AttributeDescription *desc ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc ));
#else
+LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, const char *type,
+ struct berval **vals ));
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, const char *type ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, const char *type ));
LIBSLAPD_F (int) attr_syntax LDAP_P(( const char *type ));
int opattrs;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *entry = slap_ad_entry;
+ AttributeDescription *entry = slap_schema.si_ad_entry;
#else
static const char *entry = "entry";
#endif
for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
val.bv_val = backends[i].be_suffix[j];
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "namingContexts", vals );
+ attr_merge( e, slap_schema.si_ad_namingContexts, vals );
}
}
for ( i=0; supportedControls[i] != NULL; i++ ) {
val.bv_val = supportedControls[i];
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "supportedControl", vals );
+ attr_merge( e, slap_schema.si_ad_supportedControl, vals );
}
/* supportedExtension */
for ( i=0; (val.bv_val = get_supported_extop(i)) != NULL; i++ ) {
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "supportedExtension", vals );
+ attr_merge( e, slap_schema.si_ad_supportedExtension, vals );
}
/* supportedLDAPVersion */
sprintf(buf,"%d",i);
val.bv_val = buf;
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "supportedLDAPVersion", vals );
+ attr_merge( e, slap_schema.si_ad_supportedLDAPVersion, vals );
}
/* supportedSASLMechanism */
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
val.bv_val = supportedSASLMechanisms[i];
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "supportedSASLMechanisms", vals );
+ attr_merge( e, slap_schema.si_ad_supportedSASLMechanisms, vals );
}
}
/* supportedACIMechanisms */
for ( i=0; (val.bv_val = get_supported_acimech(i)) != NULL; i++ ) {
val.bv_len = strlen( val.bv_val );
- attr_merge( e, "supportedACIMechanisms", vals );
+ attr_merge( e, slap_schema.si_ad_supportedSASLMechanisms, vals );
}
#endif
if ( default_referral != NULL ) {
- attr_merge( e, "ref", default_referral );
+ attr_merge( e, slap_schema.si_ad_ref, default_referral );
}
val.bv_val = "top";
val.bv_len = sizeof("top")-1;
- attr_merge( e, "objectClass", vals );
+ attr_merge( e, slap_schema.si_ad_objectClass, vals );
val.bv_val = "LDAProotDSE";
val.bv_len = sizeof("LDAProotDSE")-1;
- attr_merge( e, "objectClass", vals );
+ attr_merge( e, slap_schema.si_ad_objectClass, vals );
send_search_entry( &backends[0], conn, op,
e, attrs, attrsonly, NULL );
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
-AttributeDescription *slap_ad_entry = NULL;
-AttributeDescription *slap_ad_children = NULL;
+struct slap_internal_schema slap_schema;
+
+struct slap_schema_ad_map {
+ char *ssm_type;
+ size_t ssm_offset;
+} ad_map[] = {
+ { "objectClass",
+ offsetof(struct slap_internal_schema, si_ad_objectClass) },
+
+ { "creatorsName",
+ offsetof(struct slap_internal_schema, si_ad_creatorsName) },
+ { "createTimestamp",
+ offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
+ { "modifiersName",
+ offsetof(struct slap_internal_schema, si_ad_modifiersName) },
+ { "modifyTimestamp",
+ offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
+ { "namingContexts",
+ offsetof(struct slap_internal_schema, si_ad_namingContexts) },
+ { "supportedControl",
+ offsetof(struct slap_internal_schema, si_ad_supportedControl) },
+ { "supportedExtension",
+ offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
+ { "supportedLDAPVersion",
+ offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
+ { "supportedSASLMechanisms",
+ offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
+
+ { "ref",
+ offsetof(struct slap_internal_schema, si_ad_ref) },
+
+ { "entry",
+ offsetof(struct slap_internal_schema, si_ad_entry) },
+ { "children",
+ offsetof(struct slap_internal_schema, si_ad_children) },
+ { NULL, NULL }
+};
+
#endif
int
schema_prep( void )
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- int rc;
+ int i;
char *text;
#endif
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
#ifdef SLAPD_SCHEMA_NOT_COMPAT
- rc = slap_str2ad( "entry", &slap_ad_entry, &text);
- if( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "No attribute \"entry\" defined in schema\n" );
- return rc;
- }
+ for( i=0; ad_map[i].ssm_type; i++ ) {
+ int rc = slap_str2ad( ad_map[i].ssm_type,
+ (AttributeDescription **)
+ &(((char *) &slap_schema)[ad_map[i].ssm_offset]),
+ &text);
- rc = slap_str2ad( "children", &slap_ad_children, &text);
- if( rc != LDAP_SUCCESS ) {
- fprintf( stderr, "No attribute \"children\" defined in schema\n" );
- return rc;
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr,
+ "No attribute \"%s\" defined in schema\n",
+ ad_map[i].ssm_type );
+ return rc;
+ }
}
#endif
#define SLAP_DESC_BINARY 0x1U
} AttributeDescription;
+/*
+ * pointers to schema elements used internally
+ */
+struct slap_internal_schema {
+ /* objectClass attribute */
+ AttributeDescription *si_ad_objectClass;
+
+ /* operational attributes */
+ AttributeDescription *si_ad_creatorsName;
+ AttributeDescription *si_ad_createTimestamp;
+ AttributeDescription *si_ad_modifiersName;
+ AttributeDescription *si_ad_modifyTimestamp;
+ AttributeDescription *si_ad_subschemaSubentry;
+
+ /* root DSE attributes */
+ AttributeDescription *si_ad_namingContexts;
+ AttributeDescription *si_ad_supportedControl;
+ AttributeDescription *si_ad_supportedExtension;
+ AttributeDescription *si_ad_supportedLDAPVersion;
+ AttributeDescription *si_ad_supportedSASLMechanisms;
+
+ /* subschema subentry attributes */
+ AttributeDescription *si_ad_objectClasses;
+ AttributeDescription *si_ad_attributeTypes;
+ AttributeDescription *si_ad_ldapSyntaxes;
+ AttributeDescription *si_ad_matchingRules;
+ AttributeDescription *si_ad_matchingRulesUse;
+
+ /* Aliases & Referrals */
+ AttributeDescription *si_ad_aliasedObjectName;
+ AttributeDescription *si_ad_ref;
+
+ /* ACL Internals */
+ AttributeDescription *si_ad_entry;
+ AttributeDescription *si_ad_children;
+
+ /* Other */
+ AttributeDescription *si_ad_userPassword;
+};
+
typedef struct slap_attr_assertion {
AttributeDescription *aa_desc;
struct berval *aa_value;