Commit 79cc61f2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Suck in global schema dn and operational attributes changes

parent 8e303f71
......@@ -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 );
......
......@@ -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
......
......@@ -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 ) {
......
......@@ -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 );
......
......@@ -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 );
......
/* operational.c - routines to deal with on-the-fly operational attrs */
/*
* Copyright 2001-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include "slap.h"
/*
* helpers for on-the-fly operational attribute generation
*/
#ifdef SLAPD_SCHEMA_DN
Attribute *
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;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( a->a_vals, &global_schemadn );
a->a_vals[1].bv_val = NULL;
a->a_next = NULL;
a->a_flags = 0;
return a;
}
#endif /* SLAPD_SCHEMA_DN */
Attribute *
slap_operational_hasSubordinate( int hs )
{
Attribute *a;
a = ch_malloc( sizeof( Attribute ) );
a->a_desc = slap_schema.si_ad_hasSubordinates;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
ber_str2bv( hs ? "TRUE" : "FALSE",
hs ? sizeof("TRUE")-1 : sizeof("FALSE")-1,
1, a->a_vals );
a->a_vals[1].bv_val = NULL;
a->a_next = NULL;
a->a_flags = 0;
return a;
}
......@@ -341,7 +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) )
#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;
......@@ -678,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 );
/*
......@@ -1046,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;
......
......@@ -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 ) {
......
......@@ -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 ) {
......
......@@ -1189,6 +1189,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 */
......
......@@ -239,7 +239,7 @@ int read_root_dse_file ( const char *file )
}
Attribute *
slap_operational_subschemaSubentry( void )
slap_operational_subschemaSubentry( Backend *be )
{
return NULL;
}
......
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