Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my server (cpanel) I see now that with a simple DIR script (PHP) I can list files of all users over public_html

/home/[user]/public_html/

How can I prevent users from accessing the files of other users?

share|improve this question
add comment

2 Answers

When you create a user, create a group also with the same name

eg:

groupadd mike useradd -g mike mike

and change group of all folders owned by user 'mike' to group 'mike'

chgrp -R mike /home/mike/
chmod 770 to all folders and chmod 640 to all files

and make all user's umask value to 0[2|7]7 in /etc/bashrc, which will help to make these settings persistant for user accounts which will be created in future

share|improve this answer
    
As it seems to be a public_html problem, I think the web server will need to access the files, setting the homes to 770 will not allow that unless the group of the home directory is the same as the web server, and in that case, all users with web server privileges will be able to look into the files. –  mat Feb 18 '10 at 13:17
add comment

Your best bet, guessing that all users have different user id's, is to have their homes set to 0711 that is, readable, writable and executable to them, and only executable to others.

For a directory, the executable bit means that you can go in it but you can't list the content, which is what you're looking for.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.