~ubuntu-branches/ubuntu/maverick/openldap/maverick-proposed

« back to all changes in this revision

Viewing changes to servers/slapd/overlays/translucent.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-09-07 13:41:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090907134110-jsdrvn0atu1fex4m
Tags: upstream-2.4.18
ImportĀ upstreamĀ versionĀ 2.4.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* translucent.c - translucent proxy module */
2
 
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/translucent.c,v 1.13.2.27 2009/06/08 19:27:05 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/translucent.c,v 1.13.2.32 2009/08/25 23:05:25 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
5
 * Copyright 2004-2009 The OpenLDAP Foundation.
158
158
 
159
159
        /* FIXME: should not hardcode "olcDatabase" here */
160
160
        bv.bv_len = snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
161
 
                "olcDatabase=%s", ov->db.bd_info->bi_type );
 
161
                "olcDatabase=" SLAP_X_ORDERED_FMT "%s",
 
162
                0, ov->db.bd_info->bi_type );
162
163
        if ( bv.bv_len >= sizeof( ca->cr_msg ) ) {
163
164
                return -1;
164
165
        }
282
283
}
283
284
 
284
285
/*
285
 
** dup_bervarray()
286
 
**      copy a BerVarray;
287
 
*/
288
 
 
289
 
BerVarray dup_bervarray(BerVarray b) {
290
 
        int i, len;
291
 
        BerVarray nb;
292
 
        for(len = 0; b[len].bv_val; len++);
293
 
        nb = ch_malloc((len+1) * sizeof(BerValue));
294
 
        for(i = 0; i < len; i++) ber_dupbv(&nb[i], &b[i]);
295
 
        nb[len].bv_val = NULL;
296
 
        nb[len].bv_len = 0;
297
 
        return(nb);
298
 
}
299
 
 
300
 
/*
301
286
** free_attr_chain()
302
287
**      free only the Attribute*, not the contents;
303
288
**
785
770
        Filter *orig;
786
771
        Avlnode *list;
787
772
        int step;
 
773
        int slimit;
 
774
        AttributeName *attrs;
788
775
} trans_ctx;
789
776
 
790
777
static int translucent_search_cb(Operation *op, SlapReply *rs) {
809
796
        Debug(LDAP_DEBUG_TRACE, "==> translucent_search_cb: %s\n",
810
797
                rs->sr_entry->e_name.bv_val, 0, 0);
811
798
 
 
799
        op->ors_slimit = tc->slimit + ( tc->slimit > 0 ? 1 : 0 );
 
800
        if ( op->ors_attrs == slap_anlist_all_attributes ) {
 
801
                op->ors_attrs = tc->attrs;
 
802
                rs->sr_attrs = tc->attrs;
 
803
                rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
 
804
        }
 
805
 
812
806
        on = tc->on;
813
807
        ov = on->on_bi.bi_private;
814
808
 
834
828
                                if ( rc == LDAP_COMPARE_TRUE ) {
835
829
                                        rs->sr_flags |= REP_ENTRY_MUSTBEFREED;
836
830
                                        rs->sr_entry = re;
 
831
 
 
832
                                        if ( tc->slimit >= 0 && rs->sr_nentries >= tc->slimit ) {
 
833
                                                return LDAP_SIZELIMIT_EXCEEDED;
 
834
                                        }
 
835
 
837
836
                                        return SLAP_CB_CONTINUE;
838
837
                                } else {
839
838
                                        entry_free( re );
883
882
                for(ax = le->e_attrs; ax; ax = ax->a_next) {
884
883
                        for(a = re->e_attrs; a; a = a->a_next) {
885
884
                                if(a->a_desc == ax->a_desc) {
 
885
                                        test_f = 1;
886
886
                                        if(a->a_vals != a->a_nvals)
887
887
                                                ber_bvarray_free(a->a_nvals);
888
888
                                        ber_bvarray_free(a->a_vals);
889
 
                                        a->a_vals = dup_bervarray(ax->a_vals);
890
 
                                        a->a_nvals = (ax->a_vals == ax->a_nvals) ?
891
 
                                                a->a_vals : dup_bervarray(ax->a_nvals);
 
889
                                        ber_bvarray_dup_x( &a->a_vals, ax->a_vals, NULL );
 
890
                                        if ( ax->a_vals == ax->a_nvals ) {
 
891
                                                a->a_nvals = a->a_vals;
 
892
                                        } else {
 
893
                                                ber_bvarray_dup_x( &a->a_nvals, ax->a_nvals, NULL );
 
894
                                        }
892
895
                                        break;
893
896
                                }
894
897
                        }
963
966
        }
964
967
 
965
968
        op->o_bd = db;
 
969
 
 
970
        if ( rc == SLAP_CB_CONTINUE && tc->slimit >= 0 && rs->sr_nentries >= tc->slimit ) {
 
971
                return LDAP_SIZELIMIT_EXCEEDED;
 
972
        }
 
973
 
966
974
        return rc;
967
975
}
968
976
 
1105
1113
        tc.orig = op->ors_filter;
1106
1114
        tc.list = NULL;
1107
1115
        tc.step = 0;
 
1116
        tc.slimit = op->ors_slimit;
 
1117
        tc.attrs = NULL;
1108
1118
        fbv = op->ors_filterstr;
1109
1119
 
1110
1120
        op->o_callback = &cb;
1111
1121
 
1112
1122
        if ( fr || !fl ) {
1113
 
                AttributeName *attrs = op->ors_attrs;
1114
 
                op->ors_attrs = NULL;
 
1123
                tc.attrs = op->ors_attrs;
 
1124
                op->ors_slimit = SLAP_NO_LIMIT;
 
1125
                op->ors_attrs = slap_anlist_all_attributes;
1115
1126
                op->o_bd = &ov->db;
1116
1127
                tc.step |= RMT_SIDE;
1117
1128
                if ( fl ) {
1120
1131
                        filter2bv_x( op, fr, &op->ors_filterstr );
1121
1132
                }
1122
1133
                rc = ov->db.bd_info->bi_op_search(op, rs);
1123
 
                op->ors_attrs = attrs;
 
1134
                op->ors_attrs = tc.attrs;
1124
1135
                op->o_bd = tc.db;
1125
1136
                if ( fl ) {
1126
1137
                        op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
1137
1148
        op->ors_filter = tc.orig;
1138
1149
        op->o_callback = cb.sc_next;
1139
1150
        rs->sr_attrs = op->ors_attrs;
 
1151
        rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
1140
1152
 
1141
1153
        /* Send out anything remaining on the list and finish */
1142
1154
        if ( tc.step & USE_LIST ) {
1162
1174
                send_ldap_result( op, rs );
1163
1175
        }
1164
1176
 
 
1177
        op->ors_slimit = tc.slimit;
 
1178
 
1165
1179
        /* Free in reverse order */
1166
1180
        if ( fl )
1167
1181
                trans_filter_free( op, fl );