2

I have website folder called

/home/john/public_html

Now i want that what ever files are copied to that public_html or new files created inside that folder then those files should have default read /write permission by john , no matter who is the owner of that file.

Also i will be copying /creating files /directories by FTP , will that system work there as well or file with ftp won't have group read /write permission

i mean will umask work only files created / copied within shell or even outside shell aswell

3 Answers 3

2

You can achieve this using ACL. Look at the man page of setfacl/getfacl for details.

Unfortunately the syntax is a bit complex. Try something like:

setfacl -s u::rwx,g::r-x,o::r-x,m:rwx,u:john:rwx,d:u:john:rwx /home/john/public_html

Well, umask will still aply to newly created files, but you can "override" umask as well using ACL:

setfacl -s u::rwx,g::r-x,o::r-x,m:rwx,u:john:rwx,d:u:john:rwx,d:u::rwx,d:g::r-x,d:o::r-x,d:m:rwx /home/john/public_html
1

I'm not exactly sure what you're trying to accomplish, but it looks like it could be solved with group permissions and a setgid bit on the directory.

chown john.john-contrib /home/john/public_html
chmod 2775 /home/john/public_html

Then when people create files, they'll be owned by the group 'john-contrib'. Everyone needs to be a member of john-contrib to put files in John's directory though.

If you really want everyone to write into John's directory all the time without any security controls... then chmod 2777 would work, but that's a little insane application of the /home filesystem.

2
  • i don't want 777 . but will john-contrib still be the owner if files are created via ftp or via websit thrugh some script , not in shell
    – Mirage
    May 8, 2011 at 13:41
  • It should work, the sticky-group sets the default group ownership for files created in the directory. This occurs at the filesystem level.
    – mgjk
    May 8, 2011 at 14:58
0

If you are root on the server, you can no doubt configure the FTP server to set specific permissions on uploaded files. To make just ANY file moved in to public_html get r/w for john is another deal. Perhaps you could make a script to change group on all files in public_html. Then make sure the script loops every 1 second or something. I would not call this a good way, but I can not think of another...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .