From 20125eca06b4c2d3499a5f4f052d752e251156c6 Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Tue, 21 Feb 2012 11:53:54 +0100 Subject: [PATCH] fix: ldap_result does not succeed for sssd Resolves: #771484 --- openldap-result-write-polling.patch | 125 ++++++++++++++++++++++++++++ openldap.spec | 7 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 openldap-result-write-polling.patch diff --git a/openldap-result-write-polling.patch b/openldap-result-write-polling.patch new file mode 100644 index 0000000..9c71c7d --- /dev/null +++ b/openldap-result-write-polling.patch @@ -0,0 +1,125 @@ +ldap_result: only poll sockets for write as needed + +caused ldap_result() to return -1 in SSSD + +Author: Howard Chu +Upstream ITS: 7167 +Upstream commit: 33f6bc4fe623a2fdef02de1a84fdb93de1aad32a +Resolves: #771484 + +--- + libraries/libldap/ldap-int.h | 1 + + libraries/libldap/open.c | 2 -- + libraries/libldap/os-ip.c | 26 ++++++++++++++++++++++++++ + libraries/libldap/request.c | 1 + + libraries/libldap/result.c | 6 +++--- + 5 files changed, 31 insertions(+), 5 deletions(-) + +diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h +index c558d2a..ad37250 100644 +--- a/libraries/libldap/ldap-int.h ++++ b/libraries/libldap/ldap-int.h +@@ -622,6 +622,7 @@ LDAP_F (void) ldap_free_select_info( void *sip ); + LDAP_F (void) ldap_mark_select_write( LDAP *ld, Sockbuf *sb ); + LDAP_F (void) ldap_mark_select_read( LDAP *ld, Sockbuf *sb ); + LDAP_F (void) ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ); ++LDAP_F (void) ldap_clear_select_write( LDAP *ld, Sockbuf *sb ); + LDAP_F (int) ldap_is_read_ready( LDAP *ld, Sockbuf *sb ); + LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb ); + +diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c +index 6b92ba6..a920953 100644 +--- a/libraries/libldap/open.c ++++ b/libraries/libldap/open.c +@@ -344,7 +344,6 @@ ldap_init_fd( + + /* Add the connection to the *LDAP's select pool */ + ldap_mark_select_read( ld, conn->lconn_sb ); +- ldap_mark_select_write( ld, conn->lconn_sb ); + + *ldp = ld; + return LDAP_SUCCESS; +@@ -502,7 +501,6 @@ ldap_open_internal_connection( LDAP **ldp, ber_socket_t *fdp ) + + /* Add the connection to the *LDAP's select pool */ + ldap_mark_select_read( ld, c->lconn_sb ); +- ldap_mark_select_write( ld, c->lconn_sb ); + + /* Make this connection an LDAP V3 protocol connection */ + rc = LDAP_VERSION3; +diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c +index daa765e..2864256 100644 +--- a/libraries/libldap/os-ip.c ++++ b/libraries/libldap/os-ip.c +@@ -966,6 +966,32 @@ ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ) + #endif + } + ++void ++ldap_clear_select_write( LDAP *ld, Sockbuf *sb ) ++{ ++ struct selectinfo *sip; ++ ber_socket_t sd; ++ ++ sip = (struct selectinfo *)ld->ld_selectinfo; ++ ++ ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd ); ++ ++#ifdef HAVE_POLL ++ /* for UNIX poll(2) */ ++ { ++ int i; ++ for(i=0; i < sip->si_maxfd; i++) { ++ if( sip->si_fds[i].fd == sd ) { ++ sip->si_fds[i].events &= ~POLL_WRITE; ++ } ++ } ++ } ++#else ++ /* for UNIX select(2) */ ++ FD_CLR( sd, &sip->si_writefds ); ++#endif ++} ++ + + int + ldap_is_write_ready( LDAP *ld, Sockbuf *sb ) +diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c +index 88190a2..071391d 100644 +--- a/libraries/libldap/request.c ++++ b/libraries/libldap/request.c +@@ -202,6 +202,7 @@ ldap_int_flush_request( + + /* sent -- waiting for a response */ + ldap_mark_select_read( ld, lc->lconn_sb ); ++ ldap_clear_select_write( ld, lc->lconn_sb ); + } + return 0; + } +diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c +index b6e8e75..7241df9 100644 +--- a/libraries/libldap/result.c ++++ b/libraries/libldap/result.c +@@ -302,7 +302,7 @@ wait4msg( + if ( ber_sockbuf_ctrl( lc->lconn_sb, + LBER_SB_OPT_DATA_READY, NULL ) ) + { +- lc_ready = 1; ++ lc_ready = 2; /* ready at ber level, not socket level */ + break; + } + } +@@ -373,8 +373,8 @@ wait4msg( + } + } + LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex ); +- /* Quit looping if no one handled any events */ +- if (!serviced) ++ /* Quit looping if no one handled any socket events */ ++ if (!serviced && lc_ready == 1) + rc = -1; + } + LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex ); +-- +1.7.7.6 + diff --git a/openldap.spec b/openldap.spec index 786341b..d9b6909 100644 --- a/openldap.spec +++ b/openldap.spec @@ -8,7 +8,7 @@ Name: openldap Version: 2.4.29 -Release: 2%{?dist} +Release: 3%{?dist} Summary: LDAP support libraries Group: System Environment/Daemons License: OpenLDAP @@ -37,6 +37,7 @@ Patch5: openldap-ldaprc-currentdir.patch Patch6: openldap-userconfig-setgid.patch Patch7: openldap-dns-priority.patch Patch8: openldap-syncrepl-unset-tls-options.patch +Patch9: openldap-result-write-polling.patch # Fedora specific patches Patch100: openldap-fedora-systemd.patch @@ -140,6 +141,7 @@ pushd openldap-%{version} %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 %patch100 -p1 @@ -651,6 +653,9 @@ exit 0 %{evolution_connector_prefix}/ %changelog +* Tue Feb 21 2012 Jan Vcelak 2.4.29-3 +- fix: ldap_result does not succeed for sssd (#771484) + * Mon Feb 20 2012 Jan Vcelak 2.4.29-2 - fix update: provide ldif2ldbm, not ldib2ldbm (#437104) - Jan Synáček :