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

« back to all changes in this revision

Viewing changes to libraries/libldap/os-ip.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
1
/* os-ip.c -- platform-specific TCP & UDP related code */
2
 
/* $OpenLDAP: pkg/ldap/libraries/libldap/os-ip.c,v 1.118.2.8 2008/05/20 00:05:30 quanah Exp $ */
 
2
/* $OpenLDAP: pkg/ldap/libraries/libldap/os-ip.c,v 1.118.2.14 2009/02/10 23:42:16 quanah Exp $ */
3
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4
4
 *
5
 
 * Copyright 1998-2008 The OpenLDAP Foundation.
 
5
 * Copyright 1998-2009 The OpenLDAP Foundation.
6
6
 * Portions Copyright 1999 Lars Uffmann.
7
7
 * All rights reserved.
8
8
 *
207
207
                == AC_SOCKET_ERROR )
208
208
        {
209
209
                /* XXX: needs to be replace with ber_stream_read() */
210
 
                read(s, &ch, 1);
 
210
                int rc = read(s, &ch, 1);
211
211
                TRACE;
212
212
                return -1;
213
213
        }
424
424
}
425
425
#endif
426
426
 
 
427
int
 
428
ldap_int_connect_cbs(LDAP *ld, Sockbuf *sb, ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr)
 
429
{
 
430
        struct ldapoptions *lo;
 
431
        ldaplist *ll;
 
432
        ldap_conncb *cb;
 
433
        int rc;
 
434
 
 
435
        ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, s );
 
436
 
 
437
        /* Invoke all handle-specific callbacks first */
 
438
        lo = &ld->ld_options;
 
439
        for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) {
 
440
                cb = ll->ll_data;
 
441
                rc = cb->lc_add( ld, sb, srv, addr, cb );
 
442
                /* on any failure, call the teardown functions for anything
 
443
                 * that previously succeeded
 
444
                 */
 
445
                if ( rc ) {
 
446
                        ldaplist *l2;
 
447
                        for (l2 = lo->ldo_conn_cbs; l2 != ll; l2 = l2->ll_next) {
 
448
                                cb = l2->ll_data;
 
449
                                cb->lc_del( ld, sb, cb );
 
450
                        }
 
451
                        /* a failure might have implicitly closed the fd */
 
452
                        ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, s );
 
453
                        return rc;
 
454
                }
 
455
        }
 
456
        lo = LDAP_INT_GLOBAL_OPT();
 
457
        for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) {
 
458
                cb = ll->ll_data;
 
459
                rc = cb->lc_add( ld, sb, srv, addr, cb );
 
460
                if ( rc ) {
 
461
                        ldaplist *l2;
 
462
                        for (l2 = lo->ldo_conn_cbs; l2 != ll; l2 = l2->ll_next) {
 
463
                                cb = l2->ll_data;
 
464
                                cb->lc_del( ld, sb, cb );
 
465
                        }
 
466
                        lo = &ld->ld_options;
 
467
                        for (l2 = lo->ldo_conn_cbs; l2; l2 = l2->ll_next) {
 
468
                                cb = l2->ll_data;
 
469
                                cb->lc_del( ld, sb, cb );
 
470
                        }
 
471
                        ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, s );
 
472
                        return rc;
 
473
                }
 
474
        }
 
475
        return 0;
 
476
}
427
477
 
428
478
int
429
479
ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
430
 
        int proto,
431
 
        const char *host, int port,
 
480
        int proto, LDAPURLDesc *srv,
432
481
        int async )
433
482
{
434
483
        int     rc;
435
 
        int     socktype;
 
484
        int     socktype, port;
436
485
        ber_socket_t            s = AC_SOCKET_INVALID;
 
486
        char *host;
437
487
 
438
488
#if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
439
489
        char serv[7];
448
498
        char *ha_buf=NULL;
449
499
#endif
450
500
 
451
 
        if( host == NULL ) host = "localhost";
452
 
        
 
501
        if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
 
502
                host = "localhost";
 
503
        } else {
 
504
                host = srv->lud_host;
 
505
        }
 
506
 
 
507
        port = srv->lud_port;
 
508
 
 
509
        if( !port ) {
 
510
                if( strcmp(srv->lud_scheme, "ldaps") == 0 ) {
 
511
                        port = LDAPS_PORT;
 
512
                } else {
 
513
                        port = LDAP_PORT;
 
514
                }
 
515
        }
 
516
 
453
517
        switch(proto) {
454
518
        case LDAP_PROTO_TCP: socktype = SOCK_STREAM;
455
519
                osip_debug( ld,
469
533
 
470
534
#if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
471
535
        memset( &hints, '\0', sizeof(hints) );
472
 
#ifdef USE_AI_ATTRCONFIG /* FIXME: configure test needed */
473
 
        /* Use AI_ATTRCONFIG only on systems where its known to be needed. */
474
 
        hints.ai_flags = AI_ATTRCONFIG;
 
536
#ifdef USE_AI_ADDRCONFIG /* FIXME: configure test needed */
 
537
        /* Use AI_ADDRCONFIG only on systems where its known to be needed. */
 
538
        hints.ai_flags = AI_ADDRCONFIG;
475
539
#endif
476
540
        hints.ai_family = ldap_int_inet4or6;
477
541
        hints.ai_socktype = socktype;
537
601
                rc = ldap_pvt_connect( ld, s,
538
602
                        sai->ai_addr, sai->ai_addrlen, async );
539
603
                if ( rc == 0 || rc == -2 ) {
540
 
                        ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, &s );
541
 
                        break;
 
604
                        err = ldap_int_connect_cbs( ld, sb, &s, srv, sai->ai_addr );
 
605
                        if ( err )
 
606
                                rc = err;
 
607
                        else
 
608
                                break;
542
609
                }
543
610
                ldap_pvt_close_socket(ld, s);
544
611
        }
609
676
                        async);
610
677
   
611
678
                if ( (rc == 0) || (rc == -2) ) {
612
 
                        ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, &s );
613
 
                        break;
 
679
                        i = ldap_int_connect_cbs( ld, sb, &s, srv, (struct sockaddr *)&sin );
 
680
                        if ( i )
 
681
                                rc = i;
 
682
                        else
 
683
                                break;
614
684
                }
615
685
 
616
686
                ldap_pvt_close_socket(ld, s);
699
769
                char *herr;
700
770
#ifdef NI_MAXHOST
701
771
                char hbuf[NI_MAXHOST];
702
 
#elif defined( MAXHOSTNAMELEN
 
772
#elif defined( MAXHOSTNAMELEN )
703
773
                char hbuf[MAXHOSTNAMELEN];
704
774
#else
705
775
                char hbuf[256];
887
957
 
888
958
        sip = (struct selectinfo *)ld->ld_selectinfo;
889
959
 
 
960
        if (ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ))
 
961
                return 1;
 
962
 
890
963
        ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
891
964
 
892
965
#ifdef HAVE_POLL