在 Linux PAM 模块中检索用户命令

Retrieve user command in Linux PAM module

我写了一个 pam 模块,当用户执行 sudo 命令时调用。我已经得到了用户名密码tty,但是现在,我必须得到用户命令加密。

如果用户执行

sudo ls -l

我必须得到 ls -l

我的模块没有 pam 应用程序。 (所以我只使用pam_modules.h)并且我的模块首先在/etc/pam.d/sudo[中被调用=13=]

我想过像pam_tty_audit那样使用netlink套接字,但我不认为这是最好的方法(或最简单的)

你知道如何获取用户命令吗?

谢谢你,抱歉我的英语不好

改为根据the API documentation of sudo's authentication mechanisms, the command is not passed to the authentication backend, so PAM is the wrong place to do whatever you are trying to do. Consider writing a sudo plugin