我希望能够执行一个自定义脚本时,帕姆做身份validation,但我得到一个错误,我似乎无法通过:
Feb 20 17:39:47 DC03R07DS25-08 sockd[2874]: pam_exec(sockd:auth): send password to child Feb 20 17:39:47 DC03R07DS25-08 sockd[2893]: pam_exec(sockd:auth): Calling /tmp/test.sh ... Feb 20 17:39:47 DC03R07DS25-08 sockd[2874]: pam_exec(sockd:auth): waitpid returns with -1: No child processes
这是一个非常基本的脚本,只是打印出一个0来允许转换。
#!/bin/bash # read the users password from stdin (pam_exec.so gives the provided password # if invoked with expose_authtok) read password echo $password > /tmp/a.txt exit 0
这是我的pam.dconfiguration:
auth required pam_exec.so debug expose_authtok /tmp/test.sh account required pam_permit.so
这是我第一次和我一起玩,和我一起玩。 我在这里做错了什么?
PS我真的需要expose_authtok所以我可以访问该脚本中的密码。
这似乎是一个收获的种族。 调用进程(sockd?)设置了SIGCHLD处理程序,该处理程序取决于test.sh而不是pam_exec。 请参阅https://lists.andrew.cmu.edu/pipermail/cyrus-sasl/2009-January/001627.html
编辑:对不起,让我解释一下你可以在上面的链接find:当我遇到这个错误,我不得不重新编译pam_exec.so与pam_exec.c中的一些修改。 在fork()之前将SIGCHLD处理程序设置为默认值,并在waitpid()之后和fork失败之后将其重置(pid == – 1分支)。 就像是:
组:
struct sigaction newact, oldact; newact.sa_handler = SIG_DFL; newact.sa_flags = 0; sigfillset(&newact.sa_mask); sigaction (SIGCHLD, &newact, &oldact);
重启:
sigaction (SIGCHLD, &oldact, NULL);