[Date Prev][Date Next] [Chronological] [Thread] [Top]

ldapsearch returning a lot of big objects (ITS#321)



OpenLDAP 1.2
Solaris 2.5
gcc 2.95.1

    To whom it may concern, I was using ldapsearch with the following
    parameters: -t -B "sn=<name". Because I work in a fairly big
    organization, that kind of query can trigger a lot of return. I
    was using the -t flag because I was using eudc (an Emacs package),
    which uses ldapsearch.

    Because the number of the number of files created, I had 885 on
    some tests, mktemp was failing. I made some some modifications in
    ldapsearch.c to fix the problem. I also verified that the same
    thing happens with OpenLDAP 1.2.7.

    Here's the output of diff -bc for ldapsearch.c:

==================================================
*** ldapsearch.c.orig   Wed Aug 25 17:40:42 1999
--- ldapsearch.c        Thu Oct  7 16:23:57 1999
***************
*** 428,434 ****
      int               attrsonly)
  {
      char              *a, *dn, *ufn, tmpfname[ 64 ];
!     int                       i, j, notascii;
      BerElement                *ber;
      struct berval     **bvals;
      FILE              *tmpfp;
--- 428,434 ----
      int               attrsonly)
  {
      char              *a, *dn, *ufn, tmpfname[ 64 ];
!     int                       i, j, k, notascii;
      BerElement                *ber;
      struct berval     **bvals;
      FILE              *tmpfp;
***************
*** 450,457 ****
      }
      free( dn );
  
!     for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
!           a = ldap_next_attribute( ld, entry, ber ) ) {
        if ( skipsortattr && strcasecmp( a, sortattr ) == 0 ) {
            continue;
        }
--- 450,458 ----
      }
      free( dn );
  
!     for ( a = ldap_first_attribute( ld, entry, &ber ), k = 0;
!           a != NULL;
!           a = ldap_next_attribute( ld, entry, ber ), k++ ) {
        if ( skipsortattr && strcasecmp( a, sortattr ) == 0 ) {
            continue;
        }
***************
*** 464,470 ****
        } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
            for ( i = 0; bvals[i] != NULL; i++ ) {
                if ( vals2tmp ) {
!                   sprintf( tmpfname, "/tmp/ldapsearch-%s-XXXXXX", a );
                    tmpfp = NULL;
  
                    if ( mktemp( tmpfname ) == NULL ) {
--- 465,475 ----
        } else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
            for ( i = 0; bvals[i] != NULL; i++ ) {
                if ( vals2tmp ) {
!                   sprintf(tmpfname,
!                             "/tmp/ldapsearch-%s-%d-%d-XXXXXX",
!                             a,
!                             k,
!                             i);
                    tmpfp = NULL;
  
                    if ( mktemp( tmpfname ) == NULL ) {
==================================================

    I know, it's kind of a kludge, but it works.

    Hope this helps.

                                        Didier

-- 
Didier Fort             | Federal Express Corp.      | Tel: +1 (719) 262-1756
Didier.Fort@fedex.com   | 5450 Tech Center Drive     | Fax: +1 (719) 260-9739
didier.fort@computer.org| Colorado Springs, CO 80919 | From MEM: 588-1756
--
"A clear conscience is usually the sign of a bad memory."