【发布时间】:2013-09-23 07:42:04
【问题描述】:
这在 Apache2.2 中完美运行,但在 2.4 中却不行(我现在需要使用 2.4):
<AuthnProviderAlias ldap myldap>
AuthLDAPBindDN cn=Manager,dc=example,dc=com
AuthLDAPBindPassword xxxx
AuthLDAPURL ldap://localhost:9011/dc=example,dc=com?uid?sub?(objectClass=*)
</AuthnProviderAlias>
Listen 48443
<VirtualHost myserver:48443>
<Directory /path/to/a/folder>
Options +ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AuthBasicProvider myldap mySecondLdap myThirdLdap ...
AuthType Basic
AuthName "LDAP authentication for folder"
Require valid-user
...
</Directory>
</VirtualHost>
直接使用来自Apache 2.4 mod_authnz_ldap 的指令在<Directory > 部分有效:
AuthLDAPBindDN cn=Manager,dc=example,dc=com
AuthLDAPBindPassword xxx
AuthLDAPURL ldap://localhost:9011/dc=example,dc=com?uid?sub?(objectClass=*)
AuthBasicProvider ldap
但这允许仅针对一个 LDAP 服务器进行身份验证,我必须针对至少两个进行身份验证。
因此使用AuthnProviderAlias,它现在是mod_authn_core core authentication module 的(2.4)一部分,而不是旧的2.2 LDAP authentication module mod_authn_alias。
我已经编译了所有 2.4.x 版本(从 2.4.1 到 2.4.6,甚至是当前版本),使用 APR 1.4.8, and APR-util 1.5.2,在调试模式下 (-g -O0)
我尝试的是调试会话(gdb --command=debug,带有 'debug' 的 gdb 参数文件如下):
file /home/vonc/usr/local/apps/apache/bin/httpd
set logging file /home/vonc/gdb.txt
set logging on
set args -X
show args
set breakpoint pending on
# authn_alias_check_password
b mod_authn_core.c:115
# authaliassection
b mod_authn_core.c:203
b mod_authn_core.c:255
run
wh
fs next
where
我看到的是:
-
authaliassectionfunction ofmod_authn_core被称为两次,可能是因为server/main.c调用ap_process_config_tree两次(once here和once there)在同一个@ 987654330@.
那个函数gets the authcfg
authn_alias_srv_conf *authcfg =
(authn_alias_srv_conf *)ap_get_module_config(r->server->module_config,
&authn_core_module);
而sets the provider 具有正确的名称“ldap”和正确的别名“myldap”
apr_hash_set(authcfg->alias_rec, provider_alias, APR_HASH_KEY_STRING, prvdraliasrec);
但是:当需要检查密码时(在authn_alias_check_password中,它再次得到authcfg,然后fetch the provider:
provider_alias_rec *prvdraliasrec = apr_hash_get(authcfg->alias_rec,
provider_name, APR_HASH_KEY_STRING);
它使用正确的 provider_name 'myldap', ... 并且总是返回 null。
这意味着prvdraliasrec->provider->check_password 永远不会被调用。
http-dev mailing list (August 23, 2013 "Is AuthnProviderAlias subtly broken in 2.4?") 中的一个类似问题......没有得到解答。
您将如何解决此错误?
【问题讨论】:
-
我唯一的建议是使用 gdb 跟踪具有工作 ldap 配置的服务器的身份验证序列,希望这会暴露配置行为之间的差异
-
@GearoidMurphy 这意味着在 Apache 2.2 中进行跟踪。并且在 2.2 和 2.4 之间进行了一些大规模的重构......在移动的代码中找出错误并不容易。
标签: c apache configuration ldap