Jump to content

chdir outside of web root on linux


herghost

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.