]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/chain.c
add a giant mutex around the ldapinfo structure to serialize chaining (need to check...
[openldap] / servers / slapd / back-ldap / chain.c
index 573ab84ebeb0be6a9caef20376c4acdb4e85d217..a0dbb581c23ab34e9729ba65529abcf6ab278d2d 100644 (file)
@@ -29,6 +29,8 @@
 #include "slap.h"
 #include "back-ldap.h"
 
+#include "config.h"
+
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
 #define SLAP_CHAINING_DEFAULT                          LDAP_CHAINING_PREFERRED
 #define SLAP_CH_RESOLVE_SHIFT                          SLAP_CONTROL_SHIFT
@@ -67,6 +69,8 @@ typedef struct ldap_chain_t {
 #define LDAP_CHAIN_F_NONE              0x00U
 #define        LDAP_CHAIN_F_CHAINING           0x01U
 
+       ldap_pvt_thread_mutex_t lc_mutex;
+
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        LDAPControl             lc_chaining_ctrl;
        char                    lc_chaining_ctrlflag;
@@ -130,8 +134,8 @@ chaining_control_remove(
         * added by the chain overlay, so it's the only one we explicitly 
         * free */
        if ( op->o_ctrls != oldctrls ) {
-               assert( op->o_ctrls );
-               assert( op->o_ctrls[ 0 ] );
+               assert( op->o_ctrls != NULL );
+               assert( op->o_ctrls[ 0 ] != NULL );
 
                free( op->o_ctrls );
 
@@ -257,7 +261,10 @@ ldap_chain_op(
 {
        slap_overinst   *on = (slap_overinst *) op->o_bd->bd_info;
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
-       struct ldapinfo li, *lip = lc->lc_li;
+
+       struct ldapinfo *lip = lc->lc_li;
+       char            *save_url = NULL;
+       SlapReply       rs2 = { 0 };
 
        /* NOTE: returned if ref is empty... */
        int             rc = LDAP_OTHER;
@@ -270,12 +277,14 @@ ldap_chain_op(
 
        if ( lip->url != NULL ) {
                op->o_bd->be_private = lip;
-               rc = ( *op_f )( op, rs );
+               rc = ( *op_f )( op, &rs2 );
+               rs->sr_err = rs2.sr_err;
                goto done;
        }
 
-       li = *lip;
-       op->o_bd->be_private = &li;
+       save_url = lip->url;
+       lip->url = NULL;
+       op->o_bd->be_private = lip;
 
        /* if we parse the URI then by no means 
         * we can cache stuff or reuse connections, 
@@ -319,26 +328,29 @@ Document: draft-ietf-ldapbis-protocol-27.txt
                save_dn = srv->lud_dn;
                srv->lud_dn = "";
                srv->lud_scope = LDAP_SCOPE_DEFAULT;
-               li.url = ldap_url_desc2str( srv );
+               lip->url = ldap_url_desc2str( srv );
                srv->lud_dn = save_dn;
                ldap_free_urldesc( srv );
 
-               if ( li.url == NULL ) {
+               if ( lip->url == NULL ) {
                        /* try next */
                        rc = LDAP_OTHER;
                        continue;
                }
 
-               rc = ( *op_f )( op, rs );
+               rc = ( *op_f )( op, &rs2 );
+               rs->sr_err = rs2.sr_err;
 
-               ldap_memfree( li.url );
-               li.url = NULL;
+               ldap_memfree( lip->url );
+               lip->url = NULL;
                
                if ( rc == LDAP_SUCCESS && rs->sr_err == LDAP_SUCCESS ) {
                        break;
                }
        }
 
+       lip->url = save_url;
+
 done:;
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        (void)chaining_control_remove( op, &ctrls );
@@ -360,7 +372,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
        struct berval   ndn = op->o_ndn;
 
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
-       struct ldapinfo li, *lip = lc->lc_li;
+       struct ldapinfo *lip = lc->lc_li;
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        int             sr_err = rs->sr_err;
@@ -400,6 +412,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
        }
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 
+       ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
+
        /*
         * TODO: add checks on who/when chain operations; e.g.:
         *   a) what identities are authorized
@@ -439,43 +453,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                }
                break;
        case LDAP_REQ_ADD:
-               {
-               int             cleanup_attrs = 0;
-
-               if ( op->ora_e->e_attrs == NULL ) {
-                       char            textbuf[ SLAP_TEXT_BUFLEN ];
-                       size_t          textlen = sizeof( textbuf );
-
-#if 0
-                       /* FIXME: op->o_bd is still set to the BackendDB 
-                        * structure of the database that tried to handle
-                        * the operation and actually returned a referral
-                        * ... */
-                       assert( SLAP_DBFLAGS( op->o_bd ) & SLAP_DBFLAG_GLOBAL_OVERLAY );
-#endif
-
-                       /* global overlay: create entry */
-                       /* NOTE: this is a hack to use the chain overlay
-                        * as global.  I expect to be able to remove this
-                        * soon by using slap_mods2entry() earlier in
-                        * do_add(), adding the operational attrs later
-                        * if required. */
-                       rs->sr_err = slap_mods2entry( op->ora_modlist,
-                                       &op->ora_e, 0, 1,
-                                       &rs->sr_text, textbuf, textlen );
-                       if ( rs->sr_err != LDAP_SUCCESS ) {
-                               send_ldap_result( op, rs );
-                               rc = 1;
-                               break;
-                       }
-               }
                rc = ldap_chain_op( op, rs, lback->bi_op_add, ref );
-               if ( cleanup_attrs ) {
-                       attrs_free( op->ora_e->e_attrs );
-                       op->ora_e->e_attrs = NULL;
-               }
                break;
-               }
        case LDAP_REQ_DELETE:
                rc = ldap_chain_op( op, rs, lback->bi_op_delete, ref );
                break;
@@ -493,6 +472,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                        struct berval   *curr = ref,
                                        odn = op->o_req_dn,
                                        ondn = op->o_req_ndn;
+                       char            *save_url = NULL;
+                       SlapReply       rs2 = { 0 };
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
                        LDAPControl     **ctrls = NULL;
@@ -504,9 +485,9 @@ ldap_chain_response( Operation *op, SlapReply *rs )
 
                        sc2.sc_response = ldap_chain_cb_search_response;
 
-                       li = *lip;
-                       li.url = NULL;
-                       op->o_bd->be_private = &li;
+                       save_url = lip->url;
+                       lip->url = NULL;
+                       op->o_bd->be_private = lip;
                        
                        /* if we parse the URI then by no means 
                         * we can cache stuff or reuse connections, 
@@ -535,8 +516,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                                save_dn = srv->lud_dn;
                                srv->lud_dn = "";
                                srv->lud_scope = LDAP_SCOPE_DEFAULT;
-                               li.url = ldap_url_desc2str( srv );
-                               if ( li.url != NULL ) {
+                               lip->url = ldap_url_desc2str( srv );
+                               if ( lip->url != NULL ) {
                                        ber_str2bv_x( save_dn, 0, 1, &op->o_req_dn,
                                                        op->o_tmpmemctx );
                                        ber_dupbv_x( &op->o_req_ndn, &op->o_req_dn,
@@ -546,7 +527,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                                srv->lud_dn = save_dn;
                                ldap_free_urldesc( srv );
 
-                               if ( li.url == NULL ) {
+                               if ( lip->url == NULL ) {
                                        /* try next */
                                        rs->sr_err = LDAP_OTHER;
                                        continue;
@@ -555,10 +536,11 @@ ldap_chain_response( Operation *op, SlapReply *rs )
 
                                /* FIXME: should we also copy filter and scope?
                                 * according to RFC3296, no */
-                               rc = lback->bi_op_search( op, rs );
+                               rc = lback->bi_op_search( op, &rs2 );
+                               rs->sr_err = rs2.sr_err;
 
-                               ldap_memfree( li.url );
-                               li.url = NULL;
+                               ldap_memfree( lip->url );
+                               lip->url = NULL;
 
                                op->o_tmpfree( op->o_req_dn.bv_val,
                                                op->o_tmpmemctx );
@@ -576,6 +558,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                        (void)chaining_control_remove( op, &ctrls );
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 
+                       lip->url = save_url;
+
                        op->o_req_dn = odn;
                        op->o_req_ndn = ondn;
                        rs->sr_type = REP_SEARCHREF;
@@ -607,7 +591,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        if ( rc != LDAP_SUCCESS || sc2.sc_private == LDAP_CH_ERR ) {
-               if ( rs->sr_err == LDAP_CANNOT_CHAIN ) {
+               if ( rs->sr_err == LDAP_X_CANNOT_CHAIN ) {
                        goto cannot_chain;
                }
 
@@ -615,7 +599,8 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                case LDAP_CHAINING_REQUIRED:
 cannot_chain:;
                        op->o_callback = NULL;
-                       send_ldap_error( op, rs, LDAP_CANNOT_CHAIN, "operation cannot be completed without chaining" );
+                       send_ldap_error( op, rs, LDAP_X_CANNOT_CHAIN,
+                               "operation cannot be completed without chaining" );
                        break;
 
                default:
@@ -643,6 +628,8 @@ dont_chain:;
        op->o_ndn = ndn;
        rs->sr_ref = ref;
 
+       ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
+
        return rc;
 }
 
@@ -673,20 +660,285 @@ str2chain( const char *s )
 }
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 
+enum {
+       PC_CHAINING = 1
+};
+
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+static ConfigDriver chain_cf_gen;
+static ConfigCfAdd chain_cfadd;
+#endif
+static ConfigLDAPadd chain_ldadd;
+
+static ConfigTable chaincfg[] = {
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+       { "chain-chaining", "args",
+               2, 4, 0, ARG_MAGIC|ARG_BERVAL|PC_CHAINING, chain_cf_gen,
+               "( OLcfgOvAt:3.1 NAME 'olcChainingBehavior' "
+                       "DESC 'Chaining behavior control parameters (draft-sermersheim-ldap-chaining)' "
+                       "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
+       { NULL, NULL, 0, 0, 0, ARG_IGNORED }
+};
+
+static ConfigOCs chainocs[] = {
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+       { "( OLcfgOvOc:3.1 "
+               "NAME 'olcChainConfig' "
+               "DESC 'Chain configuration' "
+               "SUP olcOverlayConfig "
+               "MAY olcChainingBehavior )", Cft_Overlay, chaincfg, NULL, chain_cfadd },
+#endif
+       { "( OLcfgOvOc:3.2 "
+               "NAME 'olcChainDatabase' "
+               "DESC 'Chain remote server configuration' "
+               "AUXILIARY )", Cft_Misc, chaincfg, chain_ldadd },
+       { NULL, 0, NULL }
+};
+
+static int
+chain_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
+{
+       if ( p->ce_type != Cft_Overlay || !p->ce_bi ||
+               p->ce_bi->bi_cf_ocs != chainocs )
+               return LDAP_CONSTRAINT_VIOLATION;
+
+       return LDAP_SUCCESS;
+}
+
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+
+static int
+chain_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
+{
+       CfEntryInfo     *pe = p->e_private;
+       slap_overinst   *on = (slap_overinst *)pe->ce_bi;
+       ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
+       void            *priv = (void *)ca->be->be_private;
+       struct berval   bv;
+
+       /* FIXME: should not hardcode "olcDatabase" here */
+       bv.bv_len = sprintf( ca->msg, "olcDatabase=%s", lback->bi_type );
+       bv.bv_val = ca->msg;
+
+       /* We can only create this entry if the database is table-driven */
+       if ( lback->bi_cf_ocs ) {
+               ca->be->be_private = (void *)lc->lc_li;
+               config_build_entry( op, rs, pe, ca, &bv, lback->bi_cf_ocs, &chainocs[1] );
+               ca->be->be_private = priv;
+       }
+
+       return 0;
+}
+
+static slap_verbmasks chaining_mode[] = {
+       { BER_BVC("referralsRequired"),         LDAP_REFERRALS_REQUIRED },
+       { BER_BVC("referralsPreferred"),        LDAP_REFERRALS_PREFERRED },
+       { BER_BVC("chainingRequired"),          LDAP_CHAINING_REQUIRED },
+       { BER_BVC("chainingPreferred"),         LDAP_CHAINING_PREFERRED },
+       { BER_BVNULL,                           0 }
+};
+
+static int
+chain_cf_gen( ConfigArgs *c )
+{
+       slap_overinst   *on = (slap_overinst *)c->bi;
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+       ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
+#endif
+
+       int             rc = 0;
+
+       if ( c->op == SLAP_CONFIG_EMIT ) {
+               switch( c->type ) {
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+               case PC_CHAINING: {
+                       struct berval   resolve = BER_BVNULL,
+                                       continuation = BER_BVNULL;
+
+                       if ( !( lc->lc_flags & LDAP_CHAIN_F_CHAINING ) ) {
+                               return 1;
+                       }
+
+                       enum_to_verb( chaining_mode, ( ( lc->lc_chaining_ctrlflag & SLAP_CH_RESOLVE_MASK ) >> SLAP_CH_RESOLVE_SHIFT ), &resolve );
+                       enum_to_verb( chaining_mode, ( ( lc->lc_chaining_ctrlflag & SLAP_CH_CONTINUATION_MASK ) >> SLAP_CH_CONTINUATION_SHIFT ), &continuation );
+
+                       c->value_bv.bv_len = STRLENOF( "resolve=" ) + resolve.bv_len
+                               + STRLENOF( " " )
+                               + STRLENOF( "continuation=" ) + continuation.bv_len;
+                       c->value_bv.bv_val = ch_malloc( c->value_bv.bv_len + 1 );
+                       snprintf( c->value_bv.bv_val, c->value_bv.bv_len + 1,
+                               "resolve=%s continuation=%s",
+                               resolve.bv_val, continuation.bv_val );
+
+                       if ( lc->lc_chaining_ctrl.ldctl_iscritical ) {
+                               c->value_bv.bv_val = ch_realloc( c->value_bv.bv_val,
+                                       c->value_bv.bv_len + STRLENOF( " critical" ) + 1 );
+                               AC_MEMCPY( &c->value_bv.bv_val[ c->value_bv.bv_len ],
+                                       " critical", STRLENOF( " critical" ) + 1 );
+                               c->value_bv.bv_len += STRLENOF( " critical" );
+                       }
+
+                       break;
+               }
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
+
+               default:
+                       assert( 0 );
+                       rc = 1;
+               }
+               return rc;
+
+       } else if ( c->op == LDAP_MOD_DELETE ) {
+               return 1;       /* FIXME */
+#if 0
+               switch( c->type ) {
+               case PC_ATTR:
+               case PC_TEMP:
+               }
+               return rc;
+#endif
+       }
+
+       switch( c->type ) {
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+       case PC_CHAINING: {
+               char                    **argv = c->argv;
+               int                     argc = c->argc;
+               BerElementBuffer        berbuf;
+               BerElement              *ber = (BerElement *)&berbuf;
+               int                     resolve = -1,
+                                       continuation = -1,
+                                       iscritical = 0;
+               Operation               op = { 0 };
+               SlapReply               rs = { 0 };
+
+               lc->lc_chaining_ctrlflag = 0;
+
+               for ( argc--, argv++; argc > 0; argc--, argv++ ) {
+                       if ( strncasecmp( argv[ 0 ], "resolve=", STRLENOF( "resolve=" ) ) == 0 ) {
+                               resolve = str2chain( argv[ 0 ] + STRLENOF( "resolve=" ) );
+                               if ( resolve == -1 ) {
+                                       fprintf( stderr, "%s line %d: "
+                                               "illegal <resolve> value %s "
+                                               "in \"chain-chaining>\"\n",
+                                               c->fname, c->lineno, argv[ 0 ] );
+                                       return 1;
+                               }
+
+                       } else if ( strncasecmp( argv[ 0 ], "continuation=", STRLENOF( "continuation=" ) ) == 0 ) {
+                               continuation = str2chain( argv[ 0 ] + STRLENOF( "continuation=" ) );
+                               if ( continuation == -1 ) {
+                                       fprintf( stderr, "%s line %d: "
+                                               "illegal <continuation> value %s "
+                                               "in \"chain-chaining\"\n",
+                                               c->fname, c->lineno, argv[ 0 ] );
+                                       return 1;
+                               }
+
+                       } else if ( strcasecmp( argv[ 0 ], "critical" ) == 0 ) {
+                               iscritical = 1;
+
+                       } else {
+                               fprintf( stderr, "%s line %d: "
+                                       "unknown option in \"chain-chaining\"\n",
+                                       c->fname, c->lineno );
+                               return 1;
+                       }
+               }
+
+               if ( resolve != -1 || continuation != -1 ) {
+                       int     err;
+
+                       if ( resolve == -1 ) {
+                               /* default */
+                               resolve = SLAP_CHAINING_DEFAULT;
+                       }
+
+                       ber_init2( ber, NULL, LBER_USE_DER );
+
+                       err = ber_printf( ber, "{e" /* } */, resolve );
+                       if ( err == -1 ) {
+                               ber_free( ber, 1 );
+                               fprintf( stderr, "%s line %d: "
+                                       "chaining behavior control encoding error!\n",
+                                       c->fname, c->lineno );
+                               return 1;
+                       }
+
+                       if ( continuation > -1 ) {
+                               err = ber_printf( ber, "e", continuation );
+                               if ( err == -1 ) {
+                                       ber_free( ber, 1 );
+                                       fprintf( stderr, "%s line %d: "
+                                               "chaining behavior control encoding error!\n",
+                                               c->fname, c->lineno );
+                                       return 1;
+                               }
+                       }
+
+                       err = ber_printf( ber, /* { */ "N}" );
+                       if ( err == -1 ) {
+                               ber_free( ber, 1 );
+                               fprintf( stderr, "%s line %d: "
+                                       "chaining behavior control encoding error!\n",
+                                       c->fname, c->lineno );
+                               return 1;
+                       }
+
+                       if ( ber_flatten2( ber, &lc->lc_chaining_ctrl.ldctl_value, 0 ) == -1 ) {
+                               exit( EXIT_FAILURE );
+                       }
+
+               } else {
+                       BER_BVZERO( &lc->lc_chaining_ctrl.ldctl_value );
+               }
+
+               lc->lc_chaining_ctrl.ldctl_oid = LDAP_CONTROL_X_CHAINING_BEHAVIOR;
+               lc->lc_chaining_ctrl.ldctl_iscritical = iscritical;
+
+               if ( ldap_chain_parse_ctrl( &op, &rs, &lc->lc_chaining_ctrl ) != LDAP_SUCCESS )
+               {
+                       fprintf( stderr, "%s line %d: "
+                               "unable to parse chaining control%s%s\n",
+                               c->fname, c->lineno,
+                               rs.sr_text ? ": " : "",
+                               rs.sr_text ? rs.sr_text : "" );
+                       return 1;
+               }
+
+               lc->lc_chaining_ctrlflag = op.o_chaining;
+
+               lc->lc_flags |= LDAP_CHAIN_F_CHAINING;
+
+               rc = 0;
+
+               break;
+       }
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
+
+       default:
+               assert( 0 );
+               return 1;
+       }
+       return rc;
+}
+
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
+
 static int
 ldap_chain_db_config(
        BackendDB       *be,
        const char      *fname,
        int             lineno,
        int             argc,
-       char    **argv
-)
+       char            **argv )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
-       void            *private = be->be_private;
        char            *argv0 = NULL;
        int             rc;
+       BackendDB       db = *be;
 
        if ( strncasecmp( argv[ 0 ], "chain-", STRLENOF( "chain-" ) ) == 0 ) {
                argv0 = argv[ 0 ];
@@ -807,10 +1059,9 @@ ldap_chain_db_config(
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
        }
 
-
-       be->be_private = lc->lc_li;
-       rc = lback->bi_db_config( be, fname, lineno, argc, argv );
-       be->be_private = private;
+       db.be_cf_ocs = lback->bi_cf_ocs;
+       db.be_private = lc->lc_li;
+       rc = lback->bi_db_config( &db, fname, lineno, argc, argv );
 
 done:;
        if ( argv0 ) {
@@ -822,8 +1073,7 @@ done:;
 
 static int
 ldap_chain_db_init(
-       BackendDB *be
-)
+       BackendDB *be )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        ldap_chain_t    *lc = NULL;
@@ -841,6 +1091,8 @@ ldap_chain_db_init(
        lc = ch_malloc( sizeof( ldap_chain_t ) );
        memset( lc, 0, sizeof( ldap_chain_t ) );
 
+       ldap_pvt_thread_mutex_init( &lc->lc_mutex );
+
        bd.be_private = NULL;
        rc = lback->bi_db_init( &bd );
        lc->lc_li = (struct ldapinfo *)bd.be_private;
@@ -875,7 +1127,7 @@ ldap_chain_db_destroy(
 
        be->be_private = (void *)lc->lc_li;
        rc = lback->bi_db_destroy( be );
-       lc->lc_li = be->be_private;
+       ldap_pvt_thread_mutex_destroy( &lc->lc_mutex );
        ch_free( lc );
        on->on_bi.bi_private = NULL;
        be->be_private = private;
@@ -1033,9 +1285,9 @@ static slap_overinst ldapchain;
 int
 chain_init( void )
 {
-#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        int     rc;
 
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        rc = register_supported_control( LDAP_CONTROL_X_CHAINING_BEHAVIOR,
                        /* SLAP_CTRL_GLOBAL| */ SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL,
                        ldap_chain_parse_ctrl, &sc_chainingBehavior );
@@ -1066,6 +1318,13 @@ chain_init( void )
 
        ldapchain.on_response = ldap_chain_response;
 
+       ldapchain.on_bi.bi_cf_ocs = chainocs;
+
+       rc = config_register_schema( chaincfg, chainocs );
+       if ( rc ) {
+               return rc;
+       }
+
        return overlay_register( &ldapchain );
 }