Ftp upload / how to change permissions / ownership “automagically”

ftppermissionsvsftpd

I've got a vsftp server running.
Here's what I want to do :

2 developpers are given the access through an ftp client to a web directory.
They write the files they want.
Then they refresh the pages (F5) and the web server gives them the new pages.

Here's what I did :

  1. Create a group (name it
    allaccessgroup

    ).

  2. create
    user1

    which belongs to this group and

    user2

    which also belongs to this group

  3. create a directory
    /var/www/newsite
  4. chgrp allaccessgroup /var/www/newsite
  5. chown apache /var/www/newsite
  6. chmod 570 /var/www/newsite

This way : apache can read, and only read the php files and all user1 and user2 are given the rights to do what they want.

The problem is that I want user1 and user2 to upload their files. When they are uploaded the files permissions are allaccessgroup / user1 or allaccessgroup / user2, and I want the permissions allaccessgroup / apache.

I'm looking for a way to change the ownnership automatically as soon as the files are uploaded.
I've read some stuff like this : create a php file then call once the upload is done :

$complete = $complete.exec("ssh root@host -i /path/to/pulic/key chmod 0700 /Users/".$shortname."/Private/\n");

I don't like calling "exec" this would mean grant the "exec" access to php…
Any other idea welcome !

By the way :

I've been looking to the vsftp config file :

chown_uploads=YES
chown_username=apache

but this is for for uploaded anonymous files to be owned by a different user, not for a specific user

Any other idea welcome !

Thanks !

Best Answer

Take a look at the local_umask directive inside the vsftpd.conf