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.

I have a new VPS setup with Debian + LEMP stack. Wondering how to automatically chown/chgrp new files uploaded via FTP to /srv/www/siteroot to www-data:www-data?

I am under the assumption this can be with a proper umask?

share|improve this question
    
Which FTP daemon are you using ? –  Iain May 10 '12 at 7:32
    
stackoverflow.com/questions/10643882/… this is what you need probably –  Drt Apr 4 '13 at 13:56
add comment

3 Answers

The umask setting influences the permission bits on the newly created files and directories. It doesn't influence the ownership.

You could add the user who uploads the files to the www-data group. A umask of 022 in the FTP server would then make sure that these files are readable by the webserver but not writeable.

If you also use PHP, you could set up suphp so that the uploaded php scripts will get executed as the user to whom they belong. Like this, your scripts would also be able to write to your files (the wouldn't if they were executed as www-data).

share|improve this answer
add comment

umask sets the permissions on a file, not the ownership.

You can use chgrp www-data <dir>; chmod +s <dir> to ensure that all files created in that directory are owned by the group www-data. I don't believe there's a way to change the owner as well but with proper group permissions that shouldn't be necessary.

share|improve this answer
    
you can do chmod u+s as well, which should set the user, too, when executed on directory. it is referenced also in several places on web, but doesn't actually seem to work when i tested it right now. –  Gnudiff May 10 '12 at 11:52
add comment

If you are uploading via FTP, there should be option in FTP service config files to always set specific user and/or group on uploaded files.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.