我正在尝试通过PAM为PostgreSQL 9.3设置身份validation。 我已经设法在Ubuntu 12.04服务器上运行,但是我无法在CentOS-6上安装。
相关的pg_hba.conf
行:
host all all 0.0.0.0/0 pam pamservice=postgresql93
pam.d/postgressql93
是官方postgresql 9.3软件包的默认configuration:
#%PAM-1.0 auth include password-auth account include password-auth
当用户尝试进行身份validation时,会在secure
日志中报告以下内容:
hostname unix_chkpwd[31807]: check pass; user unknown hostname unix_chkpwd[31808]: check pass; user unknown hostname unix_chkpwd[31808]: password check failed for user (myuser) hostname postgres 10.1.0.1(61459) authentication: pam_unix(postgresql93:auth): authentication failure; logname= uid=26 euid=26 tty= ruser= rhost= user=myuser
password-auth
configuration的相关内容是:
auth required pam_env.so auth sufficient pam_unix.so nullok try_first_pass auth requisite pam_succeed_if.so uid >= 500 quiet auth required pam_deny.so account required pam_unix.so account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 500 quiet account required pam_permit.so
问题在于pam_unix.so
。 无法validation密码,并且无法检索用户信息(当我删除pam_unix.so
的auth
条目时)。
Centos-6的安装只有5天的时间,所以没有太多的行李。
unix_chkpwd
是suid并且对每个人都有执行权限,所以它应该能够检查影子文件(根本没有特权?)。
我已经通过改变CentOS的设置来解决这个问题,使之更像Ubuntu中的设置。
我创build了一个低组ID,没有成员的组shadow
。 我将/etc/shadow
和/sbin/unit_chkpwd
组/sbin/unit_chkpwd
为创build的组shadow
。 最后我做了unix_chkpwd
SGID:
----r----- 1 root shadow 1049 Aug 22 16:38 /etc/shadow -rwxr-sr-x 1 root shadow 34840 Nov 22 2013 /sbin/unix_chkpwd
通过这些更改,我可以使用PAM为PostgreSQL的系统用户进行身份validation。 这些变化让我感觉不到安全问题。 尽pipe如果影子文件属于影子组,影子文件现在对非根用户是可读的。