我正在设置一个 bash/html CGI,它允许我在 RedHat 7.6 下使用 GnuPlot 生成图形。 我的导师要求我创建一个 cgi 脚本,该脚本将能够返回没有密码的 sudo id(root),仅使用“id ”命令,而不是“sudo id ”
我刚刚在我的 cgi 源代码中添加了 id 命令,以便在我的 cgi 第一页上显示该命令的结果:
实际上,如果我在我的一个 cgi 脚本中添加 id 命令,返回结果是:
uid=48(apache) gid=48(apache) groups=48(apache) context=system_u:system_r:httpd_sys_script_t:s0
所以我继续处理 visudo 文件,并尝试将其添加到 visudo 文件的末尾:
httpd ALL=(root) NOPASSWD: id
或者
apache ALL=(root) NOPASSWD: id
我的 cgi 一次又一次地返回这个:
uid=48(apache) gid=48(apache) groups=48(apache) context=system_u:system_r:httpd_sys_script_t:s0
但我想要这个返回:
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
你能告诉我该怎么做吗?
最佳答案
如果将用户名作为第一个参数添加到id
,您将获得所需的输出。
[user@host ~]# id root
uid=0(root) gid=0(root) Gruppen=0(root)
关于linux - 允许 Apache 在 root 中执行命令吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56322129/