我遇到了一个死的简单的Python脚本的问题; 用pam_exec调用。
我在该文件/etc/pam.d/common-session的末尾添加了一行:
会话可选pam_exec.so / bin / python /usr/local/bin/pam_notify_python.py
pam_notify_python.py脚本包含一个简单的print "Hello world"
显然,这是行不通的,但我不明白为什么。 当我su user或简单su ,脚本不打印任何东西,但是当我启动一个新的shell并手动执行python /usr/local/bin/pam_notify_python.py它正在工作。
我错过了什么 ? 谢谢阅读 !
pam_exec(8)手册页说明了原因:
stdout Per default the output of the executed command is written to /dev/null. With this option, the stdout output of the executed command is redirected to the calling application. It's in the responsibility of this application what happens with the output. The log option is ignored.
所以你需要添加stdout到该行:
session optional pam_exec.so stdout /bin/python /usr/local/bin/pam_notify_python.py