Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-integ / recipes-support / openldap / files / 0012-openldap-ldapi-sasl.patch
1 From b2623b57b79becf707ff1800bfb5153af3f0d1fc Mon Sep 17 00:00:00 2001
2 From: babak sarashki <babak.sarashki@windriver.com>
3 Date: Wed, 4 Dec 2019 07:58:45 -0800
4 Subject: [PATCH 12/12] openldap ldapi sasl
5
6 From stx 1901: openldap-ldapi-sasl.patch
7 ---
8  libraries/libldap/cyrus.c | 19 ++++++++++++++++---
9  1 file changed, 16 insertions(+), 3 deletions(-)
10
11 diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c
12 index 8a496f990..06a9fdf41 100644
13 --- a/libraries/libldap/cyrus.c
14 +++ b/libraries/libldap/cyrus.c
15 @@ -385,6 +385,8 @@ ldap_int_sasl_bind(
16         struct berval   ccred = BER_BVNULL;
17         int saslrc, rc;
18         unsigned credlen;
19 +       char my_hostname[HOST_NAME_MAX + 1];
20 +       int free_saslhost = 0;
21  
22         Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: %s\n",
23                 mechs ? mechs : "<null>", 0, 0 );
24 @@ -445,14 +447,25 @@ ldap_int_sasl_bind(
25  
26                         /* If we don't need to canonicalize just use the host
27                          * from the LDAP URI.
28 +                        * Always use the result of gethostname() for LDAPI.
29                          */
30 -                       if ( nocanon )
31 +                       if (ld->ld_defconn->lconn_server->lud_scheme != NULL &&
32 +                           strcmp("ldapi", ld->ld_defconn->lconn_server->lud_scheme) == 0) {
33 +                               rc = gethostname(my_hostname, HOST_NAME_MAX + 1);
34 +                               if (rc == 0) {
35 +                                       saslhost = my_hostname;
36 +                               } else {
37 +                                       saslhost = "localhost";
38 +                               }
39 +                       } else if ( nocanon )
40                                 saslhost = ld->ld_defconn->lconn_server->lud_host;
41 -                       else 
42 +                       else {
43                                 saslhost = ldap_host_connected_to( ld->ld_defconn->lconn_sb,
44                                 "localhost" );
45 +                               free_saslhost = 1;
46 +                       }
47                         rc = ldap_int_sasl_open( ld, ld->ld_defconn, saslhost );
48 -                       if ( !nocanon )
49 +                       if ( free_saslhost )
50                                 LDAP_FREE( saslhost );
51                 }
52  
53 -- 
54 2.17.1
55