linux - 允许 Apache 在 root 中执行命令?
问题描述
我正在设置一个 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)
推荐阅读
- javascript - 谷歌浏览器没有保存我的断点
- python - 使用python在excel中进行背景单元格颜色控制
- javascript - Vue v-bind复选框到数组内部的元素不起作用
- apache - 使本地文件夹 .Htaccess 从 Root .Htaccess 导入全局规则
- go - Terraform 自定义提供程序访问生命周期元数据
- python - 如何在python中绘制条形图动画
- powershell - 谁能帮助我如何在 PowerShell 脚本中使用 Kleopatra 加密文件?
- android - 修改地图
- c# - 无法代表用户请求智能卡证书
- javascript - 在我的所有图像中添加一个对 src 上瘾的 data-src,以改进 WordPress 环境中的延迟加载功能