我正在编写一个PAM模块,它将用户名/密码写入文件,以供其他应用程序进一步处理.我只看到了PAM_AUTHTOK项,但我不确定它是从哪种类型开始的.有人知道这个或其他方式来获取明文密码吗?
这是一个非常老的线程,但也有pam_exec:https://linux.die.net/man/8/pam_exec
例如PAM Config中的以下内容:
auth sufficient pam_exec.so expose_authtok /usr/local/bin/myscript-example
Run Code Online (Sandbox Code Playgroud)
myscript示例的内容,回显所有变量:
#!/bin/sh
read password
echo "User: $PAM_USER"
echo "Ruser: $PAM_RUSER"
echo "Rhost: $PAM_RHOST"
echo "Service: $PAM_SERVICE"
echo "TTY: $PAM_TTY"
echo "Password : $password"
exit $?
Run Code Online (Sandbox Code Playgroud)
您是否阅读过 Linux-PAM 应用程序开发人员指南?在 RHEL 类型的系统上,这将位于其中,或者您可以在不同的地方在线/usr/share/doc/pam-devel-<version>/Linux-PAM_ADG.txt找到它。
查看获取 PAM 项目部分,其中记录了该pam_get_item()功能。您可以使用常量请求密码PAM_AUTH_TOK:
PAM_AUHTOK
Run Code Online (Sandbox Code Playgroud)The authentication token (often a password). This token should be ignored by all module functions besides pam_sm_authenticate(3) and pam_sm_chauthtok (3). In the former function it is used to pass the most recent authentication token from one stacked module to another. In the latter function the token is used for another purpose. It contains the currently active authentication token.