]> git.sur5r.net Git - openldap/commitdiff
Suck in global schema dn and operational attributes changes
authorKurt Zeilenga <kurt@openldap.org>
Fri, 16 Aug 2002 19:21:12 +0000 (19:21 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 16 Aug 2002 19:21:12 +0000 (19:21 +0000)
servers/slapd/add.c
servers/slapd/backend.c
servers/slapd/compare.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/operational.c [new file with mode: 0644]
servers/slapd/proto-slap.h
servers/slapd/schema.c
servers/slapd/search.c
servers/slapd/slap.h
servers/slapd/tools/mimic.c

index b43e78105212e139b353cecd8cec865f62203463..6e7cb7e443f8dfb347f8074eae08d96cf7ee60ce 100644 (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 );
index 133f9fd82e8c52b57c9cd87e4ccb706490135038..a6237ec5db8148b55ff0604e84cc0418337afdff 100644 (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
index b62d69dc4ad9410bfcb9271f1a460d1f65017576..61a8f6882ef9fd19253ab4aef568e2ccd6cd3552 100644 (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 ) {
index 89e405c43f0ef76a7321b08e369550b93fba2d22..057206c269f8c9d425325a7b97026ef5ff65c868 100644 (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 );
index 026678a9ad129f4d18557898cd8dc1ea6fcc29f0..f9d618174774f47d797d3acd4b44ffe481d38e37 100644 (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  );
diff --git a/servers/slapd/operational.c b/servers/slapd/operational.c
new file mode 100644 (file)
index 0000000..b9396b2
--- /dev/null
@@ -0,0 +1,58 @@
+/* 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;
+}
+
index bbbdb1d3eb02439ea9d473707f090f9940f49043..6fd4487eaf941eb4e48e55ac00fd07fd6e6c5f67 100644 (file)
@@ -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;
index 4be9256d060c095c762d678141cba82b4c777aef..725995150fe03669113f729be32e78165ce83579 100644 (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 ) {
index 7e36a3d7483b3b0ddf990689eca751577ac6d692..90cb1927cc3d3ea70415b239c52405a99ae08c1f 100644 (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 ) {
index 188e6104228d88dd97f9dfab92662082f5e0a084..64ada055143bd9b81d66ddeece70f6735c6480c9 100644 (file)
@@ -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        */
index a6c9ebb3ae1130575959413c1f3e110d4f951040..4a88f833c8920a8d19bfacfe82fd5c25b8116fc1 100644 (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;
 }