5

I have vsftpd up and running on my Ubuntu server. This is a development server and I want to be able to FTP my code directly to the directory which Apache is serving out.

As most of you know, www-data is the Apache user and the www-data user needs to have permissions to the directory that Apache is serving out.

I didn't want to make www-data an FTP user as well, so what I did instead was create another user for use with FTP, and put both www-data and the new user in a new group called www.

I did a chown -R www-data:www * to the directory that Apache is serving and it works mostly fine.

The issue comes in when I FTP upload a file that didn't previously exist in that directory. The owner gets set to my FTP user. I want the owner to get set to www-data and the group to get set to www whenever a new file gets uploaded.

Is there any way to do this with vsftpd?

I've been furiously googling around for hours, but I can't find a way to do it. Any help would be greatly appreciated.

Edit:

I just set up a couple of cron jobs to run every minute and set the permissions:

*/1 * * * * chown -R www-data:www /var/www

*/1 * * * * chmod -R g+rw /var/www

It works but it's kind of clunky, and there's a ~1 minute delay between me uploading new code and having it work when I hit F5 in my browser.

1 Answer 1

-1

Read man 2 chmod, especially the part that says:

   S_ISGID  (02000)  set-group-ID (set process effective group ID on execve(2); mandatory locking, as described in  fcntl(2);  take  a
                     new file's group from parent directory, as described in chown(2) and mkdir(2))

You could probably use this to make all files created in the directory in the www group, and change your web server's umask value to 022

To do this safely, read and reread man 2 chmod, man 2 open, man 2 stat and anything pointed to in the See Also: sections. Learn how Linux deals with file and directory permissions for fun and/or profit!

Or, you could install inoticoming - trigger actions when files hit an incoming directory, and do your thing whenever a file hits.

You must log in to answer this question.

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