ITS#1893, use "schemadn" to configure subschemasubentry DN. (diff was

inaccessible, this is original code, not contributed.)
This commit is contained in:
Howard Chu 2002-08-10 03:10:52 +00:00
parent 4c69827b15
commit 07ebdca237
13 changed files with 85 additions and 16 deletions

View File

@ -189,7 +189,7 @@ do_add( Connection *conn, Operation *op )
goto done;
#if defined( SLAPD_SCHEMA_DN )
} else if ( strcasecmp( e->e_ndn, SLAPD_SCHEMA_DN ) == 0 ) {
} else if ( bvmatch( &e->e_nname, &global_schemandn ) ) {
send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
NULL, "subschema subentry already exists",
NULL, NULL );

View File

@ -1113,7 +1113,7 @@ Attribute *backend_operational(
#ifdef SLAPD_SCHEMA_DN
if ( opattrs || ( attrs &&
ad_inlist( slap_schema.si_ad_subschemaSubentry, attrs )) ) {
*ap = slap_operational_subschemaSubentry();
*ap = slap_operational_subschemaSubentry( be );
ap = &(*ap)->a_next;
}
#endif

View File

@ -169,7 +169,8 @@ do_compare(
goto cleanup;
}
} else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
#ifdef SLAPD_SCHEMA_DN
} else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ARGS,
"do_compare: dn (%s) attr(%s) value (%s)\n",
@ -198,6 +199,7 @@ do_compare(
rc = 0;
goto cleanup;
}
#endif /* SLAPD_SCHEMA_DN */
}
if( entry ) {

View File

@ -52,6 +52,10 @@ char **cargv;
struct berval default_search_base = { 0, NULL };
struct berval default_search_nbase = { 0, NULL };
unsigned num_subordinates = 0;
#ifdef SLAPD_SCHEMA_DN
struct berval global_schemadn;
struct berval global_schemandn;
#endif
ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
@ -564,6 +568,42 @@ read_config( const char *fname, int depth )
return 1;
#endif /* HAVE_CYRUS_SASL */
#ifdef SLAPD_SCHEMA_DN
} else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
struct berval dn;
if ( cargc < 2 ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, CRIT,
"%s: line %d: missing dn in "
"\"schemadn <dn>\" line.\n", fname, lineno, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: missing dn in \"schemadn <dn>\" line\n",
fname, lineno, 0 );
#endif
return 1 ;
}
ber_str2bv( cargv[1], 0, 0, &dn );
if ( be ) {
rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
&be->be_schemandn );
} else {
rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
&global_schemandn );
}
if ( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, CRIT,
"%s: line %d: schemadn DN is invalid.\n",
fname, lineno , 0 );
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: schemadn DN is invalid\n",
fname, lineno, 0 );
#endif
return 1;
}
#endif /* SLAPD_SCHEMA_DN */
/* set UCDATA path */
} else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
int err;
@ -2261,6 +2301,14 @@ read_config( const char *fname, int depth )
if ( depth == 0 ) ch_free( cargv );
#ifdef SLAPD_SCHEMA_DN
if ( !global_schemadn.bv_val ) {
ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
&global_schemadn );
dnNormalize2( NULL, &global_schemadn, &global_schemandn );
}
#endif
if ( load_ucdata( NULL ) < 0 ) return 1;
return( 0 );
}
@ -2480,6 +2528,10 @@ void
config_destroy( )
{
ucdata_unload( UCDATA_ALL );
#ifdef SLAPD_SCHEMA_DN
free( global_schemandn.bv_val );
free( global_schemadn.bv_val );
#endif
free( line );
if ( slapd_args_file )
free ( slapd_args_file );

View File

@ -104,7 +104,7 @@ do_delete(
#ifdef SLAPD_SCHEMA_DN
} else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
} else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_delete: conn %d: "
"Attempt to delete subschema subentry.\n", conn->c_connid, 0, 0 );

View File

@ -205,7 +205,7 @@ do_modify(
goto cleanup;
#if defined( SLAPD_SCHEMA_DN )
} else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
} else if ( bvmatch( &ndn, &global_schemandn ) ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
"do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );

View File

@ -202,7 +202,7 @@ do_modrdn(
goto cleanup;
#ifdef SLAPD_SCHEMA_DN
} else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
} else if ( bvmatch( &ndn, &global_schemandn ) == 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
"do_modrdn: attempt to modify subschema subentry\n", 0, 0, 0 );

