我正在编写自定义pam规则,以限制/定义用户如何通过串行控制台登录到我的linux主机。
如果用户客户登录,我希望由pam_unix.so验证他的密码,而对于任何其他用户,我希望我的自定义身份验证程序执行相同的任务,并成为身份验证的最后一个词,也就是说,我根本不希望调用任何后续的pam模块。
这是我最小的工作/etc/pam.d/login文件。
# On success skip the next rule
auth [success=1 default=ignore] pam_succeed_if.so user in guest
auth [success=done default=ignore] pam_exec.so expose_authtok /usr/bin/custom-pam.sh
auth [success=1 default=ignore] pam_unix.so nullok
auth requisite pam_deny.so
auth required pam_permit.so当我以来宾身份登录时,上述配置正常工作( /var/log/journal也确认了这一点),但对其他用户来说却失败了。
如果/usr/bin/custom-pam.sh以0退出,我预计将停止对进一步模块的处理。根据我的理解,success=done应该立即返回,但这并没有发生。
发布于 2017-09-25 22:51:17
您试过PAM sufficient控件吗?每pam.conf(5)
sufficient
if such a module succeeds and no prior required module has failed
the PAM framework returns success to the application or to the
superior PAM stack immediately without calling any further modules
in the stack. A failure of a sufficient module is ignored and
processing of the PAM module stack continues unaffected.这将在您的自定义行停止处理:
auth sufficient pam_exec.so expose_authtok /usr/bin/custom-pam.sh除非它失败了,这可以由随后的拒绝-你-你-在这里行处理。
https://unix.stackexchange.com/questions/394425
复制相似问题