]> git.sur5r.net Git - openldap/commitdiff
better handling of on-the-fly operational attrs by means of helpers
authorPierangelo Masarati <ando@openldap.org>
Sat, 22 Dec 2001 14:24:13 +0000 (14:24 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 22 Dec 2001 14:24:13 +0000 (14:24 +0000)
servers/slapd/Makefile.in
servers/slapd/back-ldbm/operational.c
servers/slapd/back-monitor/operational.c
servers/slapd/backend.c
servers/slapd/operational.c [new file with mode: 0644]
servers/slapd/proto-slap.h
servers/slapd/tools/mimic.c

index 54ce1cbc28552bbf050869c9d5672a3d97018b24..985bff3209fdb09a2a0813288b0220be7765c49f 100644 (file)
@@ -19,7 +19,7 @@ SRCS  = main.c daemon.c connection.c search.c filter.c add.c charray.c \
                schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
                configinfo.c starttls.c index.c sets.c referral.c \
                root_dse.c sasl.c module.c suffixalias.c mra.c mods.c \
-               limits.c backglue.c \
+               limits.c backglue.c operational.c \
                $(@PLAT@_SRCS)
 
 OBJS   = main.o daemon.o connection.o search.o filter.o add.o charray.o \
@@ -32,7 +32,7 @@ OBJS  = main.o daemon.o connection.o search.o filter.o add.o charray.o \
                schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
                configinfo.o starttls.o index.o sets.o referral.o \
                root_dse.o sasl.o module.o suffixalias.o mra.o mods.o \
-               limits.o backglue.o \
+               limits.o backglue.o operational.o \
                $(@PLAT@_OBJS)
 
 LDAP_INCDIR= ../../include
index 81fe0efb1edbda15c953eb45a54091227bc7e2c7..b553a677d377bb83b87d5ddf5a6c6867411b2d09 100644 (file)
@@ -37,16 +37,10 @@ ldbm_back_operational(
                int     hs;
 
                hs = has_children( be, e );
-
-               *aa = ch_malloc( sizeof( Attribute ) );
-               (*aa)->a_desc = slap_schema.si_ad_hasSubordinates;
-
-               (*aa)->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
-               (*aa)->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
-               (*aa)->a_vals[1] = NULL;
-
-               (*aa)->a_next = NULL;
-               aa = &(*aa)->a_next;
+               *aa = slap_operational_hasSubordinate( hs );
+               if ( *aa != NULL ) {
+                       aa = &(*aa)->a_next;
+               }
        }
        
        return 0;
index 46366905dfc8d8b9769130d10037e024c745010d..62d750dfc98005393c381df4acfdaddf6543a177 100644 (file)
@@ -42,16 +42,10 @@ monitor_back_operational(
                assert( mp );
 
                hs = MONITOR_HAS_CHILDREN( mp );
-
-               *aa = ch_malloc( sizeof( Attribute ) );
-               (*aa)->a_desc = slap_schema.si_ad_hasSubordinates;
-
-               (*aa)->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
-               (*aa)->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
-               (*aa)->a_vals[1] = NULL;
-
-               (*aa)->a_next = NULL;
-               aa = &(*aa)->a_next;
+               *aa = slap_operational_hasSubordinate( hs );
+               if ( *aa != NULL ) {
+                       aa = &(*aa)->a_next;
+               }
        }
        
        return 0;
index 8b1469ef38e26fb9674db03247a41e30ad0a5681..0aff46c4434c0de23e4b07f02e1a6f7b95b80b8f 100644 (file)
@@ -1094,16 +1094,8 @@ Attribute *backend_operational(
        Attribute *a = NULL, **ap = &a;
 
 #ifdef SLAPD_SCHEMA_DN
-       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 * ) );
-       a->a_vals[0] = ber_bvstrdup( SLAPD_SCHEMA_DN );
-       a->a_vals[1] = NULL;
-
-       a->a_next = NULL;
-       ap = &a->a_next;
+       *ap = slap_operational_subschemaSubentry();
+       ap = &(*ap)->a_next;
 #endif
 
        /*
@@ -1111,7 +1103,7 @@ Attribute *backend_operational(
         * and the backend supports specific operational attributes, 
         * add them to the attribute list
         */
-       if ( ( opattrs || attrs ) && be->be_operational != NULL ) {
+       if ( ( opattrs || attrs ) && be && be->be_operational != NULL ) {
                ( void )be->be_operational( be, conn, op, e, 
                                            attrs, opattrs, ap );
        }
diff --git a/servers/slapd/operational.c b/servers/slapd/operational.c
new file mode 100644 (file)
index 0000000..989b11b
--- /dev/null
@@ -0,0 +1,51 @@
+/* operational.c - routines to deal with on-the-fly operational attrs */
+/*
+ * Copyright 2001 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( void )
+{
+       Attribute       *a;
+
+       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 * ) );
+       a->a_vals[0] = ber_bvstrdup( SLAPD_SCHEMA_DN );
+       a->a_vals[1] = NULL;
+
+       a->a_next = NULL;
+
+       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 * ) );
+       a->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
+       a->a_vals[1] = NULL;
+
+       a->a_next = NULL;
+
+       return a;
+}
+
index f25c69e769deef4674460e29ead59adb00ae66b7..915c40321ff68c8c3ac82cf6369caaff4c361073 100644 (file)
@@ -886,6 +886,12 @@ LDAP_SLAPD_V (char)        *ldap_srvtab;
 LDAP_SLAPD_V (int)     krbv4_ldap_auth();
 #endif
 
+/*
+ * operational.c
+ */
+LDAP_SLAPD_F (Attribute *) slap_operational_subschemaSubentry( void );
+LDAP_SLAPD_F (Attribute *) slap_operational_hasSubordinate( int has );
+
 /*
  * Other...
  */
index 43e80bf8e589c879e366cad9170cf98d92df8bdf..ef6bad5d1fd18b262ec64ebb8dc8d47dd487c3ea 100644 (file)
@@ -220,3 +220,16 @@ int read_root_dse_file ( const char *file )
 {
        return 0;
 }
+
+Attribute *
+slap_operational_subschemaSubentry( void )
+{
+       return NULL;
+}
+
+Attribute *
+slap_operational_hasSubordinate( int hs )
+{
+       return NULL;
+}
+