[英]Executing a bash script from a web page via PHP's shell_exec(), which requires another user's perms?
I have a couple of bash scripts on a Centos box which I use to do basic server admin stuff like restart services, etc. I run these as a standard user who is also the scripts' owner. 我在Centos机器上有几个bash脚本,用于执行基本的服务器管理工作,例如重启服务等。我以标准用户的身份运行这些脚本,这些用户也是脚本的所有者。
I tried to run these using shell_exec() in PHP, with the apache user, but it simply doesn't work - I'm guessing it doesn't have enough permissions (even with 775 and being in the correct group!) to run everything I want it to. 我试图用Apache用户在PHP中使用shell_exec()运行这些程序,但是它根本行不通-我猜它没有足够的权限(即使使用775并且在正确的组中!)也无法运行我想要的一切。
I've tried editing the sudoers file giving apache permission to run the script calls but it still doesn't work and has no error messages that I can see. 我尝试编辑sudoers文件,以授予apache权限来运行脚本调用,但是它仍然无法正常工作,并且没有错误消息。
Any thoughts? 有什么想法吗? How can one trigger a script from a web page which requires a different user to run?
如何才能从需要另一用户运行的网页上触发脚本?
Make sure safe mode is off. 确保安全模式已关闭。 Also verify the user is the one you expect:
还要验证用户是否是您期望的用户:
<?php echo exec('whoami'); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.