LDAPサーバ利用不可時にローカルログインできない

【やりたいこと】
LDAPサーバのslapdが落ちている場合、デフォルトではローカルユーザでもログインできなくなる。
これを防ぐために、LDAPサーバに接続できない場合は、すぐに断念してローカルユーザでログインできるようにしたい。

【手順】
・とりあえず/etc/ldap.confでbind_policyをhard(デフォルト)からsoftに変更
・/etc/pam.d/system-authを以下のように変更

#account [default=bad success=ok user_unknown=ignore] pam_ldap.so
account [default=bad success=ok user_unknown=ignore service_err=ignore \
system_err=ignore authinfo_unavail=ignore] pam_ldap.so

→認証情報を取得できない場合はリトライし続けず断念するようになった。

・ログインできるようにはなったが、10秒以上かかる…
→バインドできない場合に数度リトライするが、諦めるまでの時間が3秒あり、結局ログインするまでに10秒以上の時間がかかってしまう。

・/etc/ldap.confでbind_timelimitの値を1に変更
→バインドを諦めるまでの時間を1秒にし、とりあえず5秒ほどでログインできるようにはなった。

【まだ不明なこと】
・bind_policyをsoftにしても数度リトライがかかるのは仕様?
・bind_timelimit=120秒の場合も3秒でバインドを断念するのはどこのパラメータの影響?

【変更内容まとめ】
■/etc/ldap.conf
bind_policy=soft
bind_timelimit=1
# timelimitの値は変更してもしなくてもリトライ間隔は変わらず

以下は/var/log/secure検証時のメモ。

timelimit=1
bind_timelimit=1

Sep 29 11:45:00 client1 sshd[4326]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Sep 29 11:45:00 client1 sshd[4326]: Accepted password for user1 from 192.168.XXX.XXX port XXXX ssh2
Sep 29 11:45:01 client1 sshd[4326]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:45:01 client1 sshd[4326]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:45:02 client1 sshd[4326]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:45:02 client1 sshd[4326]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:45:02 client1 sshd[4326]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
Sep 29 11:45:03 client1 sshd[4328]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:45:03 client1 sshd[4328]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:45:04 client1 sshd[4328]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:45:04 client1 sshd[4328]: nss_ldap: could not search LDAP server - Server is unavailable

                                                                                                                                                                                                                                                              • -

timelimit=1
bind_timelimit=120(デフォルト)

Sep 29 11:48:15 client1 sshd[4365]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Sep 29 11:48:15 client1 sshd[4365]: Accepted password for user1 from 192.168.XXX.XXX port 3534 ssh2
Sep 29 11:48:18 client1 sshd[4365]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:48:18 client1 sshd[4365]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:48:21 client1 sshd[4365]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:48:21 client1 sshd[4365]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:48:21 client1 sshd[4365]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
Sep 29 11:48:24 client1 sshd[4367]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:48:24 client1 sshd[4367]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:48:24 client1 sshd[4367]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:48:24 client1 sshd[4367]: nss_ldap: could not search LDAP server - Server is unavailable

                                                                                                                                                                                                                                                              • -

timelimit=120(デフォルト)
bind_timelimit=1


Sep 29 11:49:16 client1 sshd[4402]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Sep 29 11:49:16 client1 sshd[4402]: Accepted password for user1 from 192.168.XXX.XXX port 4180 ssh2
Sep 29 11:49:17 client1 sshd[4402]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:49:17 client1 sshd[4402]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:49:18 client1 sshd[4402]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:49:18 client1 sshd[4402]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:49:18 client1 sshd[4402]: pam_unix(sshd:session): session opened for user user1 by (uid=0)
Sep 29 11:49:19 client1 sshd[4404]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:49:19 client1 sshd[4404]: nss_ldap: could not search LDAP server - Server is unavailable
Sep 29 11:49:20 client1 sshd[4404]: nss_ldap: failed to bind to LDAP server ldap://192.168.XXX.XXX: Can't contact LDAP server
Sep 29 11:49:20 client1 sshd[4404]: nss_ldap: could not search LDAP server - Server is unavailable