php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72064 ldap_connect sees correct args as *uninitialized*
Submitted: 2016-04-20 13:48 UTC Modified: 2018-06-24 04:22 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: hcoin at quietfountain dot com Assigned:
Status: No Feedback Package: LDAP related
PHP Version: 5.6.20 OS: Ubuntu xenial
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hcoin at quietfountain dot com
New email:
PHP Version: OS:

 

 [2016-04-20 13:48 UTC] hcoin at quietfountain dot com
Description:
------------
Calls to ldap_connect with present and correct arguments randomly returns 'False'. Same code run again, even in the same debug session, succeeds.

Single stepping with xdebug, examining the variables each step, shows no differences in any variable whether the bind call then fails or works.

When it does fail, the debug log shows:

2016/04/20 07:36:49 [error] 4429#4429: *30 FastCGI sent in stderr: "PHP message: PHP Warning:  ldap_bind(): Unable to bind to server: Can't contact LDAP server in /var/www/fusionpbx/foo.php on line 18
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /var/www/fusionpbx/foo.php:0
PHP message: PHP   2. ldap_bind(*uninitialized*, *uninitialized*, *uninitialized*) /var/www/fusionpbx/foo.php:18" while reading response header from upstream, client: 192.168.29.16, server: pbx, request: "GET /foo.php?XDEBUG_SESSION_START=netbeans-xdebug HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "pbx1.foo.com"

Note: the 'ldaps'.  This implementation requires the server to send the caller a valid certificate, but also requires the caller to send the server a valid certificate.
dpkg -l | egrep 'ldap|php|ssl|tls' | grep -vi codec
ii  ldap-utils                         2.4.42+dfsg-2ubuntu3              amd64        OpenLDAP utilities
ii  libcurl3-gnutls:amd64              7.47.0-1ubuntu2                   amd64        easy-to-use client-side URL transfer library (GnuTLS flavour)
ii  libgnutls-deb0-28:amd64            3.3.20-1ubuntu1                   amd64        GNU TLS library - main runtime library
ii  libgnutls-openssl27:amd64          3.4.10-4ubuntu1                   amd64        GNU TLS library - OpenSSL wrapper
ii  libgnutls30:amd64                  3.4.10-4ubuntu1                   amd64        GNU TLS library - main runtime library
ii  libldap-2.4-2:amd64                2.4.42+dfsg-2ubuntu3              amd64        OpenLDAP libraries
ii  libssl1.0.0:amd64                  1.0.2g-1ubuntu4                   amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl1.0.2:amd64                  1.0.2g-1+deb.sury.org~wily+1      amd64        Secure Sockets Layer toolkit - shared libraries
ii  openssl                            1.0.2g-1+deb.sury.org~wily+1      amd64        Secure Sockets Layer toolkit - cryptographic utility
ii  php-cli                            1:7.0+35ubuntu6                   all          command-line interpreter for the PHP scripting language (default)
ii  php-common                         1:35ubuntu6                       all          Common files for PHP packages
ii  php-pear                           1:1.10.1+submodules+notgz-6       all          PEAR Base System
ii  php-xml                            1:7.0+35ubuntu6                   all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php5-cli                           5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        command-line interpreter for the php5 scripting language
ii  php5-common                        5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        Common files for packages built from the php5 source
ii  php5-curl                          5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        CURL module for php5
ii  php5-fpm                           5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5-gd                            5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        GD module for php5
ii  php5-imap                          5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        IMAP module for php5
ii  php5-json                          1.3.9-1+deb.sury.org~wily+4       amd64        JSON module for php5
ii  php5-ldap                          5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        LDAP module for php5
ii  php5-mcrypt                        5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        MCrypt module for php5
ii  php5-memcache                      3.0.8-5build1                     amd64        memcache extension module for PHP5
ii  php5-mysql                         5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        MySQL module for php5
ii  php5-odbc                          5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        ODBC module for php5
ii  php5-readline                      5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        Readline module for php5
ii  php5-sqlite                        5.6.20+dfsg-1+deb.sury.org~wily+1 amd64        SQLite module for php5
ii  php5-xdebug                        2.3.3-3+deb.sury.org~wily+1       amd64        Xdebug Module for PHP 5
rc  php5.6-phpdbg                      5.6.17+dfsg-5                     amd64        server-side, HTML-embedded scripting language (PHPDBG binary)



uname -a
Linux pbx1.foo.com 4.4.0-18-generic #34-Ubuntu SMP Wed Apr 6 14:01:02 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


Test script:
---------------
<?php

$tls_cert="/etc/ldap/certs/pbx.client.rsa.midterm.pem";
$tls_key ="/etc/ldap/certs/pbx.client.rsa.midterm.key.pkcs8.pem";
 
#putenv("LDAPTLS_CACERT=$tls_cacert");
putenv("LDAPTLS_CERT=$tls_cert");
putenv("LDAPTLS_KEY=$tls_key");

$c=ldap_connect('ldaps://directory.foo.com');
var_dump($c);
if (ldap_set_option($c, LDAP_OPT_PROTOCOL_VERSION, 3)) {
    echo "Using LDAPv3\n";
} else {
    echo "Failed to set protocol version to 3\n";
}
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$d=ldap_bind($c,'cn=Harry Coin,ou=people,dc=foo,dc=com','bar');
var_dump($d);
exit;
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-20 19:52 UTC] bishop@php.net
-Status: Open +Status: Feedback
 [2018-02-20 19:52 UTC] bishop@php.net
Given the intermittent nature, I suspect the underlying system call is being interrupted. Can you try with LDAP_OPT_RESTART, as in:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
ldap_set_option(NULL, LDAP_OPT_RESTART, 1);
$c=ldap_connect('ldaps://directory.foo.com');
// ... as before
 [2018-06-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC