Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
- if ( schema_init( ) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "error initializing the schema\n",
- 0, 0, 0 );
- return( 1 );
- }
-
fp_getline_init( &lineno );
while ( (line = fp_getline( fp, &lineno )) != NULL ) {
goto destroy;
}
+ if ( schema_init( ) != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "schema initialization error\n",
+ 0, 0, 0 );
+ goto destroy;
+ }
+
if ( read_config( configfile ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
goto destroy;
}
+ if ( schema_prep( ) != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "schema prep error\n",
+ 0, 0, 0 );
+ goto destroy;
+ }
+
#ifdef HAVE_TLS
ldap_pvt_tls_init();
LDAP_BEGIN_DECL
#ifdef SLAPD_SCHEMA_NOT_COMPAT
+LIBSLAPD_F( AttributeDescription * ) slap_ad_entry;
+LIBSLAPD_F( AttributeDescription * ) slap_ad_children;
+
LIBSLAPD_F (int) slap_str2ad LDAP_P((
const char *,
AttributeDescription **ad,
* schema_init.c
*/
LIBSLAPD_F (int) schema_init LDAP_P((void));
+LIBSLAPD_F (int) schema_prep LDAP_P((void));
/*
{NULL, SLAP_MR_NONE, NULL, NULL, NULL}
};
+static int schema_init_done = 0;
+
int
schema_init( void )
{
int res;
int i;
- static int schema_init_done = 0;
- /* We are called from read_config that is recursive */
- if ( schema_init_done )
- return( 0 );
+ /* we should only be called once (from main) */
+ assert( schema_init_done == 0 );
for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
res = register_syntax( syntax_defs[i].sd_desc,
if ( res ) {
fprintf( stderr, "schema_init: Error registering syntax %s\n",
syntax_defs[i].sd_desc );
- exit( EXIT_FAILURE );
+ return -1;
}
}
fprintf( stderr,
"schema_init: Error registering matching rule %s\n",
mrule_defs[i].mrd_desc );
- exit( EXIT_FAILURE );
+ return -1;
}
}
schema_init_done = 1;
return( 0 );
}
+
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+AttributeDescription *slap_ad_entry = NULL;
+AttributeDescription *slap_ad_children = NULL;
+#endif
+
+int
+schema_prep( void )
+{
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+ int rc;
+ 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;
+ }
+
+ rc = slap_str2ad( "children", &slap_ad_children, &text);
+ if( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "No attribute \"children\" defined in schema\n" );
+ return rc;
+ }
+#endif
+
+ ++schema_init_done;
+ return 0;
+}