View File

@ -14,16 +14,19 @@
#ifdef SLAPD_SCHEMA_DN
Attribute *
slap_operational_subschemaSubentry( void )
slap_operational_subschemaSubentry( Backend *be )
{
Attribute *a;
/* The backend wants to take care of it */
if ( be && be->be_schemadn.bv_val )
return NULL;
a = ch_malloc( sizeof( Attribute ) );
a->a_desc = slap_schema.si_ad_subschemaSubentry;
/* Should be backend specific */
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, a->a_vals );
ber_dupbv( a->a_vals, &global_schemadn );
a->a_vals[1].bv_val = NULL;
a->a_next = NULL;

View File

@ -341,6 +341,7 @@ LDAP_SLAPD_F (void) slapd_clr_read LDAP_P((ber_socket_t s, int wake));
*/
#define dn_match(dn1, dn2) ( ber_bvcmp((dn1), (dn2)) == 0 )
#define bvmatch(bv1, bv2) ( ((bv1)->bv_len == (bv2)->bv_len) && memcmp((bv1)->bv_val, (bv2)->bv_val, (bv1)->bv_len) == 0 )
LDAP_SLAPD_V( const struct berval ) slap_empty_bv;
@ -677,7 +678,7 @@ LDAP_SLAPD_F (Operation *) slap_op_pop LDAP_P(( Operation **olist ));
/*
* operational.c
*/
LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( void );
LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( Backend *be );
LDAP_SLAPD_F (Attribute *) slap_operational_hasSubordinate( int has );
/*
@ -1045,6 +1046,11 @@ LDAP_SLAPD_V (int) ldap_syslog;
LDAP_SLAPD_V (struct berval) default_search_base;
LDAP_SLAPD_V (struct berval) default_search_nbase;
#ifdef SLAPD_SCHEMA_DN
LDAP_SLAPD_V (struct berval) global_schemadn;
LDAP_SLAPD_V (struct berval) global_schemandn;
#endif
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_sent_mutex;
LDAP_SLAPD_V (unsigned long) num_bytes_sent;
LDAP_SLAPD_V (unsigned long) num_pdu_sent;

View File

@ -35,8 +35,11 @@ schema_info( Entry **entry, const char **text )
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
e->e_attrs = NULL;
ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &e->e_name);
(void) dnNormalize2( NULL, &e->e_name, &e->e_nname );
/* backend-specific schema info should be created by the
* backend itself
*/
ber_dupbv( &e->e_name, &global_schemadn );
ber_dupbv( &e->e_nname, &global_schemandn );
e->e_private = NULL;
vals[0].bv_val = "subentry";
@ -62,8 +65,7 @@ schema_info( Entry **entry, const char **text )
{
int rc;
AttributeDescription *desc = NULL;
struct berval rdn = { sizeof(SLAPD_SCHEMA_DN)-1,
SLAPD_SCHEMA_DN };
struct berval rdn = global_schemadn;
vals[0].bv_val = strchr( rdn.bv_val, '=' );
if( vals[0].bv_val == NULL ) {

View File

@ -239,7 +239,7 @@ do_search(
}
#if defined( SLAPD_SCHEMA_DN )
else if ( strcasecmp( nbase.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
else if ( bvmatch( &nbase, &global_schemandn ) ) {
/* check restrictions */
rc = backend_check_restrictions( NULL, conn, op, NULL, &text ) ;
if( rc != LDAP_SUCCESS ) {

View File

@ -1197,6 +1197,10 @@ struct slap_backend_db {
BerVarray be_suffix; /* the DN suffixes of data in this backend */
BerVarray be_nsuffix; /* the normalized DN suffixes in this backend */
BerVarray be_suffixAlias; /* pairs of DN suffix aliases and deref values */
#ifdef SLAPD_SCHEMA_DN
struct berval be_schemadn; /* per-backend subschema subentry DN */
struct berval be_schemandn; /* normalized subschema DN */
#endif
struct berval be_rootdn; /* the magic "root" name (DN) for this db */
struct berval be_rootndn; /* the magic "root" normalized name (DN) for this db */
struct berval be_rootpw; /* the magic "root" password for this db */

View File

@ -239,7 +239,7 @@ int read_root_dse_file ( const char *file )
}
Attribute *
slap_operational_subschemaSubentry( void )
slap_operational_subschemaSubentry( Backend *be )
{
return NULL;
}