I have a very simple script that is to test if running a shell_exec (or backtick operator) basically works:
#!/usr/bin/php5
<?php
echo "This is a PHP script\n";
echo `ls -l /home/stoysnet/`;
Unless I run this as root, it always gives me:
$ ./foo.php 
This is a PHP script
Warning: _shell_exec(): Permission Denied in /home/stoysnet/foo.php on line 5
I've tried running this via PHP in a few different ways, but I always get the same error. However, when I put the script into a subdirectory of /etc/ owned by root:root and executed as root it w开发者_如何学Corks.
What gives?
Update: Just to clarify:
- I am trying to run it as the stoysnetuser via the command line. I am able to execute the command being passed toshell_execvia the same session.
- If I move the script to /etc/somedir/and execute is asroot, it works as expected.
- The script itself runs, just not the backtick operator or shell_execpart
- Execution permissions are set, and 777doesn't work either.
Are you running this script as a different user than stoysnet? What happens when you do run ls -l /home/stoysnet as the same user that you're executing the PHP script as?
Seems like you need to run the script as a user who has permission to /home/stoysnet/.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论