Commit 89b09b02 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Split schema_prep() from schema_init.c

parent 67e34b5e
......@@ -15,8 +15,8 @@ SRCS = main.c daemon.c connection.c search.c filter.c add.c charray.c \
value.c ava.c bind.c unbind.c abandon.c filterentry.c \
phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
repl.c lock.c controls.c extended.c kerberos.c passwd.c \
schema.c schema_check.c schema_init.c schemaparse.c \
ad.c at.c mr.c syntax.c oc.c \
schema.c schema_check.c schema_init.c schema_prep.c \
schemaparse.c ad.c at.c mr.c syntax.c oc.c \
monitor.c configinfo.c starttls.c \
root_dse.c sasl.c module.c suffixalias.c $(@PLAT@_SRCS)
......@@ -26,8 +26,8 @@ OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
value.o ava.o bind.o unbind.o abandon.o filterentry.o \
phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
repl.o lock.o controls.o extended.o kerberos.o passwd.o \
schema.o schema_check.o schema_init.o schemaparse.o \
ad.o at.o mr.o syntax.o oc.o \
schema.o schema_check.o schema_init.o schema_prep.o \
schemaparse.o ad.o at.o mr.o syntax.o oc.o \
monitor.o configinfo.o starttls.o \
root_dse.o sasl.o module.o suffixalias.o $(@PLAT@_OBJS)
......
......@@ -12,6 +12,7 @@ LDAP_BEGIN_DECL
#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F( struct slap_internal_schema ) slap_schema;
LIBSLAPD_F( int ) schema_init_done;
LIBSLAPD_F (int) slap_str2ad LDAP_P((
const char *,
......
......@@ -329,22 +329,6 @@ caseIgnoreIA5Match(
return LDAP_SUCCESS;
}
static int
objectClassMatch(
int *match,
unsigned use,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
void *assertedValue )
{
ObjectClass *oc = oc_find( value->bv_val );
ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val );
*match = ( oc == NULL || oc != asserted );
return LDAP_SUCCESS;
}
struct syntax_defs_rec {
char *sd_desc;
int sd_flags;
......@@ -684,8 +668,6 @@ struct mrule_defs_rec mrule_defs[] = {
{NULL, SLAP_MR_NONE, NULL, NULL, NULL}
};
static int schema_init_done = 0;
int
schema_init( void )
{
......@@ -742,135 +724,3 @@ schema_init( void )
schema_init_done = 1;
return LDAP_SUCCESS;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
struct slap_internal_schema slap_schema;
struct slap_schema_oc_map {
char *ssom_name;
size_t ssom_offset;
} oc_map[] = {
{ "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
{ "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
{ NULL, 0 }
};
struct slap_schema_ad_map {
char *ssam_name;
slap_mr_match_func *ssam_match;
size_t ssam_offset;
} ad_map[] = {
{ "objectClass", objectClassMatch,
offsetof(struct slap_internal_schema, si_ad_objectClass) },
{ "creatorsName", NULL,
offsetof(struct slap_internal_schema, si_ad_creatorsName) },
{ "createTimestamp", NULL,
offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
{ "modifiersName", NULL,
offsetof(struct slap_internal_schema, si_ad_modifiersName) },
{ "modifyTimestamp", NULL,
offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
{ "subschemaSubentry", NULL,
offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
{ "namingContexts", NULL,
offsetof(struct slap_internal_schema, si_ad_namingContexts) },
{ "supportedControl", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedControl) },
{ "supportedExtension", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
{ "supportedLDAPVersion", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
{ "supportedACIMechanisms", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
#endif
{ "supportedSASLMechanisms", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
{ "attributeTypes", NULL,
offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
{ "ldapSyntaxes", NULL,
offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
{ "matchingRules", NULL,
offsetof(struct slap_internal_schema, si_ad_matchingRules) },
{ "objectClasses", NULL,
offsetof(struct slap_internal_schema, si_ad_objectClasses) },
{ "ref", NULL,
offsetof(struct slap_internal_schema, si_ad_ref) },
{ "entry", NULL,
offsetof(struct slap_internal_schema, si_ad_entry) },
{ "children", NULL,
offsetof(struct slap_internal_schema, si_ad_children) },
{ "userPassword", NULL,
offsetof(struct slap_internal_schema, si_ad_userPassword) },
{ "authPassword", NULL,
offsetof(struct slap_internal_schema, si_ad_authPassword) },
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
{ "krbName", NULL,
offsetof(struct slap_internal_schema, si_ad_krbName) },
#endif
{ NULL, NULL, 0 }
};
#endif
int
schema_prep( void )
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
int i;
#endif
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( i=0; oc_map[i].ssom_name; i++ ) {
ObjectClass ** ocp = (ObjectClass **)
&(((char *) &slap_schema)[oc_map[i].ssom_offset]);
*ocp = oc_find( oc_map[i].ssom_name );
if( *ocp == NULL ) {
fprintf( stderr,
"No objectClass \"%s\" defined in schema\n",
oc_map[i].ssom_name );
return LDAP_OBJECT_CLASS_VIOLATION;
}
}
for( i=0; ad_map[i].ssam_name; i++ ) {
int rc;
const char *text;
AttributeDescription ** adp = (AttributeDescription **)
&(((char *) &slap_schema)[ad_map[i].ssam_offset]);
*adp = NULL;
rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr,
"No attribute \"%s\" defined in schema\n",
ad_map[i].ssam_name );
return rc;
}
if( ad_map[i].ssam_match ) {
/* install custom matching routine */
(*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
}
}
#endif
++schema_init_done;
return LDAP_SUCCESS;
}
/* schema_init.c - init builtin schema */
/* $OpenLDAP$ */
/*
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "ldap_pvt.h"
int schema_init_done = 0;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
struct slap_internal_schema slap_schema;
static int
objectClassMatch(
int *match,
unsigned use,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
void *assertedValue )
{
ObjectClass *oc = oc_find( value->bv_val );
ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val );
*match = ( oc == NULL || oc != asserted );
return LDAP_SUCCESS;
}
struct slap_schema_oc_map {
char *ssom_name;
size_t ssom_offset;
} oc_map[] = {
{ "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
{ "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
{ NULL, 0 }
};
struct slap_schema_ad_map {
char *ssam_name;
slap_mr_match_func *ssam_match;
size_t ssam_offset;
} ad_map[] = {
{ "objectClass", objectClassMatch,
offsetof(struct slap_internal_schema, si_ad_objectClass) },
{ "creatorsName", NULL,
offsetof(struct slap_internal_schema, si_ad_creatorsName) },
{ "createTimestamp", NULL,
offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
{ "modifiersName", NULL,
offsetof(struct slap_internal_schema, si_ad_modifiersName) },
{ "modifyTimestamp", NULL,
offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
{ "subschemaSubentry", NULL,
offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
{ "namingContexts", NULL,
offsetof(struct slap_internal_schema, si_ad_namingContexts) },
{ "supportedControl", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedControl) },
{ "supportedExtension", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
{ "supportedLDAPVersion", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
{ "supportedACIMechanisms", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
#endif
{ "supportedSASLMechanisms", NULL,
offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
{ "attributeTypes", NULL,
offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
{ "ldapSyntaxes", NULL,
offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
{ "matchingRules", NULL,
offsetof(struct slap_internal_schema, si_ad_matchingRules) },
{ "objectClasses", NULL,
offsetof(struct slap_internal_schema, si_ad_objectClasses) },
{ "ref", NULL,
offsetof(struct slap_internal_schema, si_ad_ref) },
{ "entry", NULL,
offsetof(struct slap_internal_schema, si_ad_entry) },
{ "children", NULL,
offsetof(struct slap_internal_schema, si_ad_children) },
{ "userPassword", NULL,
offsetof(struct slap_internal_schema, si_ad_userPassword) },
{ "authPassword", NULL,
offsetof(struct slap_internal_schema, si_ad_authPassword) },
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
{ "krbName", NULL,
offsetof(struct slap_internal_schema, si_ad_krbName) },
#endif
{ NULL, NULL, 0 }
};
#endif
int
schema_prep( void )
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
int i;
#endif
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( i=0; oc_map[i].ssom_name; i++ ) {
ObjectClass ** ocp = (ObjectClass **)
&(((char *) &slap_schema)[oc_map[i].ssom_offset]);
*ocp = oc_find( oc_map[i].ssom_name );
if( *ocp == NULL ) {
fprintf( stderr,
"No objectClass \"%s\" defined in schema\n",
oc_map[i].ssom_name );
return LDAP_OBJECT_CLASS_VIOLATION;
}
}
for( i=0; ad_map[i].ssam_name; i++ ) {
int rc;
const char *text;
AttributeDescription ** adp = (AttributeDescription **)
&(((char *) &slap_schema)[ad_map[i].ssam_offset]);
*adp = NULL;
rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr,
"No attribute \"%s\" defined in schema\n",
ad_map[i].ssam_name );
return rc;
}
if( ad_map[i].ssam_match ) {
/* install custom matching routine */
(*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
}
}
#endif
++schema_init_done;
return LDAP_SUCCESS;
}
......@@ -53,8 +53,8 @@ BDB2SRCS =
QUIPUSRCS = edb2ldif.c ldapsyntax.c chlog2replog.c
SLAPD_OBJS = ../config.o ../ch_malloc.o ../backend.o ../charray.o \
../module.o ../aclparse.o ../filterentry.o \
../schema.o ../schema_check.o ../schema_init.o ../schemaparse.o \
../ad.o ../at.o ../mr.o ../oc.o ../syntax.o \
../schema.o ../schema_check.o ../schema_init.o ../schema_parse.o \
../schemaparse.o ../ad.o ../at.o ../mr.o ../oc.o ../syntax.o \
../acl.o ../phonetic.o ../attr.o ../value.o ../entry.o \
../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \
../controls.o ../kerberos.o ../passwd.o \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment