]> git.sur5r.net Git - openldap/commitdiff
Fix config, chaining
authorHoward Chu <hyc@openldap.org>
Wed, 11 Jun 2003 06:32:24 +0000 (06:32 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 11 Jun 2003 06:32:24 +0000 (06:32 +0000)
servers/slapd/back-ldap/chain.c
servers/slapd/backover.c
servers/slapd/config.c

index 214a250649d6d8c73251d38be126e6fe1779ebe0..596c003d2d0249bea7af7ebb2dcb170946fbcc40 100644 (file)
@@ -40,32 +40,57 @@ ldap_chain_response( Operation *op, SlapReply *rs )
 {
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        void *private = op->o_bd->be_private;
+       slap_callback *sc = op->o_callback;
        LDAPControl **prev = op->o_ctrls;
-       LDAPControl **ctrls, authz;
+       LDAPControl **ctrls = NULL, authz;
        int i, nctrls, rc;
        int cache = op->o_do_not_cache;
+       char *authzid = NULL;
+       BerVarray ref;
 
        if ( rs->sr_err != LDAP_REFERRAL )
                return SLAP_CB_CONTINUE;
 
+       /* currently we assume only one referral destination.
+        * we'll have to parse this in the future.
+        */
+       ref = rs->sr_ref;
+       rs->sr_ref = NULL;
+
        op->o_bd->be_private = on->on_bi.bi_private;
-       for (i=0; prev && prev[i]; i++);
-       nctrls = i;
-
-       ctrls = op->o_tmpalloc((i+1)*sizeof(LDAPControl *), op->o_tmpmemctx);
-       for (i=0; i <nctrls; i++)
-               ctrls[i] = prev[i];
-       ctrls[nctrls] = &authz;
-       ctrls[nctrls+1] = NULL;
-       authz.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
-       authz.ldctl_iscritical = 1;
-       authz.ldctl_value = op->o_dn;
+       op->o_callback = NULL;
+
+       if ( op->o_tag != LDAP_REQ_BIND ) {
+               for (i=0; prev && prev[i]; i++);
+               nctrls = i;
+
+               /* Add an extra NULL slot */
+               if (!prev) i++;
+
+               ctrls = op->o_tmpalloc((i+1)*sizeof(LDAPControl *),
+                       op->o_tmpmemctx);
+               for (i=0; i <nctrls; i++)
+                       ctrls[i] = prev[i];
+               ctrls[nctrls] = &authz;
+               ctrls[nctrls+1] = NULL;
+               authz.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
+               authz.ldctl_iscritical = 1;
+               authz.ldctl_value = op->o_dn;
+               if ( op->o_dn.bv_len ) {
+                       authzid = op->o_tmpalloc( op->o_dn.bv_len+4,
+                               op->o_tmpmemctx );
+                       strcpy(authzid, "dn: ");
+                       strcpy(authzid+4, op->o_dn.bv_val);
+                       authz.ldctl_value.bv_len = op->o_dn.bv_len + 4;
+                       authz.ldctl_value.bv_val = authzid;
+               }
+               op->o_ctrls = ctrls;
+       }
 
        /* Chaining is performed by a privileged user on behalf
         * of a normal user
         */
        op->o_do_not_cache = 1;
-       op->o_ctrls = ctrls;
 
        switch( op->o_tag ) {
        case LDAP_REQ_BIND:
@@ -99,7 +124,10 @@ ldap_chain_response( Operation *op, SlapReply *rs )
        op->o_do_not_cache = cache;
        op->o_ctrls = prev;
        op->o_bd->be_private = private;
-       op->o_tmpfree( ctrls, op->o_tmpmemctx );
+       op->o_callback = sc;
+       if ( ctrls ) op->o_tmpfree( ctrls, op->o_tmpmemctx );
+       if ( authzid ) op->o_tmpfree( authzid, op->o_tmpmemctx );
+       rs->sr_ref = ref;
 
        return rc;
 }
index 6b29007eb19cee2b2f9655d1bb01e476aa3969fd..87025c1305dfe743616942951a7223cff8e6cda9 100644 (file)
@@ -37,7 +37,7 @@ over_db_func(
        BI_db_open **func;
        int rc = 0;
 
-       func = &oi->oi_bi.bi_db_open;
+       func = &oi->oi_bd.bd_info->bi_db_open;
        if ( func[which] ) {
                rc = func[which]( &oi->oi_bd );
                if ( rc ) return rc;
@@ -69,8 +69,8 @@ over_db_config(
        BackendDB bd;
        int rc = 0;
 
-       if ( oi->oi_bi.bi_db_config ) {
-               rc = oi->oi_bi.bi_db_config( &oi->oi_bd, fname, lineno,
+       if ( oi->oi_bd.bd_info->bi_db_config ) {
+               rc = oi->oi_bd.bd_info->bi_db_config( &oi->oi_bd, fname, lineno,
                        argc, argv );
                if ( rc ) return rc;
        }
@@ -179,7 +179,7 @@ over_op_func(
                }
        }
 
-       func = &oi->oi_bi.bi_op_bind;
+       func = &oi->oi_bd.bd_info->bi_op_bind;
        if ( func[which] ) {
                rc = func[which]( op, rs );
        }
index 9cf80a8575fd22d0c8b68e61bcc6033ee3324a43..5b5a366f8a25371a77f65a1fb8535a81056f0e3a 100644 (file)
@@ -935,8 +935,8 @@ read_config( const char *fname, int depth )
 #endif
                                return 1;
 
-                       } else {
-                               return overlay_config( be, cargv[1] );
+                       } else if ( overlay_config( be, cargv[1] )) {
+                               return 1;
                        }
 
                /* set database suffix */