16.04 服务器:启用 LDAP 身份验证导致 systemd-logind 失败

16.04 服务器:启用 LDAP 身份验证导致 systemd-logind 失败

我在这里被难住了,如果我遗漏了一些显而易见的东西,请原谅。我有一个针对 LDAP 进行身份验证的 16.04 服务器,上次运行更新时它停止工作,我从头开始构建了一个干净的 16.04 服务器,运行了标准更新,它工作正常,直到我启用 LDAP 身份验证。我可以禁用 LDAP,然后它再次工作。

me@myserver:/etc# systemctl status systemd-logind.service
● systemd-logind.service - Login Service
   Loaded: loaded (/lib/systemd/system/systemd-logind.service; static; vendor preset: enabled)
   Active: activating (start) since Tue 2016-07-12 15:13:07 EDT; 19s ago
     Docs: man:systemd-logind.service(8)
           man:logind.conf(5)
           http://www.freedesktop.org/wiki/Software/systemd/logind
           http://www.freedesktop.org/wiki/Software/systemd/multiseat
 Main PID: 2106 (systemd-logind)
    Tasks: 1
   Memory: 228.0K
      CPU: 2ms
   CGroup: /system.slice/systemd-logind.service
           └─2106 /lib/systemd/systemd-logind

Jul 12 15:13:07 myserver systemd[1]: Starting Login Service...

它会运行一段时间,然后失败,然后尝试重新启动,如此循环往复。我可以登录本地帐户,但需要很长时间。

me@myserver:/etc# systemd-analyze blame
Bootup is not yet finished. Please try again later.

同时 journalctl -xe 返回其自身更详细的循环:

me@myserver:/etc# journalctl -xe
-- Subject: Unit systemd-logind.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-logind.service has failed.
-- 
-- The result is failed.
Jul 12 15:16:27 myserver systemd[1]: systemd-logind.service: Unit entered failed state.
Jul 12 15:16:27 myserver systemd[1]: systemd-logind.service: Failed with result 'exit-code'.
Jul 12 15:16:27 myserver systemd[1]: systemd-logind.service: Service has no hold-off time, scheduling restart.
Jul 12 15:16:27 myserver systemd[1]: Stopped Login Service.
-- Subject: Unit systemd-logind.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-logind.service has finished shutting down.
Jul 12 15:16:27 myserver systemd[1]: Starting Login Service...
-- Subject: Unit systemd-logind.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-logind.service has begun starting up.
Jul 12 15:16:52 myserver systemd-logind[2134]: Failed to enable subscription: Connection timed out
Jul 12 15:16:52 myserver systemd-logind[2134]: Failed to fully start up daemon: Connection timed out
Jul 12 15:16:52 myserver dbus[1012]: [system] Failed to activate service 'org.freedesktop.systemd1': timed out
Jul 12 15:16:52 myserver systemd[1]: systemd-logind.service: Main process exited, code=exited, status=1/FAILURE
Jul 12 15:16:52 myserver systemd[1]: Failed to start Login Service.

我有二十多个 14.04 服务器,它们使用 LDAP 运行良好,配置相同。

我尝试手动重新启动 systemd-logind 但失败了。

有什么想法吗?TIA。

(ETA:刚刚在 14.04 上构建了完全相同的系统,LDAP 身份验证运行良好。)

添加 dpkg.log 信息:这个文件中有很多噪音,所以不确定哪些是相关且有用的,但是这里似乎是相关包处理的终端行:

2016-07-11 13:52:08 status installed libldap-2.4-2:amd64 2.4.42+dfsg-2ubuntu3
2016-07-11 14:11:40 status installed libldap-2.4-2:amd64 2.4.42+dfsg-2ubuntu3.1
2016-07-11 15:02:45 status installed libnss-ldap:amd64 265-3ubuntu2
2016-07-11 15:02:45 status installed ldap-auth-client:all 0.5.3
2016-07-11 15:02:45 status installed ldap-auth-config:all 0.5.3
2016-07-11 15:02:45 status installed libpam-ldap:amd64 184-8.7ubuntu1
2016-07-11 15:04:12 status installed ldap-utils:amd64 2.4.42+dfsg-2ubuntu3.1

我的 LDAP 服务器在其他地方;此服务器只需要作为客户端对其进行身份验证。/etc/ldap.conf 和 /etc/ldap/ldap.conf 中的配置文件相同,似乎在 14.04 和 16.04 之间没有变化

值得注意的是,尽管 LDAP 身份验证不起作用,但我可以成功地对 LDAP 服务器执行 ldapsearch 查询。

答案1

我的 16.04 桌面客户端也遇到了同样的问题。

最后决定用 libnss-ldap 包替换libnss-ldapd

似乎与此错误报告中的问题相同:https://bugs.launchpad.net/ubuntu/+source/libnss-ldap/+bug/1024475

编辑:有关这些软件包的更多信息,请访问Debian 维基

目前有两个软件包可用于通过 LDAP 配置 NSS 查找:libnss-ldap 软件包和 libnss-ldapd 软件包。选择哪一个取决于需求。一般来说,libnss-ldapd 更简单但较新,而 libnss-ldap 更成熟但更复杂。另外libnss-ldap 在提供主机信息和启动期间查找方面存在一些已知问题,这些问题应在 libnss-ldapd 中解决。此外,使用 LDAP+SSL 时,libnss-ldap 会破坏 setuid 程序(su、sudo)

答案2

防止此问题的一种方法是确保nss_initgroups_ignoreusers参数 - in /etc/ldap.conf(或/etc/libnss-ldap.conf,取决于您的系统) - 填充了所有(本地)用户/etc/passwd

NSS_IGNOREUSERS="$(cut -d: -f1 /etc/passwd | sort | tr '\n' ',' | sed 's|,$||')"
sed -i "s|^nss_initgroups_ignoreusers.*|nss_initgroups_ignoreusers ${NSS_IGNOREUSERS}|" /etc/ldap.conf

这样,当系统启动并查询用户/组名称服务以启动本地服务时,就不会再发出“nss_ldap:无法联系 LDAP 服务器”(因为相应的本地用户/组被 NSS LDAP 忽略)。

(这个问题已经存在好几年了,与 systemd 无关)

相关内容