mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-09 08:23:35 -05:00
SLAPD_SCHEMA_NOT_COMPAT: Rework caching of internal schema
This commit is contained in:
parent
7b14e1304a
commit
40ab90fa9c
6 changed files with 110 additions and 26 deletions
|
|
@ -178,7 +178,11 @@ attr_merge_fast(
|
|||
int
|
||||
attr_merge(
|
||||
Entry *e,
|
||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||
AttributeDescription *desc,
|
||||
#else
|
||||
const char *type,
|
||||
#endif
|
||||
struct berval **vals )
|
||||
{
|
||||
Attribute **a;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@
|
|||
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 *,
|
||||
|
|
@ -117,14 +116,17 @@ LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s ));
|
|||
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 ));
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ send_search_entry(
|
|||
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
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
|||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,13 +51,13 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
|||
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 */
|
||||
|
|
@ -65,7 +65,7 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
|||
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 */
|
||||
|
|
@ -73,7 +73,7 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
|||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,21 +81,21 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
|||
/* 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 );
|
||||
|
|
|
|||
|
|
@ -618,31 +618,69 @@ schema_init( void )
|
|||
}
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
|||
|
|
@ -291,6 +291,46 @@ typedef struct slap_attr_desc {
|
|||
#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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue