openldap-ldapi-sasl.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 69709289b083c53ba41d2cef7d65120220f8c59b Mon Sep 17 00:00:00 2001
  2. From: Sumit Bose <sbose@redhat.com>
  3. Date: Tue, 7 May 2013 17:02:57 +0200
  4. Subject: [PATCH] LDAPI SASL fix
  5. Resolves: #960222
  6. ---
  7. libraries/libldap/cyrus.c | 19 ++++++++++++++++---
  8. 1 Datei geändert, 16 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
  9. diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c
  10. index 28c241b..a9acf36 100644
  11. --- a/libraries/libldap/cyrus.c
  12. +++ b/libraries/libldap/cyrus.c
  13. @@ -394,6 +394,8 @@ ldap_int_sasl_bind(
  14. struct berval ccred = BER_BVNULL;
  15. int saslrc, rc;
  16. unsigned credlen;
  17. + char my_hostname[HOST_NAME_MAX + 1];
  18. + int free_saslhost = 0;
  19. Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: %s\n",
  20. mechs ? mechs : "<null>", 0, 0 );
  21. @@ -454,14 +456,25 @@ ldap_int_sasl_bind(
  22. /* If we don't need to canonicalize just use the host
  23. * from the LDAP URI.
  24. + * Always use the result of gethostname() for LDAPI.
  25. */
  26. - if ( nocanon )
  27. + if (ld->ld_defconn->lconn_server->lud_scheme != NULL &&
  28. + strcmp("ldapi", ld->ld_defconn->lconn_server->lud_scheme) == 0) {
  29. + rc = gethostname(my_hostname, HOST_NAME_MAX + 1);
  30. + if (rc == 0) {
  31. + saslhost = my_hostname;
  32. + } else {
  33. + saslhost = "localhost";
  34. + }
  35. + } else if ( nocanon )
  36. saslhost = ld->ld_defconn->lconn_server->lud_host;
  37. - else
  38. + else {
  39. saslhost = ldap_host_connected_to( ld->ld_defconn->lconn_sb,
  40. "localhost" );
  41. + free_saslhost = 1;
  42. + }
  43. rc = ldap_int_sasl_open( ld, ld->ld_defconn, saslhost );
  44. - if ( !nocanon )
  45. + if ( free_saslhost )
  46. LDAP_FREE( saslhost );
  47. }
  48. --
  49. 1.7.11.7