X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fos-local.c;h=7f1f83100261afd615a09b55dfbbef5efad50abe;hb=d9a60db75ea1dbbc06d90d15e6f6969d8c075ee7;hp=c0f21430bb99eae5ee08ef1559669f7405068806;hpb=80d1dba9017e31811c21ea6f6716b64422f82648;p=openldap diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index c0f21430bb..7f1f831002 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2008 The OpenLDAP Foundation. + * Copyright 1998-2011 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,7 +149,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) == AC_SOCKET_ERROR ) { /* XXX: needs to be replace with ber_stream_read() */ - read(s, &ch, 1); + (void)read(s, &ch, 1); TRACE; return -1; } @@ -234,7 +234,7 @@ sendcred: msg.msg_accrights = (char *)fds; msg.msg_accrightslen = sizeof(int); # endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */ - getpeername( s, sa, &salen ); + getpeername( s, (struct sockaddr *) sa, &salen ); fchmod( fds[0], S_ISUID|S_IRWXU ); write( fds[1], sa, salen ); sendmsg( s, &msg, 0 ); @@ -319,19 +319,15 @@ sendcred: } int -ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async) +ldap_connect_to_path(LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, int async) { struct sockaddr_un server; ber_socket_t s; int rc; + const char *path = srv->lud_host; oslocal_debug(ld, "ldap_connect_to_path\n",0,0,0); - s = ldap_pvt_socket( ld ); - if ( s == AC_SOCKET_INVALID ) { - return -1; - } - if ( path == NULL || path[0] == '\0' ) { path = LDAPI_SOCK; } else { @@ -341,6 +337,11 @@ ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async) } } + s = ldap_pvt_socket( ld ); + if ( s == AC_SOCKET_INVALID ) { + return -1; + } + oslocal_debug(ld, "ldap_connect_to_path: Trying %s\n", path, 0, 0); memset( &server, '\0', sizeof(server) ); @@ -350,20 +351,9 @@ ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async) rc = ldap_pvt_connect(ld, s, &server, async); if (rc == 0) { - ldaplist *ll; - struct ldapoptions *lo; - ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, (void *)&s ); - lo = &ld->ld_options; - for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) { - ldap_conncb *cb = ll->ll_data; - cb->lc_add( ld, sb, path, (struct sockaddr *)&server, cb ); - } - lo = LDAP_INT_GLOBAL_OPT(); - for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) { - ldap_conncb *cb = ll->ll_data; - cb->lc_add( ld, sb, path, (struct sockaddr *)&server, cb ); - } - } else { + rc = ldap_int_connect_cbs( ld, sb, &s, srv, (struct sockaddr *)&server ); + } + if ( rc ) { ldap_pvt_close_socket(ld, s); } return rc;