Jump to content

Recommended Posts

Hi Guys

 

I am struggling with a shell_exec command in the long run, but I am trying to work down the root cause.

 

The error I am getting with shell_exec is a file not found error, so I thought I would start with getting to the right folder.

 

I have this

 

$sym_dir = "/root/";
$cwd = getcwd();
  echo getcwd()."\n";
  chdir ($sym_dir);
  echo getcwd()."\n";

 

Which in theory should 1st display '/var/www' as it does and then display the contents of root, at least that is my understanding!

 

However my return is this /var/www /var/www

 

Why cannot I move outside the web root?

 

Cheers

Dave

Link to comment
https://forums.phpfreaks.com/topic/259826-chdir-outside-of-web-root-on-linux/
Share on other sites

Thanks for your reply

 

the following displays all files and folders for /

 

$sym_dir = "/";
  echo getcwd()."\n";
  chdir ($sym_dir);
echo shell_exec("ls -a");

 

However if I change $sym_dir back to /root/ then I just get the contents of the www folder displayed?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.