Linux 是否允许Apache在根目录下执行命令?

Linux 是否允许Apache在根目录下执行命令?,linux,bash,redhat,root,visudo,Linux,Bash,Redhat,Root,Visudo,我正在建立一个bash/htmlcgi,它允许我在redhat7.6下使用GnuPlot生成图形。 我的导师让我创建一个cgi脚本,该脚本将能够在不使用密码的情况下返回sudo id(root),只使用“id”命令,而不是“sudo id” 我刚刚在cgi源代码中添加了id命令,以便在cgi的第一页上显示该命令的结果: 实际上,如果我在我的一个cgi脚本中添加id命令,返回值是: uid=48(apache) gid=48(apache) groups=48(apache) context=s

我正在建立一个bash/htmlcgi,它允许我在redhat7.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

我的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)
[user@host ~]# id root
uid=0(root) gid=0(root) Gruppen=0(root)