I have a php script in user1's directory, and I am getting permission denied when trying to open the directory of another 开发者_StackOverflow社区user.
So the script is in
/home/user1/script.php
and I am trying to open
/home/user2/uploadedfiles/
This is in CentOS linux. I have used
chmod -R 777 /home/user2/uploadedfiles/
and confirmed that the permissions changes have taken effect by running ls -l. Don't worry I wouldn't leave it on 777, I have just tried that in an effort to get things working.
PHP script is:
opendir(/home/user2/uploadedfiles/)
Which returns:
[function.opendir]: failed to open dir: Permission denied
I want user2 to be able to FTP up some files, but did not want to give them access to user1's folder which is where the site. So that's why there are two accounts, and user1's script is trying to get to the files user2 uploaded. Maybe I have this part wrong? Is there a better way to create a new linux account to FTP into a folder in user1's directory, but not touch anything else?
Thank you! :)
To be able to do anything with /home/user2/uploadedfiles/
, user1 must be able to traverse through /home/user2
first.
Set the execute bit (chmod ..+x
) on /home/user2
(but not the read bit, which would allow listing the directory), and remove the read and write bits of /home/user2/* (sans uploadedfiles
, of course).
精彩评论