mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-09 22:04:12 -05:00
Relocate schema_init() call to main()
Add schema_prep() call to main() Similiar changes to slapcommon.c Add schema_prep() impl to schema_init.c Add slap_ad_entry and slap_ad_children globals. Add "entry" and "children" to openldap.schema (this likely should be added to schema via code, not configuration)
This commit is contained in:
parent
ef6ee899cb
commit
7b14e1304a
7 changed files with 76 additions and 14 deletions
|
|
@ -76,13 +76,6 @@ read_config( const char *fname )
|
|||
|
||||
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 ) {
|
||||
|
|
|
|||
|
|
@ -361,12 +361,26 @@ int main( int argc, char **argv )
|
|||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
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,
|
||||
|
|
@ -611,6 +614,7 @@ LIBSLAPD_F (int) entry_schema_check LDAP_P((
|
|||
* schema_init.c
|
||||
*/
|
||||
LIBSLAPD_F (int) schema_init LDAP_P((void));
|
||||
LIBSLAPD_F (int) schema_prep LDAP_P((void));
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ send_search_entry(
|
|||
int opattrs;
|
||||
|
||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||
static AttributeDescription *entry = NULL;
|
||||
AttributeDescription *entry = slap_ad_entry;
|
||||
#else
|
||||
static const char *entry = "entry";
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@
|
|||
#
|
||||
# other slapd items
|
||||
#
|
||||
attributetype ( entryOID NAME 'entry' SUP name
|
||||
SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )
|
||||
attributetype ( childrenOID NAME 'children' SUP name
|
||||
SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )
|
||||
|
|
|
|||
|
|
@ -564,16 +564,16 @@ struct mrule_defs_rec mrule_defs[] = {
|
|||
{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,
|
||||
|
|
@ -585,7 +585,7 @@ schema_init( void )
|
|||
if ( res ) {
|
||||
fprintf( stderr, "schema_init: Error registering syntax %s\n",
|
||||
syntax_defs[i].sd_desc );
|
||||
exit( EXIT_FAILURE );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -610,9 +610,42 @@ schema_init( void )
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,13 @@ slap_tool_init(
|
|||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
rc = schema_init();
|
||||
|
||||
if (rc != 0 ) {
|
||||
fprintf( stderr, "%s: slap_schema_init failed!\n", progname );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
read_config( conffile );
|
||||
|
||||
if ( !nbackends ) {
|
||||
|
|
@ -195,6 +202,13 @@ slap_tool_init(
|
|||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
rc = schema_prep();
|
||||
|
||||
if (rc != 0 ) {
|
||||
fprintf( stderr, "%s: slap_schema_prep failed!\n", progname );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if( base != NULL ) {
|
||||
char *tbase = ch_strdup( base );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue