~ubuntu-branches/ubuntu/wily/389-ds-base/wily-proposed

« back to all changes in this revision

Viewing changes to ldap/servers/plugins/deref/deref.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-07-08 15:50:11 UTC
  • mto: (19.1.1 experimental) (0.3.1)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20140708155011-48naeyka2x89ew8g
Tags: upstream-1.3.2.19
ImportĀ upstreamĀ versionĀ 1.3.2.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
606
606
    Slapi_Entry **entries = NULL;
607
607
    int rc;
608
608
 
609
 
    if (deref_check_access(pb, NULL, derefdn, attrs, &retattrs,
610
 
                           (SLAPI_ACL_SEARCH|SLAPI_ACL_READ))) {
611
 
        slapi_log_error(SLAPI_LOG_PLUGIN, DEREF_PLUGIN_SUBSYSTEM,
612
 
                        "The client does not have permission to read the requested "
613
 
                        "attributes in entry %s\n", derefdn);
614
 
        return;
615
 
    }
616
 
 
 
609
/*  If the access check on the attributes is done without retrieveing the entry
 
610
 *  it cannot handle acis which need teh entry, eg to apply a targetfilter rule
 
611
 *  So the determination of attrs which can be dereferenced is delayed
 
612
 */
617
613
    derefpb = slapi_pblock_new();
618
614
    slapi_search_internal_set_pb(derefpb, derefdn, LDAP_SCOPE_BASE,
619
615
                                 "(objectclass=*)", retattrs, 0,
632
628
            } else {
633
629
                int ii;
634
630
                int needattrvals = 1; /* need attrvals sequence? */
635
 
                for (ii = 0; retattrs[ii]; ++ii) {
636
 
                    Slapi_Value *sv;
637
 
                    int idx = 0;
638
 
                    Slapi_ValueSet* results = NULL;
639
 
                    int type_name_disposition = 0;
640
 
                    char* actual_type_name = NULL;
641
 
                    int flags = 0;
642
 
                    int buffer_flags = 0;
643
 
                    int needpartialattr = 1; /* need PartialAttribute sequence? */
644
 
                    int needvalsset = 1;
 
631
                if (deref_check_access(pb, entries[0], derefdn, attrs, &retattrs,
 
632
                          (SLAPI_ACL_SEARCH|SLAPI_ACL_READ))) {
 
633
                    slapi_log_error(SLAPI_LOG_PLUGIN, DEREF_PLUGIN_SUBSYSTEM,
 
634
                             "The client does not have permission to read the requested "
 
635
                             "attributes in entry %s\n", derefdn);
 
636
           } else {
 
637
                    for (ii = 0; retattrs[ii]; ++ii) {
 
638
                        Slapi_Value *sv;
 
639
                        int idx = 0;
 
640
                        Slapi_ValueSet* results = NULL;
 
641
                        int type_name_disposition = 0;
 
642
                        char* actual_type_name = NULL;
 
643
                        int flags = 0;
 
644
                        int buffer_flags = 0;
 
645
                        int needpartialattr = 1; /* need PartialAttribute sequence? */
 
646
                        int needvalsset = 1;
645
647
 
646
648
#if defined(USE_OLD_UNHASHED)
647
 
                    if (is_type_forbidden(retattrs[ii])) {
648
 
                        slapi_log_error(SLAPI_LOG_PLUGIN, DEREF_PLUGIN_SUBSYSTEM,
649
 
                            "skip forbidden attribute [%s]\n", derefdn);
650
 
                        continue;
651
 
                    }
 
649
                        if (is_type_forbidden(retattrs[ii])) {
 
650
                            slapi_log_error(SLAPI_LOG_PLUGIN, DEREF_PLUGIN_SUBSYSTEM,
 
651
                                "skip forbidden attribute [%s]\n", derefdn);
 
652
                            continue;
 
653
                        }
652
654
#endif
653
 
                    deref_get_values(entries[0], retattrs[ii], &results, &type_name_disposition,
654
 
                                     &actual_type_name, flags, &buffer_flags);
 
655
                        deref_get_values(entries[0], retattrs[ii], &results, &type_name_disposition,
 
656
                                         &actual_type_name, flags, &buffer_flags);
655
657
 
656
 
                    if (results) {
657
 
                        idx = slapi_valueset_first_value(results, &sv);
658
 
                    }
659
 
                    for (; results && sv; idx = slapi_valueset_next_value(results, idx, &sv)) {
660
 
                        const struct berval *bv = slapi_value_get_berval(sv);
661
 
                        if (needattrvals) {
662
 
                            /* we have at least one attribute with values in
663
 
                               DerefRes.attrVals */
664
 
                            /* attrVals is OPTIONAL - only added if there are
665
 
                               any values to send */
666
 
                            ber_printf(ctrlber, "t{", (LBER_CLASS_CONTEXT|LBER_CONSTRUCTED));
667
 
                            needattrvals = 0;
668
 
                        }
669
 
                        if (needpartialattr) {
670
 
                            /* This attribute in attrVals has values */
671
 
                            ber_printf(ctrlber, "{s", retattrs[ii]);
672
 
                            needpartialattr = 0;
673
 
                        }
674
 
                        if (needvalsset) {
675
 
                            /* begin the vals SET of values for this attribute */
676
 
                            ber_printf(ctrlber, "[");
677
 
                            needvalsset = 0;
678
 
                        }
679
 
                        ber_printf(ctrlber, "O", bv);
680
 
                    } /* for each value in retattrs[ii] */
681
 
                    deref_values_free(&results, &actual_type_name, buffer_flags);
682
 
                    if (needvalsset == 0) {
683
 
                        ber_printf(ctrlber, "]");
684
 
                    }
685
 
                    if (needpartialattr == 0) {
 
658
                        if (results) {
 
659
                            idx = slapi_valueset_first_value(results, &sv);
 
660
                        }
 
661
                        for (; results && sv; idx = slapi_valueset_next_value(results, idx, &sv)) {
 
662
                            const struct berval *bv = slapi_value_get_berval(sv);
 
663
                            if (needattrvals) {
 
664
                                /* we have at least one attribute with values in
 
665
                                   DerefRes.attrVals */
 
666
                                /* attrVals is OPTIONAL - only added if there are
 
667
                                   any values to send */
 
668
                                ber_printf(ctrlber, "t{", (LBER_CLASS_CONTEXT|LBER_CONSTRUCTED));
 
669
                                needattrvals = 0;
 
670
                            }
 
671
                            if (needpartialattr) {
 
672
                                /* This attribute in attrVals has values */
 
673
                                ber_printf(ctrlber, "{s", retattrs[ii]);
 
674
                                needpartialattr = 0;
 
675
                            }
 
676
                            if (needvalsset) {
 
677
                                /* begin the vals SET of values for this attribute */
 
678
                                ber_printf(ctrlber, "[");
 
679
                                needvalsset = 0;
 
680
                            }
 
681
                            ber_printf(ctrlber, "O", bv);
 
682
                        } /* for each value in retattrs[ii] */
 
683
                        deref_values_free(&results, &actual_type_name, buffer_flags);
 
684
                        if (needvalsset == 0) {
 
685
                            ber_printf(ctrlber, "]");
 
686
                        }
 
687
                        if (needpartialattr == 0) {
 
688
                            ber_printf(ctrlber, "}");
 
689
                        }
 
690
                    } /* for each attr in retattrs */
 
691
                    if (needattrvals == 0) {
686
692
                        ber_printf(ctrlber, "}");
687
693
                    }
688
 
                } /* for each attr in retattrs */
689
 
                if (needattrvals == 0) {
690
 
                    ber_printf(ctrlber, "}");
691
694
                }
692
695
            }
693
696
        } else { /* nothing */