【问题标题】:UPDATED: Apache Chokes on PHP ldap_connect() Call更新:PHP ldap_connect() 调用上的 Apache Chokes
【发布时间】:2011-04-17 14:10:47
【问题描述】:

如果我在命令行上运行以下 PHP 代码,我会得到预期的结果:

php -r 'var_dump(ldap_connect("ldaps://ldaps.example.com", 636));'
resource(4) of type (ldap link)

但是,如果我把它放在 PHP 脚本中

<?php ldap_connect("ldaps://ldaps.example.com", 636); ?>

Apache 断开连接,例如,如果我从命令行点击脚本,这就是 cURL 返回的内容:

curl http://example.com/ldap_test.php
curl: (52) Empty reply from server

Apache access_log 从不显示该页面的命中,error_log 为空。

我知道 LDAP 服务器正在工作,因为我已经在另外两台服务器上对此进行了测试。我正在开发一个运行 PHP 5.2.9 和 Apache 的 Joyent 加速器。有人知道为什么 Apache 对此感到窒息吗?

更新:

今天我在运行问题脚本时使用 GDB 调试了 Apache。当脚本到达 ldap_connect() 行时,我在 GDB 中得到以下信息:

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1

我还不确定是什么导致了段错误,但至少我知道 Apache 实际上正在崩溃。

这是完整的回溯:

Breakpoint 1, 0x08094417 in ap_process_request ()
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
(gdb) where
#0  0xfe94b8bb in _free_unlocked () from /lib/libc.so.1
#1  0xfe94b86f in free () from /lib/libc.so.1
#2  0xfde2d7e8 in ldap_x_free () from /usr/lib/libldap.so.5
#3  0xfde3f78b in ldap_free_urldesc () from /usr/lib/libldap.so.5
#4  0xfd0943d9 in ldap_free_urllist () from /opt/local/lib/libldap-2.4.so.2
#5  0xfd087191 in ldap_ld_free () from /opt/local/lib/libldap-2.4.so.2
#6  0xfd07ce8f in ldap_initialize () from /opt/local/lib/libldap-2.4.so.2
#7  0xfd3831a1 in zif_ldap_connect () from /opt/local/lib/php/20040412/ldap.so
#8  0xfcbda874 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#9  0xfcbe1a23 in ZEND_DO_FCALL_SPEC_CONST_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#10 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#11 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#12 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#13 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#14 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#15 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#16 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
---Type <return> to continue, or q <return> to quit---
#17 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#18 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#19 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#20 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#21 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#22 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#23 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#24 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#25 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#26 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#27 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#28 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#29 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#30 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
---Type <return> to continue, or q <return> to quit---
   from /opt/local/lib/httpd/mod_php5.so
#31 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#32 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#33 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#34 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#35 0xfcbda985 in zend_do_fcall_common_helper_SPEC ()
   from /opt/local/lib/httpd/mod_php5.so
#36 0xfcbdad65 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER ()
   from /opt/local/lib/httpd/mod_php5.so
#37 0xfcbd9e99 in execute () from /opt/local/lib/httpd/mod_php5.so
#38 0xfcbbebaa in zend_execute_scripts () from /opt/local/lib/httpd/mod_php5.so
#39 0xfcb7f40e in php_execute_script () from /opt/local/lib/httpd/mod_php5.so
#40 0xfcc509ca in php_handler () from /opt/local/lib/httpd/mod_php5.so
#41 0x08085c2a in ap_run_handler ()
#42 0x0808638e in ap_invoke_handler ()
#43 0x08094ca7 in ap_internal_redirect ()
#44 0xfe48c232 in handler_redirect () from /opt/local/lib/httpd/mod_rewrite.so
#45 0x08085c2a in ap_run_handler ()
#46 0x0808638e in ap_invoke_handler ()
#47 0x08094471 in ap_process_request ()
#48 0x0809177c in ap_process_http_connection ()
---Type <return> to continue, or q <return> to quit---
#49 0x0808d426 in ap_run_process_connection ()
#50 0x0808d858 in ap_process_connection ()
#51 0x08099e89 in child_main ()
#52 0x08099f65 in make_child ()
#53 0x0809a472 in ap_mpm_run ()
#54 0x080709ab in main ()
(gdb) 

更新 2:

据我所知,问题始于这两个函数调用:

#3  0xfde3f78b in ldap_free_urldesc () from /usr/lib/libldap.so.5
#4  0xfd0943d9 in ldap_free_urllist () from /opt/local/lib/libldap-2.4.so.2

#4 (ldap_free_urllist) 中的函数是从 /opt/local/lib/libldap-2.4.so.2 中的库调用的,#3 是从 /usr/lib/libldap.so.5 中的库调用的.我不知道它是否正常,但我认为它不是。所以不知何故,这两个 LDAP 库都被加载了。

【问题讨论】:

  • 我收到以下错误:当我不使用 ldaps:// 时无法联系 LDAP 服务器
  • 我相信 ldap_connect() 只是返回一个资源而不建立连接,直到您调用下一个函数(例如 ldap_bind),您还调用了哪些 ldap_x 函数?编辑:对不起,删除了我上面的评论:)
  • 我没有在我的测试脚本中调用其他任何东西。我实际上只调用 ldap_connect()。这只是我在问题中的那行代码。
  • 您的测试 php 脚本中没有 vardump?
  • 我试过 var_dump,但脚本在 var_dump 发生之前崩溃:这是测试脚本在浏览器中运行时的样子:i.imgur.com/YEdIn.png 就像我说的 Apache 甚至没有注册在 access_log 中对该页面的点击。

标签: php apache ldap gdb lamp


【解决方案1】:

我看到您通过升级软件包解决了您的问题,但是如果您需要进一步调试正在发生的事情,您可以在 ldap_connect() 之前启用调试输出,如下所示:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

这应该用库调用填充 error.log

【讨论】:

    猜你喜欢
    • 2012-02-01
    • 2018-07-25
    • 1970-01-01
    • 2019-08-11
    • 2012-02-26
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    相关资源
    最近更新 更多