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

« back to all changes in this revision

Viewing changes to libraries/libldap/request.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Steve Langasek, Mathias Gug
  • Date: 2009-02-18 18:44:00 UTC
  • mfrom: (1.1.2 upstream) (0.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20090218184400-zw4mjse9eywt5566
Tags: 2.4.14-0ubuntu1
[ Steve Langasek ]
* New upstream version
  - Fixes a bug with the pcache overlay not returning cached entries
    (closes: #497697)
  - Update evolution-ntlm patch to apply to current Makefiles.
  - (tentatively) drop gnutls-ciphers, since this bug was reported to be
    fixed upstream in 2.4.8.  The fix applied in 2.4.8 didn't match the
    patch from the bug report, so this should be watched for regressions.
* Build against db4.7 instead of db4.2 at last!  Closes: #421946.
* Build with --disable-ndb, to avoid a misbuild when libmysqlclient is
  installed in the build environment.
* New patch, no-crlcheck-for-gnutls, to fix a build failure when using
  --with-tls=gnutls.

[ Mathias Gug ]
* Merge from debian unstable, remaining changes:
  - debian/apparmor-profile: add AppArmor profile
  - debian/slapd.postinst: Reload AA profile on configuration
  - updated debian/slapd.README.Debian for note on AppArmor
  - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6
  - debian/control: Conflicts with apparmor-profiles << 2.1+1075-0ubuntu4
    to make sure that if earlier version of apparmour-profiles gets
    installed it won't overwrite our profile.
  - Modify Maintainer value to match the DebianMaintainerField
    speficication.
  - follow ApparmorProfileMigration and force apparmor compalin mode on 
    some upgrades (LP: #203529)
  - debian/slapd.dirs: add etc/apparmor.d/force-complain
  - debian/slapd.preinst: create symlink for force-complain on pre-feisty
    upgrades, upgrades where apparmor-profiles profile is unchanged (ie
    non-enforcing) and upgrades where apparmor profile does not exist.
  - debian/slapd.postrm: remove symlink in force-complain/ on purge
  - debian/patches/fix-ucred-libc due to changes how newer glibc handle
    the ucred struct now.
  - debian/control:
    - Build-depend on libltdl7-dev rather then libltdl3-dev.
  - debian/patches/autogen.sh:
    - Call libtoolize with the --install option to install config.{guess,sub}
      files.
  - Don't use local statement in config script as it fails if /bin/sh
    points to bash (LP: #286063).
  - Disable the testsuite on hppa. Allows building of packages on this
    architecture again, once this package is in the archive.
    LP: #288908.
  - debian/slapd.postinst, debian/slapd.script-common: set correct ownership
    and permissions on /var/lib/ldap, /etc/ldap/slapd.d (group readable) and
    /var/run/slapd (world readable). (LP: #257667).
  - debian/patches/nssov-build, debian/rules: 
    Build and package the nss overlay.
    debian/schema/misc.ldif: add ldif file for the misc schema, which defines
    rfc822MailMember (required by the nss overlay).
  - debian/{control,rules}: enable PIE hardening
  - Use cn=config as the default configuration backend instead of 
    slapd.conf. Migrate slapd.conf  file to /etc/ldap/slapd.d/ on upgrade
    asking the end user to enter a new password to control the access to the
    cn=config tree.
* debian/patches/corrupt-contextCSN: The contextCSN can get corrupted at
  times. (ITS: #5947)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $OpenLDAP: pkg/ldap/libraries/libldap/request.c,v 1.125.2.8 2008/05/27 20:08:37 quanah Exp $ */
 
1
/* $OpenLDAP: pkg/ldap/libraries/libldap/request.c,v 1.125.2.14 2009/02/09 20:37:57 quanah Exp $ */
2
2
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
3
 *
4
 
 * Copyright 1998-2008 The OpenLDAP Foundation.
 
4
 * Copyright 1998-2009 The OpenLDAP Foundation.
5
5
 * All rights reserved.
6
6
 *
7
7
 * Redistribution and use in source and binary forms, with or without
352
352
        return( msgid );
353
353
}
354
354
 
 
355
/* return 0 if no StartTLS ext, 1 if present, 2 if critical */
 
356
static int
 
357
find_tls_ext( LDAPURLDesc *srv )
 
358
{
 
359
        int i, crit;
 
360
        char *ext;
 
361
 
 
362
        if ( !srv->lud_exts )
 
363
                return 0;
 
364
 
 
365
        for (i=0; srv->lud_exts[i]; i++) {
 
366
                crit = 0;
 
367
                ext = srv->lud_exts[i];
 
368
                if ( ext[0] == '!') {
 
369
                        ext++;
 
370
                        crit = 1;
 
371
                }
 
372
                if ( !strcasecmp( ext, "StartTLS" ) ||
 
373
                        !strcasecmp( ext, "X-StartTLS" ) ||
 
374
                        !strcmp( ext, LDAP_EXOP_START_TLS )) {
 
375
                        return crit + 1;
 
376
                }
 
377
        }
 
378
        return 0;
 
379
}
 
380
 
355
381
LDAPConn *
356
382
ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
357
383
        int connect, LDAPreqinfo *bind )
426
452
        ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
427
453
#endif
428
454
 
 
455
        if ( connect ) {
 
456
#ifdef HAVE_TLS
 
457
                if ( lc->lconn_server->lud_exts ) {
 
458
                        int rc, ext = find_tls_ext( lc->lconn_server );
 
459
                        if ( ext ) {
 
460
                                LDAPConn        *savedefconn;
 
461
 
 
462
                                savedefconn = ld->ld_defconn;
 
463
                                ++lc->lconn_refcnt;     /* avoid premature free */
 
464
                                ld->ld_defconn = lc;
 
465
 
 
466
#ifdef LDAP_R_COMPILE
 
467
                                ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
 
468
                                ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
 
469
#endif
 
470
                                rc = ldap_start_tls_s( ld, NULL, NULL );
 
471
#ifdef LDAP_R_COMPILE
 
472
                                ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
 
473
                                ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
 
474
#endif
 
475
                                ld->ld_defconn = savedefconn;
 
476
                                --lc->lconn_refcnt;
 
477
 
 
478
                                if ( rc != LDAP_SUCCESS && ext == 2 ) {
 
479
                                        ldap_free_connection( ld, lc, 1, 0 );
 
480
                                        return NULL;
 
481
                                }
 
482
                        }
 
483
                }
 
484
#endif
 
485
        }
 
486
 
429
487
        if ( bind != NULL ) {
430
488
                int             err = 0;
431
489
                LDAPConn        *savedefconn;
642
700
                ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
643
701
#endif
644
702
 
 
703
                /* process connection callbacks */
 
704
                {
 
705
                        struct ldapoptions *lo;
 
706
                        ldaplist *ll;
 
707
                        ldap_conncb *cb;
 
708
 
 
709
                        lo = &ld->ld_options;
 
710
                        if ( lo->ldo_conn_cbs ) {
 
711
                                for ( ll=lo->ldo_conn_cbs; ll; ll=ll->ll_next ) {
 
712
                                        cb = ll->ll_data;
 
713
                                        cb->lc_del( ld, lc->lconn_sb, cb );
 
714
                                }
 
715
                        }
 
716
                        lo = LDAP_INT_GLOBAL_OPT();
 
717
                        if ( lo->ldo_conn_cbs ) {
 
718
                                for ( ll=lo->ldo_conn_cbs; ll; ll=ll->ll_next ) {
 
719
                                        cb = ll->ll_data;
 
720
                                        cb->lc_del( ld, lc->lconn_sb, cb );
 
721
                                }
 
722
                        }
 
723
                }
 
724
 
645
725
                if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) {
646
726
                        ldap_mark_select_clear( ld, lc->lconn_sb );
647
727
                        if ( unbind ) {
655
735
                }
656
736
 
657
737
                ldap_int_sasl_close( ld, lc );
 
738
#ifdef HAVE_GSSAPI
 
739
                ldap_int_gssapi_close( ld, lc );
 
740
#endif
658
741
 
659
742
                ldap_free_urllist( lc->lconn_server );
660
743
 
996
1079
                }
997
1080
 
998
1081
                if( srv->lud_crit_exts ) {
999
 
                        /* we do not support any extensions */
1000
 
                        ld->ld_errno = LDAP_NOT_SUPPORTED;
1001
 
                        rc = -1;
1002
 
                        goto done;
 
1082
                        int ok = 0;
 
1083
#ifdef HAVE_TLS
 
1084
                        /* If StartTLS is the only critical ext, OK. */
 
1085
                        if ( find_tls_ext( srv ) == 2 && srv->lud_crit_exts == 1 )
 
1086
                                ok = 1;
 
1087
#endif
 
1088
                        if ( !ok ) {
 
1089
                                /* we do not support any other extensions */
 
1090
                                ld->ld_errno = LDAP_NOT_SUPPORTED;
 
1091
                                rc = -1;
 
1092
                                goto done;
 
1093
                        }
1003
1094
                }
1004
1095
 
1005
1096
                /* check connection for re-bind in progress */
1007
1098
                        /* See if we've already requested this DN with this conn */
1008
1099
                        LDAPRequest *lp;
1009
1100
                        int looped = 0;
1010
 
                        int len = srv->lud_dn ? strlen( srv->lud_dn ) : 0;
 
1101
                        ber_len_t len = srv->lud_dn ? strlen( srv->lud_dn ) : 0;
1011
1102
                        for ( lp = origreq; lp; ) {
1012
1103
                                if ( lp->lr_conn == lc
1013
1104
                                        && len == lp->lr_dn.bv_len
1266
1357
                if (( lc = find_connection( ld, srv, 1 )) != NULL ) {
1267
1358
                        LDAPRequest *lp;
1268
1359
                        int looped = 0;
1269
 
                        int len = srv->lud_dn ? strlen( srv->lud_dn ) : 0;
 
1360
                        ber_len_t len = srv->lud_dn ? strlen( srv->lud_dn ) : 0;
1270
1361
                        for ( lp = lr; lp; lp = lp->lr_parent ) {
1271
1362
                                if ( lp->lr_conn == lc
1272
1363
                                        && len == lp->lr_dn.bv_len )