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 );
#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
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",
rc = 0;
goto cleanup;
}
+#endif /* SLAPD_SCHEMA_DN */
}
if( entry ) {
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;
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;
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 );
}
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 );
#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 );
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 );
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 );
#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;
*/
#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;
/*
* 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 );
/*
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;
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";
{
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 ) {
}
#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 ) {
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 */
}
Attribute *
-slap_operational_subschemaSubentry( void )
+slap_operational_subschemaSubentry( Backend *be )
{
return NULL;
}